pass variable from ec2_eip to route53

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 :slight_smile:

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

Any advice is much appreciated.

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!

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'