Create Hosted Zone in Route53

Is it possible to add a domain to route53 from Ansible?

Looks like it’s only possible to add/modify records once you have the zone configured but maybe I’m doing it wrong.

Playbook:

`

  • name: Setup for DNS in AWS
    hosts: 127.0.0.1
    gather_facts: false
    connection: local
    tasks:
  • route53:
    command: create
    zone: “example.com
    record: “new.example.com
    type: A
    value: “xxx.xxx.xxx.xxx”
    overwrite: true

`

Output:

`

ansible-playbook -i local 53.yml -vvvv

PLAY [Setup for DNS in AWS] ***************************************************

TASK: [route53 ] **************************************************************
<127.0.0.1> REMOTE_MODULE route53 type=A command=create record=new.example.com value=xxx.xxx.xxx.xxx zone=example.com
<127.0.0.1> EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1418152704.32-223011961135662 && echo $HOME/.ansible/tmp/ansible-tmp-1418152704.32-223011961135662’]
<127.0.0.1> PUT /tmp/tmpCH8AVM TO /root/.ansible/tmp/ansible-tmp-1418152704.32-223011961135662/route53
<127.0.0.1> EXEC [‘/bin/sh’, ‘-c’, u’LANG=C LC_CTYPE=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1418152704.32-223011961135662/route53; rm -rf /root/.ansible/tmp/ansible-tmp-1418152704.32-223011961135662/ >/dev/null 2>&1’]
failed: [127.0.0.1] => {“failed”: true}

msg: Zone example.com. does not exist in Route53

FATAL: all hosts have already failed – aborting

PLAY RECAP ********************************************************************
to retry, use: --limit @/root/53.retry

127.0.0.1 : ok=0 changed=0 unreachable=0 failed=1

`

Yeah, currently the route53 module does not create zones. They have
to already be created. The boto module (which we're using to interact
with route53 and most other amazon services) appears to support
creating zones so so we'd probably take a pull request to implement
that.

-Toshio

Cool, thanks for the info!