# Use Ansible to make AWS AMIs

**URL:** <https://forum.ansible.com/t/use-ansible-to-make-aws-amis/13306>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [August 14, 2013, 4:28pm UTC](https://forum.ansible.com/t/use-ansible-to-make-aws-amis/13306 "2013-08-14T16:28:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Sankauskas](https://avatars.discourse-cdn.com/v4/letter/p/ea666f/32.png) [@Peter\_Sankauskas](https://forum.ansible.com/u/Peter_Sankauskas)\
**Post date:** [August 14, 2013, 4:28pm UTC](https://forum.ansible.com/t/use-ansible-to-make-aws-amis/13306/1 "2013-08-14T16:28:25Z")

</div>

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/](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
