Ansible - Loop

> Infrastructure as code > Ansible

1 - About

3 - Management

3.1 - Nested

loop in Ansible are never nested but you can combine list

- name: give users access to multiple databases
  mysql_user:
    name: "{{ item[0] }}"
    priv: "{{ item[1] }}.*:ALL"
    append_privs: yes
    password: "foo"
  loop: "{{ ['alice', 'bob'] |product(['clientdb', 'employeedb', 'providerdb'])|list }}"
Advertising

4 - Documentation / Reference

infra/ansible/loop.txt · Last modified: 2019/05/13 12:24 by gerardnico