You must install Ansible
on the control machine, preferably in a virtual Python environment:
virtualenv pyenv
. pyenv/bin/activate
pip install ansible==2.2 netaddr
Place your PEM-formatted private key under secrets/id_rsa
. Ensure the key file has proper permissions (0600
).
An single inventory file should be created at hosts.yml
. Both vagrant
and ansible
will use this same inventory.
An example inventory file can be found here.
If we want a full Vagrant environment (of course we will also need vagrant
installed), then:
vagrant up
In this case, vagrant
will provide the virtual machines (via virtualbox), will setup the private network,
and then will delegate to an ansible
playbook to actually setup the swarm nodes.
If the target machines (either virtual or physical) are already setup and networked (usually in a private network), then we can directly play the Ansible playbook:
# Prepare target hosts
ansible -m script -a install-ansible-prereqs.sh all
# Play
ansible-playbook play.yml