blob: 61c9417152cb3ee97006d63eda27bb9d5721a5aa [file] [log] [blame]
Zack Williams89bac2d2017-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 Williams89bac2d2017-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 Williams89bac2d2017-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 Williams89bac2d2017-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 Williams89bac2d2017-11-20 23:02:11 -070042 - name: Set profile_manifest_path fact
43 set_fact:
44 profile_manifest_path: "{{ (platform_install_dir ~ '/profile_manifests/' ~ cord_profile ~ '.yml') | realpath }}"
45
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 Williams89bac2d2017-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 Williams89bac2d2017-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 Williams89bac2d2017-11-20 23:02:11 -070078 profile_manifest: "{{ lookup('file', profile_manifest_path) | from_yaml }}"
Zack Williamsce63eb02017-02-28 10:46:22 -070079
80 - name: Combine pod and scenario config into master config
81 set_fact:
82 master_config: "{{ scenario_config | combine(pod_config) }}"
83
Zack Williams89bac2d2017-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:
Zack Williams31134ef2018-04-19 22:15:52 -070090 profile_container_list: |
91 {{ profile_container_list | union(profile_manifest.xos_services | map(attribute='name') | map('regex_replace', '(.*)','xosproject/\1-synchronizer') | list) }}
Zack Williams89bac2d2017-11-20 23:02:11 -070092
93 - name: Add items to profile_container_list from profile_manifest.enabled_gui_extensions
94 set_fact:
Zack Williams31134ef2018-04-19 22:15:52 -070095 profile_container_list: |
96 {{ profile_container_list | union(profile_manifest.enabled_gui_extensions | map(attribute='name') | map('regex_replace', '(.*)','xosproject/gui-extension-\1') | list) }}
Zack Williams89bac2d2017-11-20 23:02:11 -070097
98 - name: Update docker_image_whitelist to include containers specified by profile
99 set_fact:
100 master_config: "{{ master_config | combine({'docker_image_whitelist': profile_container_list}, recursive=True) }}"
101
Zack Williamsce63eb02017-02-28 10:46:22 -0700102 - name: Print vars
103 debug:
104 var: master_config
105
106- name: Generate config files
107 hosts: localhost
108 connection: local
109 gather_facts: False
110 roles:
111 - genconfig
112