blob: 8f4bde38de2f2cdf82e120340ef844437362e1c5 [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
Matteo Scandoloe75e7972017-12-12 13:23:54 -080086- name: Add items to profile_container_list from profile_manifest.xos_dynamic_services
87 set_fact:
88 profile_container_list: "{{ profile_container_list }} + [ 'xosproject/{{ item.name }}-synchronizer' ]"
89 with_items: "{{ profile_manifest.xos_dynamic_services if 'xos_dynamic_services' in profile_manifest else [] }}"
90 when: item.synchronizer is not defined or item.synchronizer
91
Matteo Scandoloa61248f2018-01-24 08:47:16 -080092- name: Add items to profile_container_list from profile_manifest.enabled_gui_extensions
93 set_fact:
94 profile_container_list: "{{ profile_container_list }} + [ 'xosproject/gui-extension-{{ item.name }}' ]"
95 with_items: "{{ profile_manifest.enabled_gui_extensions }}"
96
97- name: Update docker_image_whitelist to include containers specified by profile
98 set_fact:
99 master_config: "{{ master_config | combine({'docker_image_whitelist': profile_container_list}, recursive=True) }}"
100
101- name: Print vars
102 debug:
103 var: master_config
104
Zack Williamsce63eb02017-02-28 10:46:22 -0700105- name: Create cord_profile file
106 copy:
107 dest: "{{ ( genconfig_dir ~ '/cord_profile' ) | realpath }}"
108 content: "{{ cord_profile }}"
109
110- name: Create cord_scenario file
111 copy:
112 dest: "{{ ( genconfig_dir ~ '/cord_scenario' ) | realpath }}"
113 content: "{{ cord_scenario }}"
114
115- name: Generate config files
116 template:
117 src: "{{ item }}.j2"
118 dest: "{{ ( genconfig_dir ~ '/' ~ item ) | realpath }}"
119 with_items:
120 - inventory.ini
121 - config.mk
122 - config.yml
123