2022-12-22 19:18:27 +00:00
|
|
|
# vim: ft=yaml.ansible
|
2022-12-22 16:58:48 +00:00
|
|
|
---
|
|
|
|
- name: Create Caddy volume directories
|
2023-03-22 18:31:21 +00:00
|
|
|
ansible.builtin.file:
|
2022-12-22 16:58:48 +00:00
|
|
|
name: "{{ services.caddy.volume }}/{{ dir }}"
|
2022-12-23 14:54:29 +00:00
|
|
|
owner: root
|
2022-12-22 16:58:48 +00:00
|
|
|
mode: u=rwx,g=rx,o=rx
|
|
|
|
state: directory
|
|
|
|
loop:
|
|
|
|
- config
|
|
|
|
- data
|
|
|
|
loop_control:
|
|
|
|
loop_var: dir
|
|
|
|
|
|
|
|
- name: Copy Caddyfile
|
2023-03-22 18:31:21 +00:00
|
|
|
ansible.builtin.template:
|
2022-12-22 16:58:48 +00:00
|
|
|
src: Caddyfile.j2
|
|
|
|
dest: "{{ services.caddy.volume }}/Caddyfile"
|
2022-12-23 14:54:29 +00:00
|
|
|
owner: root
|
2022-12-22 16:58:48 +00:00
|
|
|
mode: u=rw,g=r,o=r
|
|
|
|
|
2023-07-02 16:07:23 +00:00
|
|
|
- name: Copy caddy.Dockerfile
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: caddy.Dockerfile.j2
|
|
|
|
dest: "{{ services.caddy.volume }}/caddy.Dockerfile"
|
|
|
|
owner: root
|
|
|
|
mode: u=rw,g=r,o=r
|
|
|
|
register: dockerfile
|
|
|
|
notify: Build Caddy Docker image
|
|
|
|
|
|
|
|
- name: Flush handlers
|
|
|
|
ansible.builtin.meta: flush_handlers
|
|
|
|
|
2022-12-22 16:58:48 +00:00
|
|
|
- name: Deploy Caddy Docker container
|
2023-03-22 18:31:21 +00:00
|
|
|
community.docker.docker_container:
|
2022-12-22 16:58:48 +00:00
|
|
|
name: caddy
|
2023-04-19 20:58:17 +00:00
|
|
|
state: "{{ 'absent' if stop is defined and stop else 'started' }}"
|
2023-04-20 22:29:19 +00:00
|
|
|
restart: "{{ stop is undefined or not stop }}"
|
2023-07-02 16:07:23 +00:00
|
|
|
recreate: "{{ dockerfile.changed }}"
|
|
|
|
image: custom/caddy:{{ services.caddy.version }}-alpine
|
2023-01-14 18:25:13 +00:00
|
|
|
restart_policy: always
|
2023-04-26 22:03:38 +00:00
|
|
|
default_host_ip: ''
|
2022-12-28 16:51:02 +00:00
|
|
|
networks:
|
2022-12-28 17:03:57 +00:00
|
|
|
- name: services
|
2023-01-06 19:33:30 +00:00
|
|
|
ipv4_address: 172.16.3.2
|
2022-12-28 17:24:27 +00:00
|
|
|
published_ports:
|
2023-01-03 21:30:22 +00:00
|
|
|
- 80:80/tcp
|
|
|
|
- 443:443/tcp
|
2023-03-30 13:41:37 +00:00
|
|
|
- 18089:18089/tcp
|
2022-12-22 16:58:48 +00:00
|
|
|
volumes:
|
|
|
|
- "{{ services.caddy.volume }}/Caddyfile:/etc/caddy/Caddyfile:ro"
|
|
|
|
- "{{ services.caddy.volume }}/config:/config:rw"
|
|
|
|
- "{{ services.caddy.volume }}/data:/data:rw"
|
|
|
|
capabilities:
|
|
|
|
- net_bind_service
|
|
|
|
- dac_override
|
|
|
|
cap_drop:
|
|
|
|
- all
|