Add basic caddy swarm role
Added caddy as swarm container. Uses templated Caddyfile which can be set up for testing purposes for now. Depends on docker and docker-swarm, and will keep its stuff where docker-swarm sets itself up.
This commit is contained in:
parent
453cd2fd2b
commit
9f188c2674
7 changed files with 102 additions and 0 deletions
27
roles/caddy/tasks/main.yml
Normal file
27
roles/caddy/tasks/main.yml
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
# install caddy as a docker stack
|
||||
|
||||
- name: Ensure Caddyfile directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ caddy_caddyfile_dir }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
become: true
|
||||
|
||||
- name: Ensure Caddyfile exists
|
||||
ansible.builtin.template:
|
||||
src: Caddyfile.j2
|
||||
dest: "{{ caddy_caddyfile_dir }}/Caddyfile"
|
||||
validate: "docker run --rm -v %s:/Caddyfile caddy caddy validate --config /Caddyfile"
|
||||
become: true
|
||||
|
||||
- name: Deploy caddy to swarm
|
||||
community.general.docker_stack:
|
||||
name: "{{ item.name }}"
|
||||
state: present
|
||||
prune: yes
|
||||
compose:
|
||||
- "{{ item.compose }}"
|
||||
with_items: "{{ caddy_stack }}"
|
||||
when: caddy_stack is defined
|
||||
become: yes
|
||||
Loading…
Add table
Add a link
Reference in a new issue