From ab4b4a1d25ba58884fd209e64a2f63978ac99c51 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Mon, 10 Apr 2023 16:33:54 +0200 Subject: [PATCH] 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: I4eec982a682bfff121f9658c6d4eb3d1db8cb94f --- handlers/main.yml | 2 ++ vars/main.yml | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/handlers/main.yml b/handlers/main.yml index c37a2a7..d912924 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -27,6 +27,7 @@ listen: - "Restart manila services" - "venv changed" + - "systemd service changed" - name: Start services service: @@ -42,3 +43,4 @@ listen: - "Restart manila services" - "venv changed" + - "systemd service changed" diff --git a/vars/main.yml b/vars/main.yml index 96ad118..df55a80 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -31,7 +31,13 @@ filtered_manila_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 %}