{"id":19702179,"url":"https://github.com/dipsas/dockerswarmansible","last_synced_at":"2026-06-07T22:34:13.507Z","repository":{"id":90879838,"uuid":"276604753","full_name":"DIPSAS/DockerSwarmAnsible","owner":"DIPSAS","description":"Ansible playbook and roles for setting up docker swarm on Linux","archived":false,"fork":false,"pushed_at":"2020-07-02T09:35:15.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-27T16:18:40.064Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DIPSAS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-02T09:29:03.000Z","updated_at":"2020-07-02T09:35:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"65b2ac41-1d9f-4b90-ab62-cd6eea624f44","html_url":"https://github.com/DIPSAS/DockerSwarmAnsible","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/DIPSAS/DockerSwarmAnsible","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIPSAS%2FDockerSwarmAnsible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIPSAS%2FDockerSwarmAnsible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIPSAS%2FDockerSwarmAnsible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIPSAS%2FDockerSwarmAnsible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DIPSAS","download_url":"https://codeload.github.com/DIPSAS/DockerSwarmAnsible/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIPSAS%2FDockerSwarmAnsible/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34041087,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"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":[],"created_at":"2024-11-11T21:13:47.745Z","updated_at":"2026-06-07T22:34:13.501Z","avatar_url":"https://github.com/DIPSAS.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Set up Docker Swarm with Ansible\r\n===\r\n\r\n## Set up new Linux Machines\r\n\r\nIf you want a worker node running on a separate machine, you need to create at least two linux machines, one manager and one worker. Docker advises using static IP addresses for manager nodes to prevent the swarm from becoming unstable on manager reboot.\r\n\r\nYou must create and copy over SSH keys for your controller machine to the target machine(s) before you can run the playbook.\r\n\r\n````\r\nssh-keygen -t rsa\r\n# hit enter until the promt returns. Setting a password is optional, see below for how to handle this.\r\n````\r\nWhen the keygen is complete, transfer them to the target server(s) with the following command:\r\n\r\n````\r\n# ssh-copy-id user@hostname_or_ip\r\nssh-copy-id root@your-hostname\r\n````\r\nWhen the copy is complete, try connecting via SSH:\r\n\r\n````\r\n# ssh user@hostname_or_ip\r\nssh root@your-hostname\r\n````\r\nIf the keys are in place you should not be promted to input login information.\r\nTo avoid getting the message about trusting the Linux machine you want to SSH into or run a playbooks against, run `export ANSIBLE_HOST_KEY_CHECKING=False`.\r\n\r\n\r\n## Update `.inventory` file\r\n\r\nWhen that is done, edit the `.inventory` file for the environment and add two host-groups for linuxDockerSwarmManager and linuxDockerSwarmWorker. If you have multiple swarms in the same inventory, you need to distinguish them using the variable swarm_name to indicate which workers and managers belong together. If you want the manager and worker on a single machine, place it only in the host group linuxDockerSwarmManager. By default, all managers are also workers:\r\n\r\n```yaml\r\n[linuxDockerSwarmManager]\r\nmanager01.domain.local swarm_name=test\r\nmanager02.domain.local swarm_name=test\r\nmanager03.domain.local swarm_name=qa\r\n\r\n[linuxDockerSwarmWorker]\r\nworker01.domain.local swarm_name=test\r\nworker02.domain.local swarm_name=test\r\nworker03.domain.local swarm_name=qa\r\n```\r\n\r\n## Run the playbook\r\n\r\nRun the playbook:\r\n\r\n```\r\nansible-playbook LinuxDockerSwarm.yaml -i inventory/environment.inventory\r\n```\r\nYou can use `--list-hosts` to do a dry-run and see which hosts will be affected.\r\nThis playbook will set up docker and docker swarm with the manager and worker nodes you have indicated in your inventory file. To verify that the setup works as intended, log in to your server and check the status of the docker nodes:\r\n\r\n```\r\nssh root@your-manager-server\r\ndocker node ls\r\n```\r\n\r\n\r\n## Known limitations\r\n\r\n* This playbook currently only works with Linux\r\n* This playbook does not detect that a machine has been removed from the linuxDockerSwarmManager or linuxDockerSwarmWorker host groups. If you want to remove a node from the swarm, you must do so manually.\r\n* Docker advises using static IP addresses for manager nodes to prevent the swarm from becoming unstable on manager reboot\r\n* Note that Docker/Linux/templates/daemon.json.j2 contains default log rotation settings for the docker daemon. Modify this file according to your requirements.\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdipsas%2Fdockerswarmansible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdipsas%2Fdockerswarmansible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdipsas%2Fdockerswarmansible/lists"}