From ddefe53b61116af5319b5b01cf0fe380e7b4bc1e Mon Sep 17 00:00:00 2001 From: Vojtech Mares Date: Mon, 30 Dec 2024 15:03:53 +0100 Subject: [PATCH] ci: add ansible task to check if systemd unit file exists --- playbook.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/playbook.yml b/playbook.yml index d6323b1..e372a79 100644 --- a/playbook.yml +++ b/playbook.yml @@ -14,6 +14,11 @@ dest: /usr/local/bin/caddy mode: "0755" + - name: Check if systemd unit file exists + stat: + path: /etc/systemd/system/caddy.service + register: systemd_unit_file + - name: Create systemd unit file for Caddy copy: dest: /etc/systemd/system/caddy.service @@ -31,7 +36,7 @@ [Install] WantedBy=multi-user.target - when: not ansible_facts['systemd']['units']['caddy.service'] + when: not systemd_unit_file.stat.exists - name: Enable and start Caddy service systemd: