Last active
August 29, 2015 14:23
-
-
Save suz-lab/9364620e6bd3634a9a9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: localhost | |
gather_facts: no | |
connection: local | |
tasks: | |
- name: cloudformation | |
cloudformation: | |
state: present | |
region: "{{ Region }}" | |
template: ../../cloudformation/packer.json | |
stack_name: Packer | |
register: cloudformation | |
- name: epoch | |
shell: date +%s | |
register: epoch | |
- name: get amazonlinux ami | |
shell: > | |
aws ec2 describe-images | |
--region {{ Region }} | |
--owners amazon | |
--filters "Name=name,Values=amzn-ami-hvm-*-gp2" | |
--query 'reverse(sort_by(Images,&CreationDate))[0].ImageId' | |
--output text | |
register: amazonlinux_image_id | |
- name: packer | |
shell: > | |
packer build | |
-var 'Region={{ Region }}' | |
-var 'VpcId={{ cloudformation.stack_outputs.Vpc }}' | |
-var 'SubnetId={{ cloudformation.stack_outputs.Subnet }}' | |
-var 'Name={{ Name }}' | |
-var 'Epoch={{ epoch.stdout }}' | |
-var 'SourceAmi={{ amazonlinux_image_id.stdout }}' | |
../../packer/ansible-amazonlinux.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment