From 330b91efecea2c8859ca610f130d7b7eb2e9835e Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Tue, 11 Apr 2023 13:02:41 +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: I53545ede7b2f129bbbf3518ab517f6f37d78598e --- handlers/main.yml | 2 ++ vars/main.yml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/handlers/main.yml b/handlers/main.yml index d2d0e4f..9cb4835 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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" diff --git a/vars/main.yml b/vars/main.yml index 8e6e8a5..fb6d532 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -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) %}