forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
include_vars.yml
63 lines (60 loc) · 1.8 KB
/
include_vars.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
- hosts: localhost
connection: local
gather_facts: no
tags: include_vars
tasks:
- name: Stat default variables files (both yaml/yml extensions)
vars:
find_me:
# Global default vars related to the cloud provider
- cloud_providers/{{ cloud_provider }}_default_vars
# Legacy env_vars.yml (replaced by default_vars.yml)
- configs/{{ env_type }}/env_vars
# Default vars of the config
- configs/{{ env_type }}/default_vars
# Default vars of the config, specific to a cloud provider
- configs/{{ env_type }}/default_vars.{{ cloud_provider }}
- configs/{{ env_type }}/default_vars_{{ cloud_provider }}
# Lecacy secret vars file.
- configs/{{ env_type }}/env_secret_vars
extensions:
- yaml
- yml
stat:
path: "{{ item[0] ~ '.' ~ item[1] }}"
loop: "{{ find_me | product(extensions) | list }}"
register: rstat_varfiles
- name: Stat variables files
vars:
find_me:
# secret file path passed as extra-var
- "{{ secret_file | d('/secret/file/not/passed') }}"
stat:
path: "{{ item }}"
loop: "{{ find_me }}"
register: rstat2_varfiles
- hosts:
- localhost
- all
connection: local
gather_facts: no
tags: include_vars
tasks:
- name: Set output_dir for all hosts
set_fact:
output_dir: "{{ hostvars.localhost.output_dir }}"
when: hostvars.localhost.output_dir is defined
- name: Include variables files
include_vars:
file: "{{ item.stat.path }}"
when:
- item is not skipped
- item.stat.exists
loop: "{{ hostvars.localhost.rstat_varfiles.results + hostvars.localhost.rstat2_varfiles.results }}"
loop_control:
label: >-
{{ (
item.stat.path
| default('skipped')
) if 'stat' in item else item }}