Difference between revisions of "Use loops in task (Ansible)"

From wikieduonline
Jump to navigation Jump to search
(Created page with "Ansible offers two keywords for creating loops: <code>loop</code> and <code>with_<lookup></code>. <pre> $ vim create-users.yml --- - name: Create New Users hosts: all g...")
 
Line 1: Line 1:
Ansible offers two keywords for creating loops: <code>loop</code> and <code>with_<lookup></code>.
+
[[Ansible]] offers two keywords for creating loops: <code>loop</code> and <code>with_<lookup></code>.
  
  

Revision as of 12:27, 26 December 2019

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
...                  


See also

Advertising: