Greetings everyone!
For a given reason, I need to handle some Route53 records for my EC2’s EIPs.
The instances are part of the [all] group in my hosts file.
Obviously, the ‘setup’ module is not aware of EIPs. But the ec2_facts module is.
Right now, I’m trying to wrap my head around this design, although there will soon be a VPN tunnel that’s gonna simply render Ansible to interact with a Bind server, thus making this whole playbook obsolete, but nevertheless, something nice to have around.
I know I could probably achieve what I want with an external inventory tool like ec2.py but I want to see first if I can do it the “normal” way.
I only need to touch one zone in Route53, essentially by creating/updating an A record like so:
`
- name: updating Route53 records
hosts: localhost
connection: local
gather_facts: False
tasks:
if we have the records, replace them if they do not match. if we don’t have them, just create them.
-
local_action: route53 command=create zone=domain.com record={{ ??ansible_hostname?? }}.zone.com type=A value={{ ??item.ansible_ec2_public_ipv4?? }} overwrite=yes ttl=300
with_items: facts
register: dnsrec_update -
name: showing the results of the create task
debug: var=dnsrec_update
`
The above would be included by the following:
`