Use Ansible to make AWS AMIs

Hi,

I wanted to let the group know I have added an Ansible provisioner to Aminator, which enables you to use playbooks to make AMIs for AWS.

In the past, I have had custom scripts to do this, but this is much cleaner. To use it:

aminate -b your-foundation-ami playbook.yml

and if you want to pass your playbook extra variables:

aminate -b your-foundation-ami --extra-vars “key1=value1 key2=value2” playbook.yml

By default, aminator will pass a variable to your playbooks called “ami_build” which will always be set to True. You can use this as a flag in case you want to reuse your playbooks on running EC2 instances, as well as building images. For example, when building an AMI, you don’t want to start services like Apache, but on a running system you do. In a handler, you can do something like this:


  • name: restart apache

service: name=apache state=restarted

only_if: ‘not $ami_build’

A more details write up about this can be found here:

http://answersforaws.com/blog/2013/08/ansible-provisioner-for-aminator/

I would love feedback on this, and whether people find it useful.

Thanks,
Peter Sankauskas