Use loops in task (Ansible)

From wikieduonline
Revision as of 16:48, 20 December 2022 by Ant (talk | contribs) (→‎Related terms)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Ansible offers two keywords for creating loops: loop and with_<lookup>.


$ vim create-users.yml 
---
- name: Create New Users
  hosts: all
  gather_facts: false
  tasks:
   - name: Create Users Task
      user:
        name: "{{ item }}"
        state: present
        password: "{{ default_user_password | password_hash('sha512', 'A512') }}"
        shell: /bin/bash
        groups: "{{ admin_group }}"
        append: true
      loop:
        - bob
        - wendy
        - lofty
        - dizzy
...                  

Related terms

See also

Advertising: