blob: d07980b8efde14ed0780c895784bb75e86bd55c1 [file] [log] [blame]
Zack Williams224bfe62017-11-20 23:02:11 -07001---
Matteo Scandolo60b640f2017-08-08 13:05:22 -07002# 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 Williamsce63eb02017-02-28 10:46:22 -070016# ansible/genconfig.yml
Zack Williams224bfe62017-11-20 23:02:11 -070017# Generate CORD configuration files
Zack Williamsce63eb02017-02-28 10:46:22 -070018
19- name: Load pod and scenario config files
20 hosts: localhost
21 connection: local
22 gather_facts: False
Zack Williams224bfe62017-11-20 23:02:11 -070023
Zack Williamsce63eb02017-02-28 10:46:22 -070024 tasks:
25
26 - name: Set pod_config_path fact
27 set_fact:
28 pod_config_path: "{{ cord_podconfig | realpath }}"
29
Zack Williams224bfe62017-11-20 23:02:11 -070030 - 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 Williamsce63eb02017-02-28 10:46:22 -070039 - name: Load pod config
40 include_vars: "{{ pod_config_path }}"
41
Zack Williams224bfe62017-11-20 23:02:11 -070042 - name: Set profile_manifest_path fact
43 set_fact:
Andy Bavier3316e602017-12-20 19:36:00 -070044 profile_manifest_path: "{{ (cord_profile_src_dir ~ '/' ~ cord_profile ~ '.yml') | realpath }}"
Zack Williams224bfe62017-11-20 23:02:11 -070045
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 Williamsce63eb02017-02-28 10:46:22 -070055 - name: Set scenario_config_path fact
56 set_fact:
57 scenario_config_path: "{{ (scenarios_dir ~ '/' ~ cord_scenario ~ '/config.yml') | realpath }}"
58
Zack Williams224bfe62017-11-20 23:02:11 -070059 - 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 Williamsce63eb02017-02-28 10:46:22 -070068 - 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 Williams224bfe62017-11-20 23:02:11 -070074 - name: Load pod, scenario, profile_manifest into facts
Zack Williamsce63eb02017-02-28 10:46:22 -070075 set_fact:
76 pod_config: "{{ lookup('file', pod_config_path) | from_yaml }}"
77 scenario_config: "{{ lookup('file', scenario_config_path) | from_yaml }}"
Zack Williams224bfe62017-11-20 23:02:11 -070078 profile_manifest: "{{ lookup('file', profile_manifest_path) | from_yaml }}"
Zack Williamsce63eb02017-02-28 10:46:22 -070079
Andy Bavier240795c2017-12-21 16:31:05 -070080 - name: Combine pod and scenario configs and profile manifest into master config
Zack Williamsce63eb02017-02-28 10:46:22 -070081 set_fact:
Andy Bavier240795c2017-12-21 16:31:05 -070082 master_config: "{{ profile_manifest | combine(scenario_config) | combine(pod_config) }}"
Zack Williamsce63eb02017-02-28 10:46:22 -070083
Zack Williams224bfe62017-11-20 23:02:11 -070084 - 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 Scandoloa05c6ea2018-01-11 16:11:21 -080092 when: item.synchronizer is not defined or item.synchronizer
Zack Williams224bfe62017-11-20 23:02:11 -070093
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 Williamsce63eb02017-02-28 10:46:22 -0700103 - 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