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: I53545ede7b2f129bbbf3518ab517f6f37d78598e
This commit is contained in:
Dmitriy Rabotyagov 2023-04-11 13:02:41 +02:00 committed by Dmitriy Rabotyagov
parent 51e347dcb9
commit 330b91efec
2 changed files with 3 additions and 1 deletions

View File

@ -81,6 +81,7 @@
listen:
- "Restart zun services"
- "venv changed"
- "systemd service changed"
- name: Start services
systemd:
@ -96,3 +97,4 @@
listen:
- "Restart zun services"
- "venv changed"
- "systemd service changed"

View File

@ -24,7 +24,7 @@ filtered_zun_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({'enabled': 'yes', 'state': 'started'}) %}
{% set _ = value.update({'enabled': value['enabled'] | default(True), 'state': value['state'] | default('started')}) %}
{% set _ = value.update({'config_overrides': (zun_service_defaults | combine(value.init_config_overrides, recursive=True))}) %}
{% set _ = value.pop('init_config_overrides') %}
{% set _ = services.append(value) %}