ansible-on-prem/playbooks/deploy-swarm.yml
2025-07-16 17:14:16 -06:00

74 lines
2.5 KiB
YAML

- name: Deploy Docker Swarm mgmt & stacks
hosts: prod_vms
become: true
roles:
- role: docker/swarm/mgmt
when: "'swarm_manager' in hostvars[inventory_hostname]['vm_roles']"
- role: docker/swarm/node
when: "'swarm_manager' in hostvars[inventory_hostname]['vm_roles']"
- role: docker/swarm/stacks
when: "'swarm_manager' in hostvars[inventory_hostname]['vm_roles']"
vars:
stacks:
- name: portainer
compose_path: portainer-compose.j2
restart_condition: on-failure
replicas: 1
labels:
com.xbazzi.stack: portainer
com.xbazzi.critical: "true"
constraints:
- node.role == manager
- node.hostname == prod2
- node.labels.zone == core
- name: caddy
compose_path: caddy-compose.j2
deploy_mode: replicated
replicas: 1
restart_condition: on-failure
labels:
com.xbazzi.stack: caddy
com.xbazzi.critical: "true"
constraints:
- node.role == manager
- node.labels.zone == core
- node.labels.type != db
volumes:
- /docker-shared/stacks/data/caddy/conf:/etc/caddy
- /docker-shared/stacks/data/caddy/site:/srv
- /docker-shared/stacks/data/caddy/caddy_data:/data
- /docker-shared/stacks/data/caddy/caddy_config:/config
- /var/run/docker.sock:/var/run/docker.sock
mount_dirs:
- /docker-shared/stacks/data/caddy/conf
- /docker-shared/stacks/data/caddy/site
- /docker-shared/stacks/data/caddy/caddy_data
- /docker-shared/stacks/data/caddy/caddy_config
- name: nginx
compose_path: nginx-compose.j2
deploy_mode: replicated
replicas: 1
restart_condition: on-failure
labels:
com.xbazzi.stack: nginx
com.xbazzi.critical: "false"
constraints:
- node.labels.zone == core
- node.labels.type != db
# - name: sleep
# compose_path: sleep-forever-compose.j2
# deploy_mode: replicated
# replicas: 5
# restart_condition: on-failure
# labels:
# com.xbazzi.stack: sleep
# com.xbazzi.critical: "false"
# constraints:
# - node.labels.zone == core
# - node.labels.type != db