Posts

How to use Ansible with_item

 The Ansible items plugin is a lookup plugin used to return the list of items provided to it with recursing. A lookup plugin allows you to access the data from outside resources. Data provided in the by lookup plugins are accessed via Jinja2 templates allowing you to load variables, templates, and more. This guide takes a look at the with_items plugin. What is Ansible with_items ? The Ansible with_items is a handy plugin to perform loop operations in a playbook. The plugin accepts items and then passes them to the calling module. For example, you can pass a list of packages to install and then give each item in the list to the install task. NOTE: If an item has a nested list, Ansible will flatten it but not recursion.   To use the with_items plugins, use the with_items keyword in a playbook and pass a list of items under it. You can then call each item within the specified list and perform the required operations. Basic Usage The following example illustrates th...