Created
August 15, 2018 23:15
-
-
Save mwhahaha/a23764047d85d50fb0b66e412ac90046 to your computer and use it in GitHub Desktop.
ansible array appending with set_fact
This file contains 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
--- | |
- name: looping | |
shell: > | |
echo "{{ loop_input }}" | |
register: foo | |
- set_fact: | |
loop_var: [] | |
when: loop_var is not defined | |
- set_fact: | |
loop_var: "{{ loop_var }} + {{ [ foo.stdout ] }}" | |
- debug: | |
var: loop_var |
This file contains 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: localhost | |
connection: local | |
gather_facts: false | |
tasks: | |
- name: testing loops | |
include: loop.yml loop_input={{ item }} | |
with_items: | |
- 'foo' | |
- 'bar' | |
- 'baz' | |
- debug: | |
var: loop_var |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment