Zack Williams | 224bfe6 | 2017-11-20 23:02:11 -0700 | [diff] [blame] | 1 | --- |
Matteo Scandolo | 60b640f | 2017-08-08 13:05:22 -0700 | [diff] [blame] | 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 16 | # ansible/genconfig.yml |
Zack Williams | 224bfe6 | 2017-11-20 23:02:11 -0700 | [diff] [blame] | 17 | # Generate CORD configuration files |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 18 | |
| 19 | - name: Load pod and scenario config files |
| 20 | hosts: localhost |
| 21 | connection: local |
| 22 | gather_facts: False |
Zack Williams | 224bfe6 | 2017-11-20 23:02:11 -0700 | [diff] [blame] | 23 | |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 24 | tasks: |
| 25 | |
| 26 | - name: Set pod_config_path fact |
| 27 | set_fact: |
| 28 | pod_config_path: "{{ cord_podconfig | realpath }}" |
| 29 | |
Zack Williams | 224bfe6 | 2017-11-20 23:02:11 -0700 | [diff] [blame] | 30 | - name: Check for PODCONFIG file |
| 31 | stat: |
| 32 | path: "{{ pod_config_path }}" |
| 33 | register: pod_config_stat |
| 34 | |
| 35 | - name: POD config file specified by 'PODCONFIG' must exist |
| 36 | assert: |
| 37 | that: pod_config_stat.stat.isreg |
| 38 | |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 39 | - name: Load pod config |
| 40 | include_vars: "{{ pod_config_path }}" |
| 41 | |
Zack Williams | 224bfe6 | 2017-11-20 23:02:11 -0700 | [diff] [blame] | 42 | - name: Set profile_manifest_path fact |
| 43 | set_fact: |
Andy Bavier | 3316e60 | 2017-12-20 19:36:00 -0700 | [diff] [blame] | 44 | profile_manifest_path: "{{ (cord_profile_src_dir ~ '/' ~ cord_profile ~ '.yml') | realpath }}" |
Zack Williams | 224bfe6 | 2017-11-20 23:02:11 -0700 | [diff] [blame] | 45 | |
| 46 | - name: Check for profile manifest |
| 47 | stat: |
| 48 | path: "{{ profile_manifest_path }}" |
| 49 | register: profile_manifest_stat |
| 50 | |
| 51 | - name: Profile manifest file specified by 'cord_profile' must exist |
| 52 | assert: |
| 53 | that: profile_manifest_stat.stat.isreg |
| 54 | |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 55 | - name: Set scenario_config_path fact |
| 56 | set_fact: |
| 57 | scenario_config_path: "{{ (scenarios_dir ~ '/' ~ cord_scenario ~ '/config.yml') | realpath }}" |
| 58 | |
Zack Williams | 224bfe6 | 2017-11-20 23:02:11 -0700 | [diff] [blame] | 59 | - name: Check for scenario config file manifest |
| 60 | stat: |
| 61 | path: "{{ scenario_config_path }}" |
| 62 | register: scenario_config_stat |
| 63 | |
| 64 | - name: Scenario config.yml file specified by 'cord_scenario' must exist |
| 65 | assert: |
| 66 | that: scenario_config_stat.stat.isreg |
| 67 | |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 68 | - name: Load scenario config |
| 69 | include_vars: "{{ scenario_config_path }}" |
| 70 | |
| 71 | - name: Reload pod config to take precedence |
| 72 | include_vars: "{{ pod_config_path }}" |
| 73 | |
Zack Williams | 224bfe6 | 2017-11-20 23:02:11 -0700 | [diff] [blame] | 74 | - name: Load pod, scenario, profile_manifest into facts |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 75 | set_fact: |
| 76 | pod_config: "{{ lookup('file', pod_config_path) | from_yaml }}" |
| 77 | scenario_config: "{{ lookup('file', scenario_config_path) | from_yaml }}" |
Zack Williams | 224bfe6 | 2017-11-20 23:02:11 -0700 | [diff] [blame] | 78 | profile_manifest: "{{ lookup('file', profile_manifest_path) | from_yaml }}" |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 79 | |
Andy Bavier | 240795c | 2017-12-21 16:31:05 -0700 | [diff] [blame] | 80 | - name: Combine pod and scenario configs and profile manifest into master config |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 81 | set_fact: |
Andy Bavier | 240795c | 2017-12-21 16:31:05 -0700 | [diff] [blame] | 82 | master_config: "{{ profile_manifest | combine(scenario_config) | combine(pod_config) }}" |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 83 | |
Zack Williams | 224bfe6 | 2017-11-20 23:02:11 -0700 | [diff] [blame] | 84 | - name: Prime profile_container_list from with master_config.docker_image_whitelist |
| 85 | set_fact: |
| 86 | profile_container_list: "{{ master_config.docker_image_whitelist }}" |
| 87 | |
| 88 | - name: Add items to profile_container_list from profile_manifest.xos_services |
| 89 | set_fact: |
| 90 | profile_container_list: "{{ profile_container_list }} + [ 'xosproject/{{ item.name }}-synchronizer' ]" |
| 91 | with_items: "{{ profile_manifest.xos_services }}" |
Matteo Scandolo | a05c6ea | 2018-01-11 16:11:21 -0800 | [diff] [blame] | 92 | when: item.synchronizer is not defined or item.synchronizer |
Zack Williams | 224bfe6 | 2017-11-20 23:02:11 -0700 | [diff] [blame] | 93 | |
| 94 | - name: Add items to profile_container_list from profile_manifest.enabled_gui_extensions |
| 95 | set_fact: |
| 96 | profile_container_list: "{{ profile_container_list }} + [ 'xosproject/gui-extension-{{ item.name }}' ]" |
| 97 | with_items: "{{ profile_manifest.enabled_gui_extensions }}" |
| 98 | |
| 99 | - name: Update docker_image_whitelist to include containers specified by profile |
| 100 | set_fact: |
| 101 | master_config: "{{ master_config | combine({'docker_image_whitelist': profile_container_list}, recursive=True) }}" |
| 102 | |
Zack Williams | ce63eb0 | 2017-02-28 10:46:22 -0700 | [diff] [blame] | 103 | - name: Print vars |
| 104 | debug: |
| 105 | var: master_config |
| 106 | |
| 107 | - name: Generate config files |
| 108 | hosts: localhost |
| 109 | connection: local |
| 110 | gather_facts: False |
| 111 | roles: |
| 112 | - genconfig |
| 113 | |