Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 1 | --- |
| 2 | # ansible/genconfig.yml |
| 3 | # Generate configuration files |
| 4 | |
| 5 | - name: Load pod and scenario config files |
| 6 | hosts: localhost |
| 7 | connection: local |
| 8 | gather_facts: False |
| 9 | tasks: |
| 10 | |
| 11 | - name: Set pod_config_path fact |
| 12 | set_fact: |
| 13 | pod_config_path: "{{ cord_podconfig | realpath }}" |
| 14 | |
| 15 | - name: Load pod config |
| 16 | include_vars: "{{ pod_config_path }}" |
| 17 | |
| 18 | - name: Set scenario_config_path fact |
| 19 | set_fact: |
| 20 | scenario_config_path: "{{ (scenarios_dir ~ '/' ~ cord_scenario ~ '/config.yml') | realpath }}" |
| 21 | |
| 22 | - name: Load scenario config |
| 23 | include_vars: "{{ scenario_config_path }}" |
| 24 | |
| 25 | - name: Reload pod config to take precedence |
| 26 | include_vars: "{{ pod_config_path }}" |
| 27 | |
| 28 | - name: Load pod and scenario configs into facts |
| 29 | set_fact: |
| 30 | pod_config: "{{ lookup('file', pod_config_path) | from_yaml }}" |
| 31 | scenario_config: "{{ lookup('file', scenario_config_path) | from_yaml }}" |
| 32 | |
| 33 | - name: Combine pod and scenario config into master config |
| 34 | set_fact: |
| 35 | master_config: "{{ scenario_config | combine(pod_config) }}" |
| 36 | |
| 37 | - name: Print vars |
| 38 | debug: |
| 39 | var: master_config |
| 40 | |
| 41 | - name: Generate config files |
| 42 | hosts: localhost |
| 43 | connection: local |
| 44 | gather_facts: False |
| 45 | roles: |
| 46 | - genconfig |
| 47 | |