This repository is to be used for playing with and creating Ansible Playbooks.
Vagrant is used on the localhost, but is wrapped in a bash script abstraction layer to automatically create the inventory files and modify the ansible.cfg as necessary.
- ./initlocal.sh
- Create the Vagrant Machines requested
- Provision the Machine with the default playbook ./ansible/playbooks/initServer.yml
- Create an inventory file ./ansible/inventories/vagrant/hosts
The vagrantfile requires unique and count to be passed as environment variables.
$ ./initlocal.sh vm 2
$ unique=vm count=2 vagrant ssh vm2
The init scripts automatically create the necessary ansible.cfg and inventory files. Test the connectivity to the servers that were created.
ansible all -m ping
$ ansible-playbook ansible/<playbookname>.yml
Playbook swarmCluster installs docker and can configure servers into a swarm.
To configure a swarm you must modify the inventory file and tag the servers as manager or worker.
[manager]
vm1
vm2
vm3
[worker]
vm4
vm5
vm6
NOTE: To configure a swarm on vagrant you must set the swarm interface variable to enp0s3 in vagrant/group_vars. swarm_iface: 'enp0s8'
$ vagrant ssh
$ vagrant destroy
Init Script will create a simple Azure Virtual Machine with up to date patches and ready for ansible commands.
$ ./init.sh <unique>
$ INVENTORY_FILE="ansible/hosts/azure"
$ ansible-playbook -i ${INVENTORY_FILE} ansible/<playbookname>.yml
$ ./connect.sh <unique>
$ ./clean.sh <unique>
$ ./init.sh <unique> 6
$ ansible-playbook ./ansible/playbooks/swarmCluster.yml
$ vboxwebsrv -H 0.0.0.0 -v >/dev/null 2>&1 &
$ ansible-playbook ./ansible/playbooks/storageVagrant.yml
# When done bring back the task and kill it
$ fg
$ ansible jumpserver -m setup | sed 's/.*|.*=>.*/{/g' |jq .ansible_facts.ansible_env
$ VBoxManage setproperty websrvauthlibrary null
$ vboxwebsrv -H 0.0.0.0 -v