September 2018
Beginner to intermediate
214 pages
5h 53m
English
Ansible loops offer several possibilities. One of the most common uses is to reduce the amount of code when running the same module multiple times on different inputs. The idea is to define a variable or an object variable that has its own variables, then populate the list with the different entries.
The following playbook shows a good use of Ansible loops to copy several configuration files with different sources, destinations, and ACL settings:
---- name: Copy users config files to their project directory hosts: linuxservers become: yes remote_user: setup gather_facts: true tasks: - name: Copy user config files copy: src: '{{ item.src }}' dest: '{{ item.dest }}' mode: '{{ item.mode | default("0744") }}' owner: '{{ ...Read now
Unlock full access