On 23.03.2017 05:17, Bhavin Parmar wrote:
*Same way another looping issue is as follow (actual code):*
- name: "Task 2: Fetch EC2 details"
ec2_remote_facts:
aws_access_key: '{{ AwsAccesskey }}'
aws_secret_key: '{{ AwsSecretkey }}'
region: '{{ region }}'
filters:
instance_id: '{{ item }}'
register: ec2_hosts
with_items: "{{ awsec2id }}"
- debug: var=ec2_hosts
- debug: var=ec2_hosts.results[0].instances[0].private_ip_address
- debug: var=ec2_hosts.results[1].instances[0].private_ip_address
*with_items: Looping for the above:*
- name: looping
shell: 'printf "{{ item.instance[0].private_ip_address }}"'
with_items: "{{ ec2_hosts.results }}"
*Error:*
TASK [awsAtachEBSvolume : looping]
*************************************************************************************************************************************
fatal: [localhost]: 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
'instance'\n\nThe
error appears to have been in
'/home/ansible/playbooks/roles/awsAtachEBSvolume/tasks/main.yml': line
30,
column 5, but may\nbe elsewhere in the file depending on the exact
syntax
problem.\n\nThe offending line appears to be:\n\n - debug:
var=awsec2id\n
- name: looping\n ^ here\n"}
to retry, use: --limit @/home/ansible/playbooks/rol.retry
The error messages says "dict object' has no attribute 'instance'"
If you check the output of ec2_hosts you will see it's called
instances and not instance (missing a "s" at the end)
--
Kai Stian Olstad
--
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/dfaf26f6c5308cdb1d9059606c5deaf4%40olstad.com.
For more options, visit https://groups.google.com/d/optout.