digital_ocean_domain - can it really create DNS records?

300 views
Skip to first unread message

Jeff Johnson

unread,
Sep 3, 2014, 4:54:05 PM9/3/14
to ansible...@googlegroups.com
I'm new to Ansible and loving it so far.  But I'm new so maybe I'm missing something obvious when I can't figure out how to make the digital_ocean_domain module create DNS records instead of just zone files.  

The example here, http://docs.ansible.com/digital_ocean_domain_module.html, creates a DigitalOcean droplet (virtual machine), and then creates a DigitalOcean domain record (DNS zone file) with the IP of the newly created droplet.  

What I would really like is to be able to create a DNS A record inside a zone file.

The module code, https://github.com/ansible/ansible/blob/devel/library/cloud/digital_ocean_domain, seems to have some support for records but the documentation doesn't say how to use it and I'm not sure that it can be used as I'm new to Ansible and my attempts to write YAML that passes in records hasn't worked.

Does anyone have experience with this module and can you tell me how to use it?

Thanks!



Michael DeHaan

unread,
Sep 4, 2014, 9:21:43 PM9/4/14
to ansible...@googlegroups.com
Can you share which line from the example is not working for you, and what parameters you are passing to it?

Also, what version of Ansible are you using?


--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/8d5a8282-1ac1-43e5-ab3e-474f7a4db62b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeff Johnson

unread,
Sep 11, 2014, 8:14:32 AM9/11/14
to ansible...@googlegroups.com
Sorry for the delay, I didn't see your response until this morning.  

I have my script below which is taken almost verbatim from http://docs.ansible.com/digital_ocean_domain_module.html.  The first call to digital_ocean_domain creates a zone file for "example-1.com" with NS records and a default A record "@".  Then it creates a droplet, then it calls digital_ocean_domain again to, hopefully, create a A record for the droplet that was just created and in the existing zone file.  What it actually does is create another zone file for "hs2.example-1.com" with NS records and a default A record "@".  So if I create 10 droplets under a domain I would end up with 10 zone files instead of one zone file containing 10 A records as I would expect.

Maybe this was intentional, and I suspect it would work, but it's not the way I would ever setup DNS.  So if it is intentional there should be a big warning in the docs to say so.

Thanks for reading :)

---
- hosts: 127.0.0.1

  tasks:

  - name: "Ensure that the SSH key exists for the account"
    digital_ocean_sshkey:
      state=present
      name=jeff
      ssh_pub_key='*************HIDDEN*************'
    register: my_ssh_key

  - digital_ocean_domain: >
      state=present
      name=example-1.com
      ip=127.0.0.1

  - digital_ocean: >
        state=present
        name=hs2
        size_id=66
        region_id=4
        image_id=5141286
    register: hs2

  - digital_ocean_domain: >
        state=present
        name={{ hs2.droplet.name }}.example-1.com
        ip={{ hs2.droplet.ip_address }}

Matt Martz

unread,
Sep 11, 2014, 8:49:24 AM9/11/14
to ansible...@googlegroups.com
It appears as though others have recognized this limitation and have submitted pull requests for a module that would do what you are looking for:


--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jeff Johnson

unread,
Sep 11, 2014, 10:29:51 AM9/11/14
to ansible...@googlegroups.com
Thanks for the links to the pull requests.  I'm looking forward to those being merged.

I forgot to include my version:

ansible --version                              
ansible 1.7.1
Reply all
Reply to author
Forward
0 new messages