From 5ad5bc1d84f245fe59f5c52ac5227e4cabff6424 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Tue, 11 Apr 2023 12:41:51 +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: Iaa2f286fa25412a1ed8c72c0b62bacd3ac50f125 --- 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 3a5100b..d642bb8 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -28,6 +28,7 @@ listen: - "Restart placement services" - "venv changed" + - "systemd service changed" - name: Start services service: @@ -43,3 +44,4 @@ listen: - "Restart placement services" - "venv changed" + - "systemd service changed" diff --git a/vars/main.yml b/vars/main.yml index 109af7a..6057d1a 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -26,7 +26,14 @@ filtered_placement_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 %}