{"id":15676968,"url":"https://github.com/jtyr/ansible-docker_swarm","last_synced_at":"2025-05-07T00:41:42.307Z","repository":{"id":69603045,"uuid":"146036475","full_name":"jtyr/ansible-docker_swarm","owner":"jtyr","description":"Ansible role which installs and configures Docker Swarm cluster.","archived":false,"fork":false,"pushed_at":"2019-12-18T18:04:21.000Z","size":9,"stargazers_count":14,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T04:37:44.542Z","etag":null,"topics":["ansible","ansible-role","docker","docker-swarm"],"latest_commit_sha":null,"homepage":"","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/jtyr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-08-24T20:23:46.000Z","updated_at":"2025-01-15T16:30:13.000Z","dependencies_parsed_at":"2023-02-23T13:00:16.380Z","dependency_job_id":null,"html_url":"https://github.com/jtyr/ansible-docker_swarm","commit_stats":{"total_commits":3,"total_committers":3,"mean_commits":1.0,"dds":0.6666666666666667,"last_synced_commit":"d5335160e3b00a1c70d2146a141403bfd2dc4665"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fansible-docker_swarm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fansible-docker_swarm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fansible-docker_swarm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyr%2Fansible-docker_swarm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jtyr","download_url":"https://codeload.github.com/jtyr/ansible-docker_swarm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252793546,"owners_count":21805053,"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","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","ansible-role","docker","docker-swarm"],"created_at":"2024-10-03T16:07:47.646Z","updated_at":"2025-05-07T00:41:42.299Z","avatar_url":"https://github.com/jtyr.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"docker_swarm\n============\n\nAnsible role which helps to install and configure Docker Swarm cluster.\n\nSupported actions:\n - Cluster initiation\n - Adding nodes\n - Rebuilding nodes\n - Removing nodes\n - Promoting/demoting nodes\n - Setting node's labels\n - Setting node's availability\n\nThe configuration of the role is done in such way that it should not be\nnecessary to change the role for any kind of configuration. All can be\ndone either by changing role parameters or by declaring completely new\nconfiguration as a variable. That makes this role absolutely\nuniversal. See the examples below for more details.\n\nPlease report any issues or send PR.\n\n\nExamples\n--------\n\nRole of the node (manager/worker) is controlled by presence of the nodes in the\nparticular Ansible inventory group. Examples bellow assume the following\ninventory:\n\n```ini\n[swarm:children]\nmanagers\nworkers\n\n[managers]\nswarm01\nswarm03\nswarm05\n\n[workers]\nswarm02\nswarm04\n```\n\nThe group names can be controled by setting the `docker_swarm_group*` variables.\n\n\n```yaml\n---\n\n- name: Example of how to initiate the cluster\n  hosts: swarm\n  roles:\n    - role: docker\n      tags: docker\n    - role: docker_swarm\n      tags: docker_swarm\n      # Skip all docker_swarm tasks if we are not deploying to all Swarm cluster nodes\n      when: \u003e\n        groups[docker_swarm_group] | difference(ansible_play_batch) | length == 0\n\n- name: Example of how to set global labels (labels on all nodes)\n  hosts: swarm\n  vars:\n    docker_swarm_node_labels:\n      # Sets label cluster=test_cluster to all nodes\n      cluster: test_cluster\n  roles:\n    - role: docker\n      tags: docker\n    - role: docker_swarm\n      tags: docker_swarm\n      # Skip all docker_swarm tasks if we are not deploying to all Swarm cluster nodes\n      when: \u003e\n        groups[docker_swarm_group] | difference(ansible_play_batch) | length == 0\n\n- name: Example of how configure individual nodes\n  hosts: swarm\n  vars:\n    docker_swarm_nodes:\n      swarm01:\n        labels:\n          # Sets additional label app=test\n          app: test\n        # Do not run any tasks on this node\n        availability: drain\n      swarm03:\n        # Use eth1 to communicate with the cluster\n        iface: eth1\n      swarm05:\n        # Remove the node swarm05 from the cluster\n        # (the node can be removed from the inventory after the change was applied)\n        state: absent\n  roles:\n    - role: docker\n      tags: docker\n    - role: docker_swarm\n      tags: docker_swarm\n      # Skip all docker_swarm tasks if we are not deploying to all Swarm cluster nodes\n      when: \u003e\n        groups[docker_swarm_group] | difference(ansible_play_batch) | length == 0\n```\n\nNew node can be added into the cluster by simply adding it into the inventory.\nNode can be rebuild by destroying the node and running the role again on all\ncluster. Promote/demote node to master/worker is simply done by moving the\nnode between the inventory groups. \n\n\nRole variables\n--------------\n\nVariables used by the role:\n\n```yaml\n# Group name for all nodes in the cluster (managers + workers)\ndocker_swarm_group: swarm\n\n# Group name for manager nodes\ndocker_swarm_group_managers: managers\n\n# Group name for worker nodes\ndocker_swarm_group_workers: workers\n\n# Default node network interface through which the nodes in the cluster communicate\ndocker_swarm_node_iface: eth0\n\n# Default node availability mode\ndocker_swarm_node_availability: active\n\n# Default node labels\ndocker_swarm_node_labels: {}\n\n# List of cluster nodes and their attributes (see examples in the README for details)\ndocker_swarm_nodes: {}\n```\n\n\nLimitations\n-----------\n\n- Node hostnames must be unique.\n- Always run the play on all nodes of the cluster (all nodes of the group\n  defined by the `docker_swarm_group` variable).\n- It's not possible to demote all masters and promote all workers. There must\n  always stay at least one master which doesn't change the role.\n- Variable `docker_swarm_nodes` must be uniform across all nodes.\n\n\nDependencies\n------------\n\n- [`docker`](https://github.com/jtyr/ansible-docker) (optional)\n\n\nLicense\n-------\n\nMIT\n\n\nAuthor\n------\n\nJiri Tyr\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtyr%2Fansible-docker_swarm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjtyr%2Fansible-docker_swarm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtyr%2Fansible-docker_swarm/lists"}