atosatto.docker-swarm

Ansible Role: Docker

This Ansible role helps you set up Docker on RHEL/CentOS and Debian/Ubuntu servers. It supports Docker's "Swarm Mode" for creating a cluster of Docker nodes.

Requirements

  • You need Ansible version 2.7 or higher.
  • The role uses the json_filter which requires jmespath to be installed on your Ansible machine. Check the requirements.txt file for the specific version needed.

Dependencies

None.

Role Variables

Here are some available variables with default values:

  • docker_repo: Repository for Docker packages.
  • docker_package_name: Name of the Docker daemon package, default is "docker-ce".
  • docker_package_version: Version of the Docker package. Leave it empty for the latest version.
  • docker_package_state: Use present to install or latest to ensure the latest version is installed.

Additional variables include:

  • docker_service_state: State of the Docker service, typically set to "started".
  • docker_daemon_config: Options for Docker daemon configuration in /etc/docker/daemon.json.

For more variable definitions and details, check [defaults/main.yml](defaults/main.yml).

Swarm Node Labels

Use node labels for flexible organization and service constraints in your cluster. Define labels using the swarm_labels variable in your inventory.

Example Inventory

swarm-01 ansible_ssh_host=172.10.10.1
swarm-02 ansible_ssh_host=172.10.10.2

[docker_engine]
swarm-01
swarm-02

[docker_swarm_manager]
swarm-01 swarm_labels=deploy

[docker_swarm_worker]
swarm-02 swarm_labels='["libvirt", "docker", "foo", "bar"]'

Example Playbook

- name: "Provision Docker Swarm Cluster"
  hosts: all
  roles:
    - { role: atosatto.docker-swarm }

Testing

Tests are run using Molecule.

  • Install with: $ pip install tox
  • Run tests: $ tox
  • For a custom command: $ tox -e py36-ansible29 -- molecule test -s swarm-singlenode

License

MIT License

Author Information

Andrea Tosatto (@_hilbert_)

Informazioni sul progetto

Setup a Docker Swarm Cluster on Centos/RHEL, Ubuntu/Debian.

Installa
ansible-galaxy install atosatto.docker-swarm
Licenza
mit
Download
250.4k
Proprietario
Automation fan-boy. Head in the ☁️. Loving Containers, Micro-Services, OpenSource, Golang and Python