Hi All,
I cannot figure out how to reference the zone id attribute from the
registered variable of the below AWS CLI.
For some reason it doesn't work.
Playbook:
___________________________
- name: List hosted zone
command: aws route53 list-hosted-zones --max-items 1 --query
'HostedZones[?Name==`"{{ zone_name }}"`]' --output json
register: hosted_zone_list_res
- name: Get hosted zone details
set_fact: hosted_zone="{{ hosted_zone_list_res.stdout | from_json }}"
- debug: var=hosted_zone
- name: Get hosted zone ID
set_fact: zone_id="{{ hosted_zone[0].Id }}"
___________________________
Here is the output:
___________________________
TASK: [route53_zone | Get hosted zone details]
********************************
ok: [127.0.0.1] => {"ansible_facts": {"hosted_zone": "[{u'Config':
{u'Comment': u'Test public zone', u'PrivateZone': False},
u'CallerReference': u'20151115-095525', u'ResourceRecordSetCount': 2,
u'Id': u'/hostedzone/Z2VTI3W5U16LCK', u'Name': u'aws.company.com.'}]"}}
TASK: [route53_zone | debug var=hosted_zone]
**********************************
ok: [127.0.0.1] => {
"var": {
"hosted_zone": [
{
"CallerReference": "20151115-095525",
"Config": {
"Comment": "Test public zone",
"PrivateZone": false
},
"Id": "/hostedzone/Z2VTI3W5U16LCK",
"Name": "aws.company.com.",
"ResourceRecordSetCount": 2
}
]
}
}
TASK: [route53_zone | Get hosted zone ID]
*************************************
fatal: [127.0.0.1] => One or more undefined variables: 'unicode object' has
no attribute 'Id'
FATAL: all hosts have already failed -- aborting
___________________________
Could you please advise what I'm doing wrong?
Regards,
Costea
--
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/d9122654-1552-412d-9988-92753a502699%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.