Created
October 2, 2018 12:33
-
-
Save gorshunovr/cfe1232d03d940fb8ed5095d3318fb38 to your computer and use it in GitHub Desktop.
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 | |
gather_facts: no | |
tasks: | |
- name: "loop through list" | |
debug: | |
msg: "An item: {{ item }}" | |
with_items: | |
- 1 | |
- 2 | |
- 3 | |
- name: Create the list | |
set_fact: | |
my_list: | |
- "One fish" | |
- "Two fish" | |
- "Red fish" | |
- "Blue fish" | |
- name: "loop through list - flat 1" | |
debug: | |
msg: "Flat items: {{ my_list | join(' --option ') }}" | |
- name: "set_fact" | |
set_fact: | |
my_list: "{{ my_list | map('regex_replace', '^(.*)$', 'PREFIX \\1 SUFFIX') | list }}" | |
- name: "loop through list - flat 2" | |
debug: | |
msg: "Flat items: {{ my_list | join(' ') }}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment