|
8 | 8 |
|
9 | 9 | - name: Restart libvirtd (NOW) |
10 | 10 | ansible.builtin.service: |
11 | | - name: "{{ _name[ansible_os_family] }}" |
| 11 | + name: libvirtd |
12 | 12 | state: restarted |
13 | | - vars: |
14 | | - _name: |
15 | | - Debian: libvirtd |
16 | | - RedHat: libvirtd |
17 | 13 | when: lineinfile is changed |
18 | 14 |
|
19 | 15 | - name: Disable Libvirt's default network (optional) |
|
28 | 24 | changed_when: false |
29 | 25 | when: disable_default_net | bool is true |
30 | 26 |
|
31 | | -- name: Populate service facts |
32 | | - ansible.builtin.service_facts: |
| 27 | +- name: Query raw status of virtqemud.service |
| 28 | + ansible.builtin.systemd: |
| 29 | + name: virtqemud.service |
| 30 | + register: systemd_virtqemud |
33 | 31 | no_log: true |
34 | 32 |
|
35 | 33 | # NOTE: OpenNebula cannot deal with socket-activated Libvirt (yet), |
36 | | -# so the socket activation *MUST* be disabled. |
37 | | -- when: ansible_facts.services is contains('virtqemud.service') |
| 34 | +# so the socket activation *MUST* be disabled. |
| 35 | +- when: systemd_virtqemud.status.LoadState not in ['masked', 'not-found'] |
38 | 36 | block: |
39 | 37 | - name: Mask virtqemud* units and libvirtd* sockets |
40 | 38 | ansible.builtin.systemd: |
41 | 39 | name: "{{ item }}" |
42 | 40 | enabled: false |
43 | 41 | masked: true |
44 | 42 | state: stopped |
| 43 | + register: result |
| 44 | + failed_when: |
| 45 | + - result is failed |
| 46 | + - result.status.LoadState is defined and result.status.LoadState != 'not-found' |
45 | 47 | loop: |
46 | 48 | - virtqemud.service |
47 | 49 | - virtqemud.socket |
48 | 50 | - virtqemud-admin.socket |
49 | 51 | - virtqemud-ro.socket |
50 | | - - libvirtd.socket |
51 | | - - libvirtd-admin.socket |
52 | | - - libvirtd-ro.socket |
53 | | - - libvirtd-tcp.socket |
54 | | - - libvirtd-tls.socket |
55 | 52 |
|
56 | 53 | - name: Create /etc/systemd/system/libvirtd.service.d/ |
57 | 54 | ansible.builtin.file: |
|
100 | 97 | get_attributes: false |
101 | 98 | get_checksum: false |
102 | 99 | get_mime: false |
103 | | - register: stat_libvirt_qemu |
| 100 | + register: stat |
104 | 101 |
|
105 | | - - when: stat_libvirt_qemu.stat.exists is true |
| 102 | + - when: stat.stat.exists is true |
106 | 103 | block: |
107 | 104 | - name: Add permissions to AppArmor |
108 | 105 | ansible.builtin.lineinfile: |
|
111 | 108 | loop: |
112 | 109 | - " /srv/** rwk," |
113 | 110 | - " /var/lib/one/datastores/** rwk," |
114 | | - register: lineinfile_libvirt_qemu |
| 111 | + register: lineinfile |
115 | 112 |
|
116 | 113 | - name: Reload apparmor |
117 | 114 | ansible.builtin.service: |
|
122 | 119 | - result is failed |
123 | 120 | - result.msg is not contains("find") |
124 | 121 | - result.msg is not contains("found") |
125 | | - when: lineinfile_libvirt_qemu is changed |
| 122 | + when: lineinfile is changed |
0 commit comments