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: