These instructions will allow anyone to deploy a Docker Swarm cluster onto an abitrary number of VMs
-
VMs to provision Swarm cluster have already been provisioned an accessible.
-
Ansible has been installed on the machine which will be used to run the playbook.
-
Ansible module
atosatto.docker-swarm
has been installed from Ansible Galaxyansible-galaxy install atosatto.docker-swarm
Ansible connects to VMs using SFTP or SSH protocol for deployments. So for a one-click and no human intervention deployments to a VM, some setup is required.
- Install Python >3.5.
- For security and audit, a separate user account with proper sudoers rights should be used.
- For one-click deployment, password-less authentication needs to be set up between the machine running Ansible playbook and VMs.
Script bootstrap/setup.sh
, when run on each VM will setup the forementioned requirements.
To bootstrap VMs for each VM, perform following steps:
-
Login to VM as
root
user. -
Copy
bootstrap/setup.sh
to any location on the VM, say/tmp
. -
IMPORTANT: Edit the script
bootstrap/setup.sh
and change thepublicKey
variable so that it has the public key of machine from where ansible playbook will be executed (usually user's laptop/desktop). -
Make the script runnable
chmod u+x /tmp/setup.sh
-
Execute script to boostrap the VM.
-
Prepare the Ansible inventory including all the hosts which will be part of Swarm cluster.
-
Group up the hosts into
docker_swarm_manager
anddocker_swarm_worker
. Number of manager hosts must be 1, 3, 5 or 7. For Swarm's high-availability values >=3 are suggested. -
Run the Ansible playbook
export ANSIBLE_REMOTE_USER=ansible ansible-playbook -i playbook/inventory playbook/deploy-swarm.yml