From 94690a06dac367d036c0aea82ba2cd278763b2e1 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Tue, 11 Apr 2023 11:54:07 +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: I4273d2fbcbff3028e693e3274093c1afebdcfca2 --- handlers/main.yml | 2 ++ vars/main.yml | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/handlers/main.yml b/handlers/main.yml index e281e3bd..c37716cc 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -70,6 +70,7 @@ - "Restart nova services" - "venv changed" - "cert installed" + - "systemd service changed" - name: Start services service: @@ -86,3 +87,4 @@ - "Restart nova services" - "venv changed" - "cert installed" + - "systemd service changed" diff --git a/vars/main.yml b/vars/main.yml index 0775b353..7ec1ded0 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -41,7 +41,14 @@ filtered_nova_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 %}