63 lines
1.5 KiB
YAML
63 lines
1.5 KiB
YAML
---
|
|
- import_playbook: meta.yml
|
|
|
|
- name: Configure docker hosts
|
|
hosts: servers
|
|
roles:
|
|
- role: docker
|
|
tasks:
|
|
- name: Disable firewall on internal interface
|
|
become: true
|
|
firewalld:
|
|
state: enabled
|
|
service: docker-swarm
|
|
permanent: true
|
|
immediate: true
|
|
|
|
- name: Configure swarm master
|
|
hosts: jupiter
|
|
tasks:
|
|
- name: Configure portainer volume
|
|
docker_volume:
|
|
volume_name: portainer
|
|
|
|
- name: Run portainer
|
|
docker_container:
|
|
name: omni.portainer
|
|
image: portainer/portainer
|
|
restart_policy: unless-stopped
|
|
published_ports:
|
|
- 0.0.0.0:8000:8000
|
|
- 0.0.0.0:9000:9000
|
|
volumes:
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
|
- portainer:/data
|
|
|
|
- name: Initialize swarm
|
|
docker_swarm:
|
|
state: present
|
|
advertise_addr: "{{ omni_docker_swarm_iface }}"
|
|
|
|
- name: Set swarm master to DRAIN
|
|
docker_node:
|
|
hostname: "{{ ansible_host }}"
|
|
availability: drain
|
|
|
|
- name: Configure swarm nodes
|
|
hosts:
|
|
- remus
|
|
- romulus
|
|
tags: docker-nodes
|
|
tasks:
|
|
- name: Fetch docker swarm information
|
|
delegate_to: jupiter
|
|
docker_swarm_info:
|
|
register: _swarm_info
|
|
|
|
- name: Join workers to swarm
|
|
docker_swarm:
|
|
state: join
|
|
remote_addrs: ["jupiter.svr.local"]
|
|
join_token: "{{ _swarm_info.swarm_facts.JoinTokens.Worker }}"
|
|
advertise_addr: "{{ omni_docker_swarm_iface }}"
|