Difference between revisions of "Use loops in task (Ansible)"
Jump to navigation
Jump to search
Line 29: | Line 29: | ||
* <code>[[with_items]]</code> https://docs.ansible.com/ansible/latest/plugins/lookup/items.html | * <code>[[with_items]]</code> https://docs.ansible.com/ansible/latest/plugins/lookup/items.html | ||
* [[User ssh access]] | * [[User ssh access]] | ||
+ | * {{Ansible}} | ||
− | [[Category: | + | [[Category:Ansible]] |
[[Category:Server administration]] | [[Category:Server administration]] |
Revision as of 05:55, 8 November 2020
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
with_items
https://docs.ansible.com/ansible/latest/plugins/lookup/items.html- User ssh access
- Ansible: modules, plugins, Playbooks (examples)
ansible-playbook
,ansible-vault
,ansible-inventory
,ansible-config
, Ansible Tower, Ansible Galaxy (Roles) (ansible-galaxy
),ansible-cmdb
,gather facts
,ansible.cfg
,Ansible Molecule
, Ansible collections,register
,template
,--ask-pass
,--ask-become-pass
,remote_user:
,/etc/ansible/hosts
,ansible-doc
,ansible-lint
,.ansible/
,--forks
,--start-at-task
,changelog
,inventory
,Notify:
,ansible HOSTNAME -m ping
,gathering
,/usr/bin/ansible
,ansible -m ping
,ansible.builtin
,hosts: (Ansible)
,set fact:
,when:
,blockinfile:
,become method:
,include:
,git:
, AWX,ansible --help
, Tags, Ansible variables, versions
Advertising: