This article is a follow-up to Vedant Sethia’s article about “Automating DNS Traffic Control with Ansible and Infoblox NIOS.” In this article, I took the individual examples and turned each playbook into an Ansible Task that you can run from the main playbook to create or remove DTC objects. Also, I explain how to use variables in a file, so a user just needs to edit “data.yml,” and it will automatically build the DTC Server(s), the DTC Pool, and the DTC LBDN.
- Ansible – the latest version
- Infoblox Ansible Collection
- For installation/setup, refer to the GitHub repository or ansible-galaxy collection.
- The collection of Playbooks and Task – github.com/seefor
DTC Server Task
Here we are going to take a look at “task_dtc_server.yml.”
As you can see above, I made “name,” “host,” and “comment” variables, and that will read the values from the “data.yml” file. With Ansible, when you use “item,” it’s reading a list of variables from a YAML file.
DTC Pool Task and Jinja2 Template
To create the “Pool,” we have to leverage Jinja2 Templates. For example, here is the Jinja2 template “temp_pool.j2.”
We are reading “name” for the pool and “servers” from the data.yml file. When you run the “create_everything.yml,” it will create a new playbook called “c_pool.yml” that looks like this.
Then execute the “c_pool.yml” for “Pool” creation; now we have the Servers and Pool time for the LBDN creation.
DTC LBDN Task
Now let’s wrap this all up with the last Task, “task_dtc_lbdn.yml.”
The above will create the “LBDN,” and again, we are reading the “name,” “pool,” “auth_zones,” and “patterns” from the data.yml file.
Here is the “data.yml” layout
As you can see, this is where we get all the data points that we used above in each “task” file.
Let’s see how we call the “data.yml” and all the “tasks” from one playbook called “create_everything.yml.”
Let’s Create Everything
We are going to look at the file “create_everything.yml.”
The first thing to notice is that we use “vars_files” to read the “data.yml” file into the playbook. Next, we have “included_tasks” under “tasks” that will run each instance of the “task” files for us. For example, in line 11, we will create “c_pool.yml” from a “template.” The last “task” I did not cover in this article is “restart_serverices.yml,” which is self-explanatory.
We are leveraging Ansible Task and Infoblox DNS Traffic Control to speed up the deployment of new APPs.