Handle 'state' (present,attached,absent,detached)

This commit is contained in:
Sebastien Thebert committed 2022-10-30 01:29:02 +02:00
1 parent 7cc01844f1
commit 6a09818893
5 files changed
+52 -12

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
---
- ansible.builtin.shell: "command pro"
register: reg_command_pro
ignore_errors: yes
- set_fact:
pro_command_exists: "{{ (reg_command_pro.rc == 127) | ternary(false, true) }}"
- name: Unregister this host on Ubuntu Pro (pro detach)
ansible.builtin.command: "pro detach --assume-yes"
become: yes
register: reg_pro_detach
changed_when: reg_pro_detach.rc == 0
failed_when: (reg_pro_detach.rc != 0) and ('This machine is not attached to an Ubuntu Pro subscription.' not in reg_pro_detach.stderr_lines[0])
when: pro_command_exists
- name: Print 'pro detach' command output
ansible.builtin.debug:
var: reg_pro_detach
when: (debug and pro_command_exists)