# Best way to manage DNS via ansible.

**URL:** <https://forum.ansible.com/t/best-way-to-manage-dns-via-ansible/17047>\
**Category:** Ansible Project\
**Created:** [December 14, 2014, 7:13am UTC](https://forum.ansible.com/t/best-way-to-manage-dns-via-ansible/17047 "2014-12-14T07:13:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Burton](https://avatars.discourse-cdn.com/v4/letter/k/dec6dc/32.png) [@Kevin\_Burton](https://forum.ansible.com/u/Kevin_Burton)\
**Post date:** [December 14, 2014, 7:13am UTC](https://forum.ansible.com/t/best-way-to-manage-dns-via-ansible/17047/1 "2014-12-14T07:13:22Z")

</div>

Since we have all of our cluster in Ansible I want to also manage our DNS this way too.

What I was thinking of is having a playbook that runs before all of our other playbooks.

One issue though is that I’d like a module that does forward and reverse DNS with one pass.

I haven’t found any that can do it… the dnsimple module looks nice but it can’t do forward and reverse DNS.

---

<div class="post-metadata">

**Author:** ![Kevin\_Burton](https://avatars.discourse-cdn.com/v4/letter/k/dec6dc/32.png) [@Kevin\_Burton](https://forum.ansible.com/u/Kevin_Burton)\
**Post date:** [December 14, 2014, 7:14am UTC](https://forum.ansible.com/t/best-way-to-manage-dns-via-ansible/17047/2 "2014-12-14T07:14:43Z")

</div>

you know, I guess I could use loops:

[http://docs.ansible.com/playbooks\_loops.html#standard-loops](http://docs.ansible.com/playbooks_loops.html#standard-loops)

and define a map from host → IP and then have one loop do the forward DNS and another do the reverse.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [December 15, 2014, 11:57am UTC](https://forum.ansible.com/t/best-way-to-manage-dns-via-ansible/17047/3 "2014-12-15T11:57:25Z")

</div>

Cobbler templated BIND and dnsmasq back in the day without too much difficulty - you could do this with host variables and a single template call, where each host has both a variable for it’s IP (or just uses the fact) and has another variable “hostname”.

Shouldn’t need to loop much in the playbook itself at all, just the template.

dnsmasq is obviously easier to configure if it’s sufficient.
