blob: c05d06c001d42ed79f2dea14a5d38a90d370c180 (
plain)
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
122
123
124
125
126
127
|
---
# Copyright 2016, Rackspace US, Inc.
# Copyright 2017, SUSE LINUX GmbH.
#
# 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.
- name: Clone the scenario requirements
hosts: localhost
connection: local
gather_facts: true
vars_files:
- ../var/opnfv.yml
tasks:
- name: Remove existing scenario directories
file:
path: "{{ item[1] }}/{{ item[0].scenario }}"
state: absent
with_nested:
- "{{ scenarios }}"
- [ "{{ scenario_path_default }}", "{{ role_path_default }}" ]
loop_control:
label: "{{ item[0].scenario }}"
- name: Update scenarios with local overrides
set_fact:
scenarios: >
{%- for z in xci_scenarios_overrides -%}
{%- for x in scenarios if x.scenario == z.scenario -%}
{%- set _ = x.update(z) -%}
{%- endfor -%}
{%- endfor -%}
{{- scenarios -}}
with_items: "{{ xci_scenarios_overrides }}"
loop_control:
label: "{{ item.scenario }}"
when: xci_scenarios_overrides is defined
- name: Clone git repos
git:
repo: "{{ item.src }}"
dest: "{{ scenario_path_default }}/{{ item.scenario | default(item.src | basename) }}"
version: "{{ item.version | default('master') }}"
refspec: "{{ item.refspec | default(omit) }}"
update: true
force: true
with_items: "{{ scenarios }}"
register: git_clone
until: git_clone | success
retries: "{{ git_clone_retries }}"
delay: "{{ git_clone_retry_delay }}"
loop_control:
label: "{{ item.scenario }}"
- name: Plug in the scenario Ansible roles to XCI
synchronize:
src: "{{ scenario_path_default }}/{{ item.scenario }}/{{ item.role }}/"
dest: "{{ role_path_default }}/{{ item.role | basename }}"
with_items: "{{ scenarios }}"
loop_control:
label: "{{ item.scenario }}"
- name: Gather information about the selected {{ deploy_scenario }} scenario
set_fact:
deploy_scenario: "{{ item }}"
with_items: "{{ scenarios }}"
loop_control:
label: "{{ item.scenario }}"
when: deploy_scenario | lower == item.scenario
- name: Determine if the selected {{ deploy_scenario }} scenario can be deployed
block:
- name: Set scenario installer fact
set_fact:
deploy_scenario_installer: "{{ item }}"
with_items: "{{ deploy_scenario.installers }}"
loop_control:
label: "{{ item.installer }}"
when: item.installer == installer_type
- name: Set scenario flavor fact
set_fact:
deploy_scenario_flavor: "{{ (xci_flavor in deploy_scenario_installer.flavors) | bool }}"
when:
- deploy_scenario_installer is defined
- deploy_scenario_installer
- name: Set scenario distro flavor fact
set_fact:
deploy_scenario_distro: "{{ (xci_distro in deploy_scenario_installer.distros) | bool }}"
when:
- deploy_scenario_flavor is defined
- deploy_scenario_flavor
when: deploy_scenario is defined
- name: Fail if {{ deploy_scenario.scenario }} is not supported
fail:
msg:
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ERROR! The {{ deploy_scenario.scenario }} scenario can't be deployed. This is because
- the {{ installer_type }} XCI installer or the {{ xci_flavor }} flavor or the {{ xci_distro }}
- distribution is not supported by this scenario. It may also be possible that
- this scenario doesn't exist at all or it's not listed in {{ scenario_file }}.
- ''
- This is a great chance for you to contribute to XCI ;-)
- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- ''
when:
- deploy_scenario is not defined or
deploy_scenario_distro is not defined or
(deploy_scenario_distro is defined and not deploy_scenario_distro)
vars:
ansible_python_interpreter: "/usr/bin/python"
scenarios: "{{ lookup('file', scenario_file) | from_yaml }}"
scenario_file: '../opnfv-scenario-requirements.yml'
scenario_path_default: "{{ xci_scenarios_cache }}"
role_path_default: "{{ playbook_dir }}/roles"
git_clone_retries: 2
git_clone_retry_delay: 5
|