From 7012e1ea2b14979dce75b56db226d5ce83f3b6a0 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Wed, 12 Apr 2023 20:23:08 +0200 Subject: [PATCH] Separate enable and re-/start service for fine-control --- wireguard-ipv6-converter/tasks/setup-service.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wireguard-ipv6-converter/tasks/setup-service.yml b/wireguard-ipv6-converter/tasks/setup-service.yml index 600e2d7..c12fc5c 100644 --- a/wireguard-ipv6-converter/tasks/setup-service.yml +++ b/wireguard-ipv6-converter/tasks/setup-service.yml @@ -4,9 +4,14 @@ dest: /etc/systemd/system/wg-ipv6-converter_{{ wireguard_ipv6_converter.setup.interface }}.service register: serviceFile -- name: Enable & Start service +- name: Enable service ansible.builtin.service: name: wg-ipv6-converter_{{ wireguard_ipv6_converter.setup.interface }} - state: "{{ 'restarted' if serviceFile.changed else 'started' }}" - enabled: true daemon-reload: true + enabled: true + +- name: Start service if interface exists already + ansible.builtin.service: + name: wg-ipv6-converter_{{ wireguard_ipv6_converter.setup.interface }} + state: "{{ 'restarted' if deployDownload.changed or serviceFile.changed else 'started' }}" + when: "wireguard_ipv6_converter.setup.interface in ansible_interfaces"