|
@@ -29,15 +29,19 @@
|
|
mode: a=r
|
|
mode: a=r
|
|
register: _dropin_config_file
|
|
register: _dropin_config_file
|
|
when: systemd_unit_dropin_config is defined
|
|
when: systemd_unit_dropin_config is defined
|
|
|
|
+- name: set return values
|
|
|
|
+ set_fact:
|
|
|
|
+ systemd_unit_config_changed: >-
|
|
|
|
+ {{ _config_file.changed or _dropin_config_file.changed }}
|
|
- name: 'fetch state of systemd unit {{ systemd_unit_name }}'
|
|
- name: 'fetch state of systemd unit {{ systemd_unit_name }}'
|
|
systemd:
|
|
systemd:
|
|
name: '{{ systemd_unit_name }}'
|
|
name: '{{ systemd_unit_name }}'
|
|
register: _unit
|
|
register: _unit
|
|
when: systemd_unit_scope == 'system'
|
|
when: systemd_unit_scope == 'system'
|
|
- and (_config_file.changed or _dropin_config_file.changed or systemd_unit_restart_if_active)
|
|
+ and (systemd_unit_config_changed or systemd_unit_restart_if_active)
|
|
- name: 'set state of systemd unit {{ systemd_unit_name }}'
|
|
- name: 'set state of systemd unit {{ systemd_unit_name }}'
|
|
systemd:
|
|
systemd:
|
|
- daemon_reload: '{{ _config_file.changed or _dropin_config_file.changed }}'
|
|
+ daemon_reload: '{{ systemd_unit_config_changed }}'
|
|
name: '{{ systemd_unit_name }}'
|
|
name: '{{ systemd_unit_name }}'
|
|
enabled: '{{ systemd_unit_enabled | default(omit) }}'
|
|
enabled: '{{ systemd_unit_enabled | default(omit) }}'
|
|
# > `started'/`stopped' are idempotent actions [...]
|
|
# > `started'/`stopped' are idempotent actions [...]
|
|
@@ -45,16 +49,14 @@
|
|
state: >-
|
|
state: >-
|
|
{{ "restarted" if (systemd_unit_state is not defined
|
|
{{ "restarted" if (systemd_unit_state is not defined
|
|
or systemd_unit_state != "stopped")
|
|
or systemd_unit_state != "stopped")
|
|
- and (_config_file.changed
|
|
+ and (systemd_unit_config_changed
|
|
- or _dropin_config_file.changed
|
|
|
|
or systemd_unit_restart_if_active)
|
|
or systemd_unit_restart_if_active)
|
|
and 'ActiveState' in _unit.status
|
|
and 'ActiveState' in _unit.status
|
|
and _unit.status.ActiveState == "active"
|
|
and _unit.status.ActiveState == "active"
|
|
else systemd_unit_state | default(omit) }}
|
|
else systemd_unit_state | default(omit) }}
|
|
when: >-
|
|
when: >-
|
|
systemd_unit_scope == 'system'
|
|
systemd_unit_scope == 'system'
|
|
- and (_config_file.changed
|
|
+ and (systemd_unit_config_changed
|
|
- or _dropin_config_file.changed
|
|
|
|
or systemd_unit_enabled is defined
|
|
or systemd_unit_enabled is defined
|
|
or systemd_unit_state is defined
|
|
or systemd_unit_state is defined
|
|
or (systemd_unit_restart_if_active
|
|
or (systemd_unit_restart_if_active
|