Loop over separate things, fix typo and add conditionals

This commit is contained in:
Alex 2020-05-16 22:13:53 +02:00
parent 29497278df
commit 0ffb4ad724
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
2 changed files with 10 additions and 8 deletions

View File

@ -1,5 +1,5 @@
- name: Run service actions
loop: "{{ systemd }}"
loop: "{{ systemd.services }}"
systemd:
name: '{{ item.name }}'
enabled: "{% if item.enabled %}yes{% else %}no{% endif %}"

View File

@ -1,13 +1,15 @@
- name: Create override directories
loop: "{{ systemd }}"
loop: "{{ systemd.overrides }}"
file:
follow: yes
path: "/etc/systemd/system/{{ item.name }}.service.d/"
path: "/etc/systemd/system/{{ item }}.service.d/"
state: directory
- name: Template service overrides
loop: "{{ systemd }}"
when: (systemd.overrides| default([])) | length
- name: Copy service overrides
loop: "{{ systemd.overrides }}"
template:
follow: yes
src: "{{ item.name }}.service.j2"
dest: "/etc/systemd/system/{{ item.name }}.service.d/override.conf"
handlers: Run service actions
src: "{{ item }}.service.j2"
dest: "/etc/systemd/system/{{ item }}.service.d/override.conf"
notify: Run service actions
when: (systemd.overrides| default([])) | length