{"id":13579744,"url":"https://github.com/atosatto/ansible-dockerswarm","last_synced_at":"2025-10-08T02:58:17.908Z","repository":{"id":47261547,"uuid":"62576341","full_name":"atosatto/ansible-dockerswarm","owner":"atosatto","description":"Docker Engine clustering using \"Swarm Mode\" and Ansible","archived":false,"fork":false,"pushed_at":"2022-04-11T13:51:10.000Z","size":119,"stargazers_count":265,"open_issues_count":18,"forks_count":148,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-05-25T21:06:51.263Z","etag":null,"topics":["ansible","docker","docker-swarm","molecule","swarm-mode"],"latest_commit_sha":null,"homepage":"https://galaxy.ansible.com/atosatto/docker-swarm/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atosatto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-04T16:48:34.000Z","updated_at":"2025-04-25T20:54:58.000Z","dependencies_parsed_at":"2022-09-10T09:12:21.287Z","dependency_job_id":null,"html_url":"https://github.com/atosatto/ansible-dockerswarm","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/atosatto/ansible-dockerswarm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atosatto%2Fansible-dockerswarm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atosatto%2Fansible-dockerswarm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atosatto%2Fansible-dockerswarm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atosatto%2Fansible-dockerswarm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atosatto","download_url":"https://codeload.github.com/atosatto/ansible-dockerswarm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atosatto%2Fansible-dockerswarm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278881830,"owners_count":26062176,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","docker","docker-swarm","molecule","swarm-mode"],"created_at":"2024-08-01T15:01:42.627Z","updated_at":"2025-10-08T02:58:17.880Z","avatar_url":"https://github.com/atosatto.png","language":"Python","funding_links":[],"categories":["Python","molecule"],"sub_categories":[],"readme":"Ansible Role: Docker\n====================\n\n[![Build Status](https://travis-ci.org/atosatto/ansible-dockerswarm.svg?branch=master)](https://travis-ci.org/atosatto/ansible-dockerswarm)\n[![License](https://img.shields.io/badge/license-MIT%20License-brightgreen.svg)](https://opensource.org/licenses/MIT)\n[![Ansible Role](http://img.shields.io/badge/galaxy-atosatto.docker--swarm-blue.svg?style=flat-square)](https://galaxy.ansible.com/atosatto/docker-swarm)\n[![GitHub tag](https://img.shields.io/github/tag/atosatto/ansible-dockerswarm.svg)](https://github.com/atosatto/ansible-dockerswarm/tags)\n\nSetup Docker on RHEL/CentOS and Debian/Ubuntu servers. \u003cbr /\u003e\nThe role supports Docker Engine's \"Swarm Mode\" (https://docs.docker.com/engine/swarm/) to create a cluster of Docker nodes.\n\nRequirements\n------------\n\nAn Ansible 2.7 or higher installation.\nThis role makes use of the Ansible `json_filter` that requires `jmespath` to be installed on the Ansible machine.\nSee the `requirements.txt` file for further details on the specific version of `jmespath` required by the role.\n\nDependencies\n------------\n\nNone.\n\nRole Variables\n--------------\n\nAvailable variables are listed below, along with default values (see `[defaults/main.yml](defaults/main.yml)`):\n\n    docker_repo: \"{{ docker_repo_ce_stable }}\"\n\nThe repository proving the Docker packages.\nAdditional repositories are defined in `[vars/main.yml](vars/main.yml)` including the edge, test and nightly repositories.\nTo skip the configuration of the repository and use the system repositories set `skip_repo: true`.\n\n    docker_package_name: \"docker-ce\"\n\nName of the package providing the Docker daemon.\n\n    docker_package_version: \"\"\n\nVersion of the Docker package to be installed on the target hosts.\nWhen set to `\"\"` the latest available version will be installed.\n\n    docker_package_state: present\n\nSet it to `latest` to force the upgrade of the installed Docker package to the latest version.\n\n    docker_dependencies: \"{{ default_docker_dependencies }}\"\n\nAdditional support packages to be installed alongside Docker by the role.\nSee `[vars/RedHat.yml](vars/RedHat.yml)` and `[vars/Debian.yml](vars/Debian.yml)` for the definition of the `default_docker_dependencies` variable.\n\n    docker_service_override: \"\"\n    # docker_service_override: |\n    # [Service]\n    # ExecStart=\n    # ExecStart=/usr/bin/dockerd\n\nContect written to the systemd unit drop-in overriding\nthe default Docker service definition.\n\n    docker_service_state: \"started\"\n    docker_service_enabled: \"yes\"\n\nState of the Docker service.\n\n    docker_daemon_config: {}\n\nDictionary of Docker deamon configuration options to be written to `/etc/docker/daemon.json`.\nSee [Daemon configuration file](https://docs.docker.com/engine/reference/commandline/dockerd/#daemon-configuration-file) for the detailed documentation of the available options.\n\n    docker_cli_package_name: \"docker-ce-cli\"\n\nName of the package providing the Docker CLI.\n\n    docker_cli_package_version: \"\"\n\nVersion of the Docker CLI package to be installed on the target hosts.\nWhen set to `\"\"` the latest available version will be installed.\n\n    docker_cli_package_state: present\n\nSet it to `latest` to force the upgrade of the installed Docker CLI package to the latest version.\n\n    containerd_package_name: \"containerd.io\"\n\nName of the package providing containerd.\n\n    containerd_package_version: \"\"\n\nVersion of the containerd package to be installed.\nWhen set to `\"\"` the latest available version will be installed.\n\n    containerd_package_state: present\n\nSet it to `latest` to force the upgrade of the installed containerd package to the latest version.\n\n    containerd_service_override: |\n      [Service]\n      ExecStartPre=\n\nContect written to the systemd unit drop-in overriding\nthe default containerd service definition.\n\n    containerd_service_state: \"started\"\n    containerd_service_enabled: \"yes\"\n\nState of the containerd service.\n\n    docker_compose_version: \"\"\n\nVersion of docker-compose to be installed via python-pip.\nWhen set to `\"\"` the latest available version will be installed.\n\n    docker_py_package_name: \"docker\"\n\nName of the python-pip package providing docker-py\n\n    docker_py_package_version: \"\"\n\nVersion of the docker-py package to be installed.\n\n    docker_py_package_state: present\n\nInstallation state of the docker-py package.\nSet it to 'latest' to upgrade the Docker CLI to the latest version.\n\n    docker_group_name: \"docker\"\n    docker_group_users:\n      - \"{{ ansible_user }}\"\n\nName of the Docker group and list of users to be added to `docker_group_name` to manage the Docker daemon.\n**NB**: The users must already exist in the system.\n\n    docker_swarm_interface: \"{{ ansible_default_ipv4['interface'] }}\"\n\nNetwork interface to be used for cluster inter-communication.\n\n    docker_swarm_addr: \"{{ hostvars[inventory_hostname]['ansible_' + docker_swarm_interface]['ipv4']['address'] }}\"\n\nListen address for the Swarm raft API.\nBy default, the ip address of `docker_swarm_interface`.\n\n    docker_swarm_port: 2377\n\nListen port for the Swarm raft API.\n\n    skip_repo: false\n    skip_containerd: false\n    skip_engine: false\n    skip_cli: false\n    skip_swarm: false\n    skip_group: false\n    skip_docker_py: false\n    skip_docker_compose: false\n\nSwitches allowing to disable specific functionalities of the role.\nIf you want to use this role to install `docker-engine` without enabling `swarm-mode` set `skip_swarm: true`.\n\nSwarm node labels\n-----------------\n\n[Node labels](https://docs.docker.com/engine/swarm/manage-nodes/#add-or-remove-label-metadata) provide a\nflexible method of node organization. You can also use node labels in service constraints.\nApply constraints when you create a service to limit the nodes where the scheduler assigns tasks for the service.\nYou can define labels by `swarm_labels` variable, e.g:\n\n    $ cat inventory\n    ...\n    [docker_swarm_manager]\n    swarm-01 swarm_labels=deploy\n\n    [docker_swarm_worker]\n    swarm-02 swarm_labels='[\"libvirt\", \"docker\", \"foo\", \"bar\"]'\n    swarm-03\n    ...\n\nIn this case:\n\n    $ docker inspect --format '{{json .Spec.Labels}}'  swarm-02 | jq\n    {\n       \"bar\": \"true\",\n       \"docker\": \"true\",\n       \"foo\": \"true\",\n       \"libvirt\": \"true\",\n    }\n\nYou can assign labels to cluster running playbook with `--tags=swarm_labels`\n\n**NB**: Please note, all labels that are not defined in inventory will be removed\n\nExample Playbook\n----------------\n\n    $ cat inventory\n    swarm-01 ansible_ssh_host=172.10.10.1\n    swarm-02 ansible_ssh_host=172.10.10.2\n    swarm-03 ansible_ssh_host=172.10.10.3\n\n    [docker_engine]\n    swarm-01\n    swarm-02\n    swarm-03\n\n    [docker_swarm_manager]\n    swarm-01 swarm_labels=deploy\n\n    [docker_swarm_worker]\n    swarm-02 swarm_labels='[\"libvirt\", \"docker\", \"foo\", \"bar\"]'\n    swarm-03\n\n    $ cat playbook.yml\n    - name: \"Provision Docker Swarm Cluster\"\n      hosts: all\n      roles:\n        - { role: atosatto.docker-swarm }\n\nTesting\n-------\n\nTests are performed by [Molecule](http://molecule.readthedocs.org/en/latest/).\n\n    $ pip install tox\n\nTo test all the scenarios run\n\n    $ tox\n\nTo run a custom molecule command\n\n    $ tox -e py36-ansible29 -- molecule test -s swarm-singlenode\n\nLicense\n-------\n\nMIT\n\n## Author Information\n\nAndrea Tosatto ([@\\_hilbert\\_](https://twitter.com/_hilbert_))\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatosatto%2Fansible-dockerswarm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatosatto%2Fansible-dockerswarm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatosatto%2Fansible-dockerswarm/lists"}