This repo contains the advanced examples for the Ansible Docker Swarm Management role https://github.com/karvounis/ansible-docker-swarm-management-role.
Execute ansible-galaxy install -r requirements.yml
to download the dependencies.
$ tree -L 2
├── ansible.cfg
├── ansible_collections
├── inventory
│ ├── group_vars
│ └── hosts
├── LICENSE
├── playbooks
│ ├── swarm-stacks-cleanup.yml
│ └── swarm-stacks.yml
├── README.md
├── requirements.yml
├── roles
└── templates
├── configs
└── stacks
- /inventory: Contains the hosts file (using local connection) and the variables for the role.
- /playbooks: Contains the playbooks to execute.
- /templates: Contains the template files for the Docker configs and stacks.
Executing ansible-playbook playbooks/swarm-stacks.yml
will create the following resources:
- Networks
- example_network_mysql
- example_network_postgres
- Volumes
- example_data_mysql
- example_data_postgres
- Secrets
- example_secret_mysql
- example_secret_postgres
- Configs
- example_config_one
- example_config_two
- example_config_three
- example_config_four
- Stacks
- example_stack_mysql
- example_stack_postgres
The resources with the suffix _mysql
are external dependencies to the example_stack_mysql
stack and the ones with the _postgres
suffix to the example_stack_postgres
stack.
The example_stack_mysql
stack is being generated by a simple docker-compose yaml file.
The example_stack_postgres
stack is being generated by a Jinja2 template file.
In order to cleanup the example resources execute
docker stack rm example_stack_mysql
docker stack rm example_stack_postgres
ansible-playbook playbooks/swarm-stacks-cleanup.yml --skip-tags stacks,pip