Created
July 25, 2017 08:01
-
-
Save berlic/bedf6024ca9aa327ae15f65412c37668 to your computer and use it in GitHub Desktop.
yaml combine
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 | |
vars: | |
config_files: | |
- test1 | |
- test2 | |
tasks: | |
- name: Load config defaults | |
include_vars: | |
file: "{{ item }}.yml" | |
name: "default_config" | |
with_items: "{{ config_files }}" | |
register: default_configs | |
tags: | |
- configuration | |
- name: Combine configs into one dict | |
# Здесь мы делаем словарь вида | |
# default_configs: | |
# config_name_1: { default_config_object } | |
# config_name_2: { default_config_object } | |
# config_name_3: { default_config_object } | |
# ... | |
set_fact: | |
default_configs: "{{ dict(default_configs.results | json_query('[].[item, ansible_facts.default_config]')) }}" | |
tags: | |
- configuration | |
- debug: | |
var: default_configs |
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
foo: bar |
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
hello: world |
Author
berlic
commented
Jul 25, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment