# pass variable from ec2\_eip to route53

**URL:** <https://forum.ansible.com/t/pass-variable-from-ec2-eip-to-route53/15505>\
**Category:** Ansible Project\
**Created:** [June 19, 2014, 4:13pm UTC](https://forum.ansible.com/t/pass-variable-from-ec2-eip-to-route53/15505 "2014-06-19T16:13:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [June 19, 2014, 4:13pm UTC](https://forum.ansible.com/t/pass-variable-from-ec2-eip-to-route53/15505/1 "2014-06-19T16:13:26Z")

</div>

Hello everyone!

Since the ‘include’ doesn’t work anymore with ‘with\_items’, I am trying to do the following:

`  
…

- name: add EIP to the instance  
local\_action: ec2\_eip in\_vpc=yes instance\_id={{ item.id }} region={{ region }}  
with\_items: ec2.instances  
register: eip

- name: output the IP  
debug: msg= “Allocated IP inside the VPC is {{ item.public\_ip }}”  
with\_items: eip.results

- name: Update Route53  
include: route53.yml EIP={{ eip.WhatToPutHere? }}  
#with\_items: eip.results \< this is now deprecated  
…

`

Here goes my route53.yml

`

- name: if we have the records, replace them if they do not match. if we dont have them, just create them.  
local\_action: route53 command=create zone={{ item.zone }} record={{ item.record }} type=A value={{ EIP }} overwrite=yes ttl=300  
with\_items:
- { record: ‘{{ comhost }}’, zone: ‘{{ zonecom }}’ }
- { record: ‘{{ athost }}’, zone: ‘{{ zoneat }}’ }
- { record: ‘{{ chhost }}’, zone: ‘{{ zonech }}’ }
- { record: ‘{{ ukhost }}’, zone: ‘{{ zoneuk }}’ }
- { record: ‘{{ frhost }}’, zone: ‘{{ zonefr }}’ }
- { record: ‘{{ ithost }}’, zone: ‘{{ zoneit }}’ }
- { record: ‘{{ sehost }}’, zone: ‘{{ zonese }}’ }  
register: dnsrec\_create

`

Everywhere I look, everyone says “just go for those so many easy ways” to achieve the same thing without the with\_items… but after almost a full day of writing playbooks, I might be missing the obvious here 🙂

I’d like to keep the route53.yml separate from my main playbook.

Any advice is much appreciated.

---

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [June 19, 2014, 4:29pm UTC](https://forum.ansible.com/t/pass-variable-from-ec2-eip-to-route53/15505/2 "2014-06-19T16:29:17Z")

</div>

Could it be something as easy as (route53.yml)

`  
…

- name: getting & showing all records matchig our stores  
local\_action: route53 command=get zone={{ item.zone }} record={{ item.record }} type=A value={{ elasticip.public\_ip }}  
with\_items:
- { record: ‘{{ comhost }}’, zone: ‘{{ zonecom }}’`, elasticip: '{{ eip.results }}'` }
- { record: ‘{{ athost }}’, zone: ‘{{ zoneat }}’`, elasticip: '{{ eip.results }}'` }
- { record: ‘{{ chhost }}’, zone: ‘{{ zonech }}’`, elasticip: '{{ eip.results }}'` }
- { record: ‘{{ ukhost }}’, zone: ‘{{ zoneuk }}’`, elasticip: '{{ eip.results }}'` }
- { record: ‘{{ frhost }}’, zone: ‘{{ zonefr }}’`, elasticip: '{{ eip.results }}'` }
- { record: ‘{{ ithost }}’, zone: ‘{{ zoneit }}’`, elasticip: '{{ eip.results }}'` }
- { record: ‘{{ sehost }}’, zone: ‘{{ zonese }}’`, elasticip: '{{ eip.results }}'` }
- { record: ‘{{ sehost }}’, zone: ‘{{ zonese }}’, elasticip: ‘{{ eip.results }}’ }  
register: dnsrec\_get  
…

`

Just exploring potential solutions…

Thanks!

---

<div class="post-metadata">

**Author:** ![vaida.dan](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vaida.dan](https://forum.ansible.com/u/vaida.dan)\
**Post date:** [June 23, 2014, 8:45am UTC](https://forum.ansible.com/t/pass-variable-from-ec2-eip-to-route53/15505/3 "2014-06-23T08:45:23Z")

</div>

I have just tried this:

`

- name: getting & showing all records matchig our stores  
local\_action: route53 command=get zone={{ item.zone }} record={{ item.record }} type=A value={{ item.elasticip.public\_ip }}  
with\_items:
- { record: ‘{{ comhost }}’, zone: ‘{{ zonecom }}’, elasticip: ‘{{ eip.results }}’ }
- { record: ‘{{ athost }}’, zone: ‘{{ zoneat }}’, elasticip: ‘{{ eip.results }}’ }
- { record: ‘{{ chhost }}’, zone: ‘{{ zonech }}’, elasticip: ‘{{ eip.results }}’ }
- { record: ‘{{ ukhost }}’, zone: ‘{{ zoneuk }}’, elasticip: ‘{{ eip.results }}’ }
- { record: ‘{{ frhost }}’, zone: ‘{{ zonefr }}’, elasticip: ‘{{ eip.results }}’ }
- { record: ‘{{ ithost }}’, zone: ‘{{ zoneit }}’, elasticip: ‘{{ eip.results }}’ }
- { record: ‘{{ sehost }}’, zone: ‘{{ zonese }}’, elasticip: ‘{{ eip.results }}’ }  
register: dnsrec\_get  
`

and got

`TASK: [getting & showing all records matchig our stores] ********************** fatal: [localhost] => One or more undefined variables: 'list object' has no attribute 'public_ip'`
