blob: b5aa4760c28de0ee49af1032c1d7688775fe7cf6 [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:
Zack Williams299098d2018-04-19 22:15:52 -070082 profile_container_list: |
83 {{ profile_container_list | union(profile_manifest.xos_services | map(attribute='name') | map('regex_replace', '(.*)','xosproject/\1-synchronizer') | list) }}
Matteo Scandoloa61248f2018-01-24 08:47:16 -080084
Matteo Scandoloe75e7972017-12-12 13:23:54 -080085- name: Add items to profile_container_list from profile_manifest.xos_dynamic_services
Zack Williams0fae8f92018-05-09 15:05:27 -070086 when: profile_manifest.xos_dynamic_services is defined
Matteo Scandoloe75e7972017-12-12 13:23:54 -080087 set_fact:
Zack Williams299098d2018-04-19 22:15:52 -070088 profile_container_list: |
89 {{ profile_container_list | union(profile_manifest.xos_dynamic_services | map(attribute='name') | map('regex_replace', '(.*)','xosproject/\1-synchronizer') | list) }}
Matteo Scandoloe75e7972017-12-12 13:23:54 -080090
Matteo Scandoloa61248f2018-01-24 08:47:16 -080091- name: Add items to profile_container_list from profile_manifest.enabled_gui_extensions
92 set_fact:
Zack Williams299098d2018-04-19 22:15:52 -070093 profile_container_list: |
94 {{ profile_container_list | union(profile_manifest.enabled_gui_extensions | map(attribute='name') | map('regex_replace', '(.*)','xosproject/gui-extension-\1') | list) }}
Matteo Scandoloa61248f2018-01-24 08:47:16 -080095
96- name: Update docker_image_whitelist to include containers specified by profile
97 set_fact:
98 master_config: "{{ master_config | combine({'docker_image_whitelist': profile_container_list}, recursive=True) }}"
99
100- name: Print vars
101 debug:
102 var: master_config
103
Zack Williamsce63eb02017-02-28 10:46:22 -0700104- name: Create cord_profile file
105 copy:
106 dest: "{{ ( genconfig_dir ~ '/cord_profile' ) | realpath }}"
107 content: "{{ cord_profile }}"
108
109- name: Create cord_scenario file
110 copy:
111 dest: "{{ ( genconfig_dir ~ '/cord_scenario' ) | realpath }}"
112 content: "{{ cord_scenario }}"
113
114- name: Generate config files
115 template:
116 src: "{{ item }}.j2"
117 dest: "{{ ( genconfig_dir ~ '/' ~ item ) | realpath }}"
118 with_items:
119 - inventory.ini
120 - config.mk
121 - config.yml
122