March 2019
Intermediate to advanced
412 pages
9h 49m
English
The omit variable takes a bit of explaining. Sometimes, when iterating over a hash of data to construct task arguments, it may be necessary to only provide some arguments for some of the items in the hash. Even though Jinja2 supports in-line if statements to conditionally render parts of a line, this does not work well in an Ansible task. Traditionally, playbook authors would create multiple tasks, one for each set of potential arguments passed in, and use conditionals to sort the loop members between each task set. A recently added magic variable named omit solves this problem when used in conjunction with the default filter. The omit variable will remove the argument the variable was used with altogether.
Read now
Unlock full access