blob: cb88406e6f121534dac6282a9752a50880c97752 [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# genconfig/tasks/main.yml
17
Matteo Scandoloa61248f2018-01-24 08:47:16 -080018- name: Set pod_config_path fact
19 set_fact:
20 pod_config_path: "{{ cord_podconfig | realpath }}"
21
22- name: Check for PODCONFIG file
23 stat:
24 path: "{{ pod_config_path }}"
25 register: pod_config_stat
26
27- name: POD config file specified by 'PODCONFIG' must exist
28 assert:
29 that: pod_config_stat.stat.isreg
30
31- name: Load pod config
32 include_vars: "{{ pod_config_path }}"
33
34- name: Set profile_manifest_path fact
35 set_fact:
36 profile_manifest_path: "{{ (cord_profile_src_dir ~ '/' ~ cord_profile ~ '.yml') | realpath }}"
37
38- name: Check for profile manifest
39 stat:
40 path: "{{ profile_manifest_path }}"
41 register: profile_manifest_stat
42
43- name: Profile manifest file specified by 'cord_profile' must exist
44 assert:
45 that: profile_manifest_stat.stat.isreg
46
47- name: Set scenario_config_path fact
48 set_fact:
49 scenario_config_path: "{{ (scenarios_dir ~ '/' ~ cord_scenario ~ '/config.yml') | realpath }}"
50
51- name: Check for scenario config file manifest
52 stat:
53 path: "{{ scenario_config_path }}"
54 register: scenario_config_stat
55
56- name: Scenario config.yml file specified by 'cord_scenario' must exist
57 assert:
58 that: scenario_config_stat.stat.isreg
59
60- name: Load scenario config
61 include_vars: "{{ scenario_config_path }}"
62
63- name: Reload pod config to take precedence
64 include_vars: "{{ pod_config_path }}"
65
66- name: Load pod, scenario, profile_manifest into facts
67 set_fact:
68 pod_config: "{{ lookup('file', pod_config_path) | from_yaml }}"
69 scenario_config: "{{ lookup('file', scenario_config_path) | from_yaml }}"
70 profile_manifest: "{{ lookup('file', profile_manifest_path) | from_yaml }}"
71
72- name: Combine pod and scenario configs and profile manifest into master config
73 set_fact:
74 master_config: "{{ profile_manifest | combine(scenario_config) | combine(pod_config) }}"
75
76- name: Prime profile_container_list from with master_config.docker_image_whitelist
77 set_fact:
78 profile_container_list: "{{ master_config.docker_image_whitelist }}"
79
80- name: Add items to profile_container_list from profile_manifest.xos_services
81 set_fact:
82 profile_container_list: "{{ profile_container_list }} + [ 'xosproject/{{ item.name }}-synchronizer' ]"
83 with_items: "{{ profile_manifest.xos_services }}"
84 when: item.synchronizer is not defined or item.synchronizer
85
86- name: Add items to profile_container_list from profile_manifest.enabled_gui_extensions
87 set_fact:
88 profile_container_list: "{{ profile_container_list }} + [ 'xosproject/gui-extension-{{ item.name }}' ]"
89 with_items: "{{ profile_manifest.enabled_gui_extensions }}"
90
91- name: Update docker_image_whitelist to include containers specified by profile
92 set_fact:
93 master_config: "{{ master_config | combine({'docker_image_whitelist': profile_container_list}, recursive=True) }}"
94
95- name: Print vars
96 debug:
97 var: master_config
98
Zack Williamsce63eb02017-02-28 10:46:22 -070099- name: Create cord_profile file
100 copy:
101 dest: "{{ ( genconfig_dir ~ '/cord_profile' ) | realpath }}"
102 content: "{{ cord_profile }}"
103
104- name: Create cord_scenario file
105 copy:
106 dest: "{{ ( genconfig_dir ~ '/cord_scenario' ) | realpath }}"
107 content: "{{ cord_scenario }}"
108
109- name: Generate config files
110 template:
111 src: "{{ item }}.j2"
112 dest: "{{ ( genconfig_dir ~ '/' ~ item ) | realpath }}"
113 with_items:
114 - inventory.ini
115 - config.mk
116 - config.yml
117