-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathdocker-swarm-portainer-caddy-openziti.yml
59 lines (48 loc) · 1.74 KB
/
docker-swarm-portainer-caddy-openziti.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
- name: Determine affected roles
hosts: localhost
gather_facts: false
roles:
- utils-affected-roles
# BASE
- name: This is the base requirement for all nodes
hosts: all
become: true
roles:
- role: docker
when: "'docker' in hostvars['localhost']['roles_with_changes']"
# SWARM
- name: This setup the Docker Swarm Manager
hosts: managers
gather_facts: true
become: true
roles:
# NOTE: One node requires python and extra tools to setup the swarm, I call it the controller.
# I case we have an issue all master are setup as potential controller
# this role is for the host running ansible to manage the swarm
- role: docker-swarm-controller
when: "'docker-swarm-controller' in hostvars['localhost']['roles_with_changes']"
# this role is for creating the swarm and adding host as manager
- role: docker-swarm-manager
when: "'docker-swarm-manager' in hostvars['localhost']['roles_with_changes']"
- name: This setup nodes to join the Swarm
hosts: nodes
roles:
- role: docker-swarm-node # this role is for host to join the swarm
when: "'docker-swarm-node' in hostvars['localhost']['roles_with_changes']"
# PLUGINS
- name: This installs docker plugins on all hosts
hosts: all
become: true
roles:
- role: docker-swarm-plugin-rclone
when: "'docker-swarm-plugin-rclone' in hostvars['localhost']['roles_with_changes']"
# APPS
- name: This install Caddy and Portainer in the Swarm
hosts: managers[0] # Only one manager need to be hit
become: true
roles:
- role: docker-swarm-app-caddy
when: "'docker-swarm-app-caddy' in hostvars['localhost']['roles_with_changes']"
- role: docker-swarm-app-portainer
caddy: true
when: "'docker-swarm-app-portainer' in hostvars['localhost']['roles_with_changes']"