feat: replace docker variable to swarm
This commit is contained in:
parent
8a95fc66e5
commit
66ac6e704a
6 changed files with 24 additions and 24 deletions
|
@ -1,4 +1,5 @@
|
||||||
---
|
---
|
||||||
docker_swarm_manager: false
|
swarm_manager: false
|
||||||
docker_repo_distribution: '{{ ansible_distribution_release }}'
|
swarm_advertise_addr: 127.0.0.1
|
||||||
docker_services: []
|
swarm_services: []
|
||||||
|
swarm_networks: []
|
||||||
|
|
|
@ -4,11 +4,10 @@
|
||||||
roles:
|
roles:
|
||||||
- swarm
|
- swarm
|
||||||
vars:
|
vars:
|
||||||
docker_swarm_manager: true
|
swarm_manager: true
|
||||||
docker_advertise_addr: 127.0.0.1
|
swarm_networks:
|
||||||
docker_networks:
|
|
||||||
- name: proxy
|
- name: proxy
|
||||||
docker_services:
|
swarm_services:
|
||||||
- name: traefik
|
- name: traefik
|
||||||
image: traefik:1.7
|
image: traefik:1.7
|
||||||
networks:
|
networks:
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
---
|
---
|
||||||
- name: init swarm cluster
|
- name: init swarm cluster
|
||||||
community.docker.docker_swarm:
|
community.docker.docker_swarm:
|
||||||
advertise_addr: '{{ docker_advertise_addr }}'
|
advertise_addr: '{{ swarm_advertise_addr }}'
|
||||||
state: present
|
state: present
|
||||||
when: docker_swarm_manager
|
when: swarm_manager
|
||||||
tags: docker
|
tags: swarm
|
||||||
|
|
||||||
- name: join swarm cluster
|
- name: join swarm cluster
|
||||||
community.docker.docker_swarm:
|
community.docker.docker_swarm:
|
||||||
advertise_addr: '{{ docker_advertise_addr }}'
|
advertise_addr: '{{ swarm_advertise_addr }}'
|
||||||
join_token: '{{ docker_join_token }}'
|
join_token: '{{ swarm_join_token }}'
|
||||||
remote_addrs: '{{ docker_remote_addrs }}'
|
remote_addrs: '{{ swarm_remote_addrs }}'
|
||||||
state: join
|
state: join
|
||||||
when: not docker_swarm_manager
|
when: not swarm_manager
|
||||||
tags: docker
|
tags: swarm
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
driver: '{{ item.driver|default("bridge") }}'
|
driver: '{{ item.driver|default("bridge") }}'
|
||||||
scope: swarm
|
scope: swarm
|
||||||
state: '{{ item.state|default("present") }}'
|
state: '{{ item.state|default("present") }}'
|
||||||
loop: '{{ docker_networks }}'
|
loop: '{{ swarm_networks }}'
|
||||||
tags: docker
|
tags: swarm
|
||||||
|
|
||||||
- name: manage services
|
- name: manage services
|
||||||
community.docker.docker_swarm_service:
|
community.docker.docker_swarm_service:
|
||||||
|
@ -22,16 +22,16 @@
|
||||||
env: '{{ item.env|default({}) }}'
|
env: '{{ item.env|default({}) }}'
|
||||||
container_labels: '{{ item.labels|default({}) }}'
|
container_labels: '{{ item.labels|default({}) }}'
|
||||||
state: present
|
state: present
|
||||||
loop: '{{ docker_services }}'
|
loop: '{{ swarm_services }}'
|
||||||
when: '"state" not in item or item.state != "absent"'
|
when: '"state" not in item or item.state != "absent"'
|
||||||
no_log: false
|
no_log: false
|
||||||
tags: docker
|
tags: swarm
|
||||||
|
|
||||||
- name: remove services
|
- name: remove services
|
||||||
community.docker.docker_swarm_service:
|
community.docker.docker_swarm_service:
|
||||||
name: '{{ item.name }}'
|
name: '{{ item.name }}'
|
||||||
state: absent
|
state: absent
|
||||||
loop: '{{ docker_services }}'
|
loop: '{{ swarm_services }}'
|
||||||
when: '"state" in item and item.state == "absent"'
|
when: '"state" in item and item.state == "absent"'
|
||||||
no_log: true
|
no_log: true
|
||||||
tags: docker
|
tags: swarm
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
name:
|
name:
|
||||||
- docker.io
|
- docker.io
|
||||||
- python3-docker
|
- python3-docker
|
||||||
tags: docker
|
tags: swarm
|
||||||
|
|
||||||
- name: enable and start service
|
- name: enable and start service
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: docker
|
name: docker
|
||||||
state: started
|
state: started
|
||||||
tags: docker
|
tags: swarm
|
||||||
|
|
|
@ -2,4 +2,4 @@
|
||||||
- import_tasks: install.yml
|
- import_tasks: install.yml
|
||||||
- import_tasks: cluster.yml
|
- import_tasks: cluster.yml
|
||||||
- import_tasks: config.yml
|
- import_tasks: config.yml
|
||||||
when: docker_swarm_manager
|
when: swarm_manager
|
||||||
|
|
Loading…
Reference in a new issue