Last active
August 12, 2018 13:54
-
-
Save nikuyoshi/203f6eafd7e86db697ce446e2bbd2789 to your computer and use it in GitHub Desktop.
Ansible Playbook for setting sequential path in the 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
TASK [debug] ************************************************************************************************************************************************************************************************************************************************************************************************** | |
ok: [localhost] => { | |
"instance_path_list": [ | |
"/var/log/instance_1/log", | |
"/var/log/instance_2/log", | |
"/var/log/instance_3/log", | |
"/var/log/instance_4/log" | |
] | |
} |
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: Set fatcs | |
hosts: localhost | |
sudo: no | |
connection: local | |
vars: | |
instance_number: 4 | |
tasks: | |
- name: Register instance's sequential path | |
set_fact: | |
instance_path: /var/log/instance_{{ item }}/log | |
with_sequence: start=1 end={{ instance_number }} | |
register: sequential_path | |
- name: Set fact | |
set_fact: | |
instance_path_list: | |
"{{ sequential_path.results | map(attribute='ansible_facts.instance_path') | list }}" | |
- name: debug | |
debug: | |
var: instance_path_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment