Thank you very much, that did it. 

On Friday, September 12, 2014 4:04:53 PM UTC-4, Michael DeHaan wrote:
>
> In that case, looks like you want:
>
> instance.results[0].image_id
>
>
>
> On Fri, Sep 12, 2014 at 3:54 PM, Peter Palmieri <[email protected] 
> <javascript:>> wrote:
>
>> That shows:
>>
>> TASK: [debug var=instance] 
>> **************************************************** 
>> ok: [54.90.128.104] => {
>>     "instance": {
>>         "changed": true, 
>>         "msg": "All items completed", 
>>         "results": [
>>             {
>>                 "changed": true, 
>>                 "image_id": "ami-be14b9d6", 
>>                 "invocation": {
>>                     "module_args": "wait=yes aws_access_key=**** 
>> aws_secret_key=**** instance_id=i-393284d2 region=us-east-1 name=blah", 
>>                     "module_name": "ec2_ami"
>>                 }, 
>>                 "item": "i-393284d2", 
>>                 "msg": "AMI creation operation complete", 
>>                 "state": "available"
>>             }
>>         ]
>>     }
>> }
>>
>> On Friday, September 12, 2014 3:22:44 PM UTC-4, Michael DeHaan wrote:
>>>
>>> Can you please share the output of:
>>>
>>> - debug: var=instance
>>>
>>> Thanks!
>>>
>>>
>>>
>>> On Fri, Sep 12, 2014 at 2:43 PM, Peter Palmieri <[email protected]> 
>>> wrote:
>>>
>>>> Thanks for helping, it's much appreciated. 
>>>>
>>>> I now have:
>>>>
>>>>   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=some-name
>>>>       with_items: hostvars[inventory_hostname]['
>>>> ansible_ec2_instance_id']
>>>>       register: instance
>>>>
>>>>     - debug: var=instance.image_id
>>>>
>>>> Which returns:
>>>>
>>>> TASK: [create an ami in us-east-1] ******************************
>>>> ************** 
>>>> changed: [54.198.217.217] => (item=i-7c77c197)
>>>>
>>>> TASK: [debug var=instance.image_id] ******************************
>>>> ************* 
>>>> ok: [54.198.217.217] => {
>>>>     "instance.image_id": "{{ instance.image_id }}"
>>>> }
>>>>
>>>> instead of the actual image id. 
>>>>
>>>> On Thursday, September 11, 2014 9:52:52 PM UTC-4, James Cammarata wrote:
>>>>>
>>>>> You should be able to just do:
>>>>>
>>>>> - debug: var=instance.image_id
>>>>>
>>>>> Which should print out the image's ID. If not, could you share what it 
>>>>> does show?
>>>>>
>>>>> On Thu, Sep 11, 2014 at 2:00 PM, Peter Palmieri <[email protected]
>>>>> > wrote:
>>>>>
>>>>>> 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. 
>>>>>>   <http://stackoverflow.com/questions/tagged/amazon-web-services>
>>>>>>
>>>>>> -- 
>>>>>> 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 [email protected].
>>>>>> To post to this group, send email to [email protected].
>>>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>>>> msgid/ansible-project/c0d46c8d-1d93-494c-a016-877f5923fe90%
>>>>>> 40googlegroups.com 
>>>>>> <https://groups.google.com/d/msgid/ansible-project/c0d46c8d-1d93-494c-a016-877f5923fe90%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>  -- 
>>>> 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 [email protected].
>>>> To post to this group, send email to [email protected].
>>>> To view this discussion on the web visit https://groups.google.com/d/
>>>> msgid/ansible-project/7c9b415a-aaeb-4578-9b99-
>>>> 1535cd97a06d%40googlegroups.com 
>>>> <https://groups.google.com/d/msgid/ansible-project/7c9b415a-aaeb-4578-9b99-1535cd97a06d%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  -- 
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/6e9af62d-b949-418f-8bba-33be50231dd2%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/6e9af62d-b949-418f-8bba-33be50231dd2%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8e7541e8-668a-4076-bdfa-5f4d5c31736e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to