Last active
September 7, 2020 19:35
-
-
Save tjtoml/4180d973e2aa9cbb47e0cb5ce973fcbb to your computer and use it in GitHub Desktop.
ansible looping
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#path /tmp/test1.txt | |
test1 | |
test1-foo | |
test1-bar | |
3000 | |
#path /tmp/test2.txt | |
test2 | |
test2-foo | |
test2-bar | |
3001 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: all | |
vars_files: vars.yml | |
tasks: | |
name: template | |
template: | |
src: src.j2 | |
dest: /tmp/{{ item.name }}.txt | |
owner: root | |
group: root | |
mode: 0777 | |
loop: "{{ sites }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ item.name }} | |
{{ item.foo }} | |
{{ item.bar }} | |
{{ 3000 + loop_index }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
sites: | |
- name: test1 | |
foo: test1-foo | |
bar: test2-bar | |
- name: test2 | |
foo: test2-foo | |
bar: test2-bar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment