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: Iaa2f286fa25412a1ed8c72c0b62bacd3ac50f125
This commit is contained in:
Dmitriy Rabotyagov 2023-04-11 12:41:51 +02:00
parent 250411c408
commit 5ad5bc1d84
2 changed files with 10 additions and 1 deletions

View File

@ -28,6 +28,7 @@
listen: listen:
- "Restart placement services" - "Restart placement services"
- "venv changed" - "venv changed"
- "systemd service changed"
- name: Start services - name: Start services
service: service:
@ -43,3 +44,4 @@
listen: listen:
- "Restart placement services" - "Restart placement services"
- "venv changed" - "venv changed"
- "systemd service changed"

View File

@ -26,7 +26,14 @@ filtered_placement_services: |-
(('condition' not in value) or (('condition' not in value) or
('condition' in value and value['condition'])) and ('condition' in value and value['condition'])) and
not ('wsgi_app' in value and value['wsgi_app']) %} 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) %} {% set _ = services.append(value) %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}