Add separate service and config changes handlers

This commit is contained in:
Alex 2020-06-05 15:41:47 +02:00
parent 64e64e6b03
commit b6f5c6a4f1
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
2 changed files with 7 additions and 5 deletions

View File

@ -1,6 +1,3 @@
- name: Reload daemon
systemd:
daemon_reload: true
- name: Run service actions - name: Run service actions
loop: "{{ systemd.services }}" loop: "{{ systemd.services }}"
systemd: systemd:
@ -8,3 +5,9 @@
enabled: "{% if item.enabled|default(false) %}yes{% else %}no{% endif %}" enabled: "{% if item.enabled|default(false) %}yes{% else %}no{% endif %}"
state: "{{ item.action }}" state: "{{ item.action }}"
daemon_reload: "{% if item.daemon_reload|default(false) %}yes{% else %}no{% endif %}" daemon_reload: "{% if item.daemon_reload|default(false) %}yes{% else %}no{% endif %}"
- name: Restart services
loop: "{{ systemd.services }}"
systemd:
name: '{{ item.name }}'
state: "restarted"
daemon_reload: true

View File

@ -15,8 +15,7 @@
src: "{{ item }}.service.j2" src: "{{ item }}.service.j2"
dest: "/etc/systemd/system/{{ item }}.service.d/override.conf" dest: "/etc/systemd/system/{{ item }}.service.d/override.conf"
notify: notify:
- Reload daemon - Restart services
- Run service actions
when: (systemd.overrides| default([])) | length when: (systemd.overrides| default([])) | length
tags: tags:
- systemd - systemd