Guillaume Coré
2019-12-09 dafba27ba5da1314c65cef2ee05867e968f345d8
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
---
- 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: stats env_vars.yml and (legacy) env_secret_vars.yml
      stat:
        path: "{{ item }}"
      loop:
        - configs/{{ env_type }}/env_vars.yml
        - cloud_providers/{{ cloud_provider }}_default_vars.yml
        - configs/{{ env_type }}/env_secret_vars.yml
        - "{{ secret_file | d('/secret/file/not/passed') }}"
      register: rstat_varfiles
 
    - name: Include vars files
      include_vars:
        file: "{{ item.stat.path }}"
      when:
        - item is not skipped
        - item.stat.exists
      loop: "{{ rstat_varfiles.results }}"
      loop_control:
        label: >-
          {{ (
            item.stat.path
            | default(item._ansible_item_label)
            | default(item)
          ) if 'stat' in item else item }}