Skip to content

rektide/ansible-with-first

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Use case

I'd like to generate a bunch of /etc/bind9/zone.d/${zone_name}.zone files. These files ought either come from a _stock.zone template, or, if available, a ${zone_name}.zone file.

Status

At present this ansible-playbook with-first.pb gives ERROR: with_(plugin), and first_available_file are mutually incompatible in a single task. This result is in accord with ansible/ansible#552 , Make with_items and first_available_file usable together or otherwise warn, which this script attempts to do.

Hope

with_item and first_available_file both collide with the $item variable. Rather than forbid this clobbering outright, provide a non-colliding codepath where both can be used: with_{plugin} to iterate through the action multiple times, and first_available_file to look for targets within a single run. with-first.disambiguated.pb demonstrates such a non-colliding path, making use of distinct ${firstAvailableFile} and ${item} files.

For backwards compatibility sake, ${item} can continue to be set by first_available_file in all cases where with_{plugin} is not used.

Alas movement appears to be towards further overriding the use of ${item} to make it do more, not separate out the distinct contextual uses of first_available_file (which operates WITHIN an iteration of a module being looped through via with_{plugin}) and with_{plugin}, which triggers this outtermost looping iteration. ansible/ansible#2260

About

An example of a what with_items and first_available_file could mean in Ansible.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published