I've been looking for a solutions for this, but I can't seem to figure it out. Here is what I want to do:
I'm writing a playbook to manage a number of DNS servers. I have a list of zones in my vars file, like so:
list_of_zones:
-
a.com -
b.com -
c.cometc...
I then have a dir with each zone file in it:
zones/a.com.db
zones/b.com.db
etc...
However, for some of the zones, I just want to use a default zone file. So basically, what I would like to do is something like this:
- name: Copy zone files
copy: src=zones/{{ item }} dest=/var/named/zones/{{ item }}
with_first_file:
- path/to/zones/{{ item }}.db
- path/to/zones/default.db
with_items:
- list_of_zones
This however does not work.
I tried to split out the copy part and with_first_file to a different file in the playbook and include it, passing the zone as a var, but I then got a warning that using with_items together with include was not recommended and that it was going to be deprecated.
I'm a bit lost how to solve this. One option would of course be to extend my zones var to include the name of the zone file as well, but I would like to make this as dynamic as possible. Any ideas are welcome.
Thanks,
/Martin