I'm building an EC2 instance with Ansible, then creating an AMI from the instance. I'm sure I'm missing something here, but how do I get the ID of the newly created AMI? I've tried:
tasks:
- name: create an ami in us-east-1
ec2_ami: wait=yes
aws_access_key={{ ec2_access_key }}
aws_secret_key={{ ec2_secret_key }}
instance_id={{ item }}
region={{ region1 }}
name=data-mgmt-qa-006
with_items: hostvars[inventory_hostname]['ansible_ec2_instance_id']
register: ec2_ami_info
- debug: var=item
with_items: ec2_ami_info.image_id
and:
tasks:
- name: create an ami in us-east-1
ec2_ami: wait=yes
aws_access_key={{ ec2_access_key }}
aws_secret_key={{ ec2_secret_key }}
instance_id={{ item }}
region={{ region1 }}
name=data-mgmt-qa-006
with_items: hostvars[inventory_hostname]['ansible_ec2_instance_id']
register: instance
- debug: var=item
with_items: instance.image_id
The latter 'register' is copied from the docs, but I'm not able to get the right with_items obviously.
The AMI is being created fine. Any suggestions would be much appreciated.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c0d46c8d-1d93-494c-a016-877f5923fe90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7c9b415a-aaeb-4578-9b99-1535cd97a06d%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6e9af62d-b949-418f-8bba-33be50231dd2%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9a0d1c27-f810-4ea2-b607-965ae06c345f%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/990518f6-3d1e-492d-9d4d-17e6418bda1b%40googlegroups.com.