--- - name: Gather variables for each operating system include_vars: "{{ ansible_distribution | lower }}.yml" - name: "Check caddy version" ansible.builtin.shell: "set -eo pipefail; caddy version | cut -d' ' -f 1 | cut -d'v' -f 2" args: executable: /bin/bash register: caddy_active_version changed_when: false failed_when: false when: caddy_version_check|bool - include_tasks: "create_user.yml" - include_tasks: "install.yml" - include_tasks: install_systemd.yml when: ansible_service_mgr == "systemd" - name: "Create config and data directory" ansible.builtin.file: path: "{{ item }}" state: directory owner: "{{ caddy_user }}" group: "{{ caddy_group }}" mode: '0755' with_items: - "/etc/caddy" - name: "Configure caddy" ansible.builtin.template: src: Caddyfile.j2 dest: /etc/caddy/Caddyfile owner: "{{ caddy_user }}" group: "{{ caddy_group }}" mode: 0600 notify: "Restart caddy" - name: "Service caddy" ansible.builtin.service: name: caddy state: started enabled: true when: ansible_service_mgr == "systemd"