Using Ansible for a number of machines, using pull architecture.
The goal here is to be able to launch a number of instance by pulling ansible playbooks.
The file user-data-ansible-pull contains:
Assuming you setup your AWS EC2 or euca-tools:
prompt$ ec2-run-instances ami-a29943cb -t t1.micro \
-k gsg-keypair -f ~/Desktop/user-data-ansible-pull
How it works?
1. Run the instance and use the user-data.
2. user-data will be executed by cloud-init and will install needed packages for ansible.
3. Install ansible via git clone
4. Setup ansible hosts variable.
5. Run ansible-pull, set parameter to a git playbook repository to clone.
6. From playbook, ansible-pull reads the local.yml whic defines the tasks to be executed.
(On the Ansible docs, it features another trick to setup a cronjob fetch for new playbooks.
See ansible examples on github. )
Simple eh? Let’s start writing more playbooks, includes these at local.yml.
Fire away your new Openstack and EC2 instances.