Ansible Task Looping Directives

From NovaOrdis Knowledge Base
Revision as of 09:50, 4 July 2021 by Ovidiu (talk | contribs) (Created page with "=Internal= * Ansible Concepts =Overview= =Looping Directives= ==<tt>with_items</tt>== An iterator whose elements can be accessed with <...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

Looping Directives

with_items

An iterator whose elements can be accessed with item.<element>.

loop

Takes a list for the task to iterate over, saving each list element into the item variable (configurable via loop_control)

jdks:
  - corretto8
  - corretto11
...
- name: Multiple items in a loop
  homebrew_cask:
    name: "{{ item }}"
    state: present
  loop: "{{ jdks }}"

loop_control

with_<lookup_plugin>

The same as loop but adds the output of any lookup plugin to generate the item list.