---
- name: Package cache updated
  shell: pkg update -f

- name: Caddy package installed
  community.general.pkgng:
    name: "caddy"
    state: latest

- name: Caddy enabled
  shell:
    cmd: sysrc caddy_enable="YES"

- name: Caddyfile installed
  copy:
    src: Caddyfile
    dest: /usr/local/etc/caddy/Caddyfile
    owner: root
    mode: 0644
  notify: Caddy restarted

- name: Caddy started
  service: name=caddy state=started
