|
2 | 2 | # NB: As `appliances_persistent_services` is defined in group_vars/all, all tasks here are conditional |
3 | 3 | - name: Make directory for unit dropins |
4 | 4 | file: |
5 | | - path: "/etc/systemd/system/{{ item.value }}.service.d/" |
| 5 | + path: "/etc/systemd/system/{{ item.key }}.service.d/" |
6 | 6 | state: directory |
7 | 7 | loop: "{{ appliances_persistent_services | dict2items }}" |
8 | | - when: "'item.key' in group_names" |
| 8 | + when: "'item.value' in group_names" |
9 | 9 |
|
10 | 10 | - name: Add dropins for unit files |
11 | 11 | ansible.builtin.copy: |
12 | 12 | content: | |
13 | 13 | [Unit] |
14 | 14 | RequiresMountsFor={{ appliances_state_dir }} |
15 | | - dest: "/etc/systemd/system/{{ item.value }}.service.d/appliance_state.conf" |
| 15 | + dest: "/etc/systemd/system/{{ item.key }}.service.d/appliance_state.conf" |
16 | 16 | loop: "{{ appliances_persistent_service | dict2items }}" |
17 | | - register: persistent_services_dropins |
18 | | - when: "'item.key' in group_names" |
| 17 | + register: _systemd_persistent_services_dropins |
| 18 | + when: "'item.value' in group_names" |
19 | 19 |
|
20 | 20 | - name: Reload unit definitions |
21 | 21 | ansible.builtin.shell: |
22 | 22 | cmd: systemctl daemon-reload |
23 | | - when: |
24 | | - - persistent_services_dropins.changed |
25 | | - - "'item.key' in group_names" |
| 23 | + when: _systemd_persistent_services_dropins.changed |
26 | 24 |
|
27 | 25 | - name: Reload units |
28 | 26 | ansible.builtin.systemd: |
29 | | - name: "{{ item.value }}" |
| 27 | + name: "{{ item.key }}" |
30 | 28 | state: restarted |
31 | 29 | loop: "{{ appliances_persistent_service | dict2items }}" |
32 | 30 | when: |
33 | | - - persistent_services_dropins.changed |
34 | | - - "'item.key' in group_names" |
| 31 | + - _systemd_persistent_services_dropins.changed |
| 32 | + - "'item.value' in group_names" |
35 | 33 | # - "'builder' not in group_names" # because mount of appliances_state_dir won't be done in builder |
0 commit comments