Ensure service is restarted on unit file changes

At the moment we don't restart services if systemd unit file is changed.

We knowingly prevent systemd_service role handlers to execute
by providing `state: started` as otherwise service will be restarted twice.
With that now  we ensure that role handlers will also listen for systemd
unit changes.

Change-Id: I78c9888f7f2b97bd901d9fcce636bc22b6411eb9
This commit is contained in:
Dmitriy Rabotyagov 2023-04-11 12:47:24 +02:00 committed by Dmitriy Rabotyagov
parent e7527d082e
commit 5849da07b9
2 changed files with 9 additions and 1 deletions

View File

@ -22,6 +22,7 @@
with_items: "{{ filtered_swift_services }}"
listen:
- "venv changed"
- "systemd service changed"
- name: Restart rsync service
service:

View File

@ -22,7 +22,14 @@ filtered_swift_services: |-
{% if (value['group'] in group_names) and
(('service_en' not in value) or
('service_en' in value and value['service_en'])) %}
{% set _ = value.update({'service_key': key}) %}
{% set _ = value.update(
{
'service_key': key,
'enabled': value['enabled'] | default(True),
'state': value['state'] | default('started')
}
)
%}
{% set _ = services.append(value) %}
{% endif %}
{% endfor %}