Hi,

Please do as follows:

# Create AMI
    - name: Create AMI
      local_action:
        module: ec2_ami
        instance_id: "{{ item.id }}"
        wait: yes
        wait_timeout: 3600
        aws_access_key: "{{ AWSAccessKey }}"
        aws_secret_key: "{{ AWSSecretKey }}"
        region: "{{ region }}"
        name: Test
        description: "Test"
        launch_permissions:
          user_ids: ['XXXXXXXXXXXX']
        device_mapping:
          - device_name: /dev/sda1
            size: 50
            volume_type: gp2
      with_items: "{{ ec2.instances }}"
      *register: image*

    
*- name: Print AMI ID      debug: msg="{{ image.results[0].image_id }}"*


*Thanks,*

*Shmulik.*




בתאריך יום שלישי, 25 באפריל 2017 בשעה 08:27:37 UTC+3, מאת sreenivas narayan:
>
> Hello Guys,
>
> I am using a playbook to create ami and trying to fetch the newely created 
> ami id. But the debug is getting 'msg": "AMI not updated"'' Please help
>
>
> -----
> - name: Create ami from the instance
>   local_action:
>     module: ec2_ami
>     aws_access_key: "{{ xxxxxxxxxxxxxx }}"
>     aws_secret_key: "{{ yyyyyyyyyyyyyyyyyyyy }}"
>     instance_id: "{{new_instanceid[0]}}"
>     region: 'us-east-1'
>     wait: yes
>     wait_timeout: 1200
>     name: CCCC
>     tags:
>       Name: newtest
>       Service: TestService
>   register: image
>
> - debug: var=image
>
> - set_fact:
>     us_image_id: "{{ image.image_id }}"
>
> - debug: var=us_image_id
>
>
>
> -------------------------------------------------
> Playbook output
>
>   },
>     "launch_permissions": {},
>     "msg": "AMI not updated"
>
>
> -------------------------------------------
>
> TASK [create-ami : debug] 
> ***********************************************************************************************************
> task path: create-ami/tasks/create.yaml:16
> ok: [127.0.0.1] => {
>     "changed": false,
>     "image": {
>         "changed": false,
>         "launch_permissions": {},
>         "msg": "AMI not updated"
>     }
> }
>
> TASK [create-ami : set_fact] 
> ********************************************************************************************************
> task path: create.yaml:18
> fatal: [127.0.0.1]: FAILED! => {
>     "failed": true,
>     "msg": "the field 'args' has an invalid value, which appears to 
> include a variable that is undefined. The error was: 'dict object' has no 
> attribute 'image_id'\n\nThe error appears to have been in 
> 'create-ami/tasks/create.yaml': line 18, column 3, but may\nbe elsewhere in 
> the file depending on the exact syntax problem.\n\nThe offending line 
> appears to be:\n\n\n- set_fact:\n  ^ here\n"
> }
>
>
>
>
> Thanks
> Sreenivas
>
>
>

-- 
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/f9f9566d-fa7a-4091-aa52-7588aeffc4a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to