/
main.yml
122 lines (97 loc) · 4.22 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
# Copyright 2017-present Open Networking Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# genconfig/tasks/main.yml
- name: Set pod_config_path fact
set_fact:
pod_config_path: "{{ cord_podconfig | realpath }}"
- name: Check for PODCONFIG file
stat:
path: "{{ pod_config_path }}"
register: pod_config_stat
- name: POD config file specified by 'PODCONFIG' must exist
assert:
that: pod_config_stat.stat.isreg
- name: Load pod config
include_vars: "{{ pod_config_path }}"
- name: Set profile_manifest_path fact
set_fact:
profile_manifest_path: "{{ (cord_profile_src_dir ~ '/' ~ cord_profile ~ '.yml') | realpath }}"
- name: Check for profile manifest
stat:
path: "{{ profile_manifest_path }}"
register: profile_manifest_stat
- name: Profile manifest file specified by 'cord_profile' must exist
assert:
that: profile_manifest_stat.stat.isreg
- name: Set scenario_config_path fact
set_fact:
scenario_config_path: "{{ (scenarios_dir ~ '/' ~ cord_scenario ~ '/config.yml') | realpath }}"
- name: Check for scenario config file manifest
stat:
path: "{{ scenario_config_path }}"
register: scenario_config_stat
- name: Scenario config.yml file specified by 'cord_scenario' must exist
assert:
that: scenario_config_stat.stat.isreg
- name: Load scenario config
include_vars: "{{ scenario_config_path }}"
- name: Reload pod config to take precedence
include_vars: "{{ pod_config_path }}"
- name: Load pod, scenario, profile_manifest into facts
set_fact:
pod_config: "{{ lookup('file', pod_config_path) | from_yaml }}"
scenario_config: "{{ lookup('file', scenario_config_path) | from_yaml }}"
profile_manifest: "{{ lookup('file', profile_manifest_path) | from_yaml }}"
- name: Combine pod and scenario configs and profile manifest into master config
set_fact:
master_config: "{{ profile_manifest | combine(scenario_config) | combine(pod_config) }}"
- name: Prime profile_container_list from with master_config.docker_image_whitelist
set_fact:
profile_container_list: "{{ master_config.docker_image_whitelist }}"
- name: Add items to profile_container_list from profile_manifest.xos_services
set_fact:
profile_container_list: |
{{ profile_container_list | union(profile_manifest.xos_services | map(attribute='name') | map('regex_replace', '(.*)','xosproject/\1-synchronizer') | list) }}
- name: Add items to profile_container_list from profile_manifest.xos_dynamic_services
when: profile_manifest.xos_dynamic_services is defined
set_fact:
profile_container_list: |
{{ profile_container_list | union(profile_manifest.xos_dynamic_services | map(attribute='name') | map('regex_replace', '(.*)','xosproject/\1-synchronizer') | list) }}
- name: Add items to profile_container_list from profile_manifest.enabled_gui_extensions
set_fact:
profile_container_list: |
{{ profile_container_list | union(profile_manifest.enabled_gui_extensions | map(attribute='name') | map('regex_replace', '(.*)','xosproject/gui-extension-\1') | list) }}
- name: Update docker_image_whitelist to include containers specified by profile
set_fact:
master_config: "{{ master_config | combine({'docker_image_whitelist': profile_container_list}, recursive=True) }}"
- name: Print vars
debug:
var: master_config
- name: Create cord_profile file
copy:
dest: "{{ ( genconfig_dir ~ '/cord_profile' ) | realpath }}"
content: "{{ cord_profile }}"
- name: Create cord_scenario file
copy:
dest: "{{ ( genconfig_dir ~ '/cord_scenario' ) | realpath }}"
content: "{{ cord_scenario }}"
- name: Generate config files
template:
src: "{{ item }}.j2"
dest: "{{ ( genconfig_dir ~ '/' ~ item ) | realpath }}"
with_items:
- inventory.ini
- config.mk
- config.yml