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: I8703c4982a56bad5995119a1b05578f74a9eb2d7
This commit is contained in:
Dmitriy Rabotyagov 2023-04-10 16:24:38 +02:00
parent 32fb1242d2
commit f991870918
2 changed files with 9 additions and 1 deletions

View File

@ -27,6 +27,7 @@
listen:
- "Restart mistral services"
- "venv changed"
- "systemd service changed"
- name: Start services
service:
@ -42,3 +43,4 @@
listen:
- "Restart mistral services"
- "venv changed"
- "systemd service changed"

View File

@ -27,7 +27,13 @@ filtered_mistral_services: |-
(('condition' not in value) or
('condition' in value and value['condition'])) and
not ('wsgi_app' in value and value['wsgi_app']) %}
{% 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 %}