Good day all!
I’ve created a playbook to do some DNS work. There are basically two plays - one changes the zone’s serial number, and the other adds TXT records. I get the zone files from a variables file in var_files (zones.yml). The first play works fine.
As to the second play, I’ve created another variables file that includes the TXT records, but I’m not quite sure how to set it up. Here are the two variables files:
zones -
zone_files:
- /var/named/chroot/var/named/trioboiler.com.hosts
- /var/named/chroot/var/named/trioboiler2.com.hosts
certs -
certs:
/var/named/chroot/var/named/trioboiler.com.hosts:
- ‘_some-string TXT “aZCCCChonRJiOCL1ZtkKMKnx7U2k3wbSswyClGb6wGk”’
- ‘_some-string TXT “aZDDDDhonRJiOCL1ZtkKMKnx7U2k3wbSswyClGb6wGk”’
/var/named/chroot/var/named/trioboiler2.com.hosts: - ‘_some-string TXT “aZYYYYhonRJiOCL1ZtkKMKnx7U2k3wbSswyClGb6wGk”’
- ‘_some-string TXT “aZZZZhonRJiOCL1ZtkKMKnx7U2k3wbSswyClGb6wGk”’
Here’s are the plays that I want to use the certs variable file in:
-
name: Add TXT entry 1 to zone file
lineinfile:
dest: “{{ item }}”
insertafter: EOF
line: ‘_acme-challenge TXT “aZCCCChonRJiOCL1ZtkKMKnx7U2k3wbSswyClGb6wGk”’
with_items: “{{ zone_files }}”
register: add_txt1 -
name: Add TXT entry 2 to zone file
lineinfile:
dest: “{{ item }}”
insertafter: EOF
line: ‘_acme-challenge TXT “aZCCCChonRJiOCL1ZtkKMKnx7U2k3wbSswyClGb6wGk”’
with_items: “{{ zone_files }}”
register: add_txt2
*Note that the TXT record has to be added to the zone twice.
The idea, of course, is to not have to put the “line:” in manually for each zone in the two plays. All of that said:
- am I generally on the right track?
- if so, do I have the variables file set up correctly?
- how do I use that variables files in the plays? I’m
I know this is a big ask, but would, as always, appreciate your help.