2 # Copyright 2016, Rackspace US, Inc.
3 # Copyright 2017, SUSE LINUX GmbH.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 - name: Clone the scenario requirements
24 - name: Remove existing scenario directories
26 path: "{{ item[1] }}/{{ item[0].scenario }}"
30 - [ "{{ scenario_path_default }}", "{{ role_path_default }}" ]
32 label: "{{ item[0].scenario }}"
34 - name: Update scenarios with local overrides
37 {%- for z in xci_scenarios_overrides -%}
38 {%- for x in scenarios if x.scenario == z.scenario -%}
39 {%- set _ = x.update(z) -%}
43 with_items: "{{ xci_scenarios_overrides }}"
45 label: "{{ item.scenario }}"
46 when: xci_scenarios_overrides is defined
48 - name: Collect list of known scenarions
51 {%- set scenario_names = [] -%}
52 {%- for x in scenarios -%}
53 {%- set _ = scenario_names.append(x.scenario) -%}
55 {{- scenario_names -}}
56 with_items: "{{ scenarios }}"
58 label: "{{ item.scenario }}"
60 - name: Fail if 'DEPLOY_SCENARIO' is not defined
62 msg: "DEPLOY_SCENARIO env variable is not defined so no scenario can be deployed"
63 when: deploy_scenario is not defined
65 - name: Ensure {{ deploy_scenario }} is a known XCI scenario
67 msg: "{{ deploy_scenario }} does not exist"
68 when: deploy_scenario not in known_scenarios
70 - name: Collect scenario information
73 {%- set xci_scenario = {} -%}
74 {%- for x in scenarios if x.scenario == deploy_scenario -%}
75 {%- for z in x.installers if z.installer == installer_type -%}
76 {%- set _ = xci_scenario.update({'flavors': z.flavors}) -%}
77 {%- set _ = xci_scenario.update({'distros': z.distros}) -%}
79 {%- set _ = xci_scenario.update({'role': x.role | basename}) -%}
83 - name: Ensure local facts directory exists
85 path: "/etc/ansible/facts.d"
89 - name: Record scenario information
95 value: "{{ xci_scenario.role | basename }}"
96 path: "/etc/ansible/facts.d/xci.fact"
99 - name: Fail if {{ deploy_scenario }} is not supported
102 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
103 - ERROR! The {{ deploy_scenario }} scenario can't be deployed. This is because
104 - the {{ installer_type }} XCI installer or the {{ xci_flavor }} flavor or the {{ xci_distro }}
105 - distribution is not supported by this scenario. It may also be possible that
106 - this scenario doesn't exist at all or it's not listed in {{ scenario_file }}.
108 - This is a great chance for you to contribute to XCI ;-)
109 - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
112 (xci_scenario['flavors'] is defined and xci_flavor not in xci_scenario['flavors']) or
113 (xci_scenario['distros'] is defined and xci_distro not in xci_scenario['distros'])
115 - name: Clone git repos
117 repo: "{{ item.src }}"
118 dest: "{{ scenario_path_default }}/{{ item.scenario | default(item.src | basename) }}"
119 version: "{{ item.version | default('master') }}"
120 refspec: "{{ item.refspec | default(omit) }}"
123 with_items: "{{ scenarios }}"
125 until: git_clone | success
126 retries: "{{ git_clone_retries }}"
127 delay: "{{ git_clone_retry_delay }}"
129 label: "{{ item.scenario }}"
131 - name: Plug in the scenario Ansible roles to XCI
133 src: "{{ scenario_path_default }}/{{ item.scenario }}/{{ item.role }}/"
134 dest: "{{ role_path_default }}/{{ item.role | basename }}"
135 with_items: "{{ scenarios }}"
137 label: "{{ item.scenario }}"
140 ansible_python_interpreter: "/usr/bin/python"
141 scenarios: "{{ lookup('file', scenario_file) | from_yaml }}"
142 scenario_file: '../opnfv-scenario-requirements.yml'
143 scenario_path_default: "{{ xci_scenarios_cache }}"
144 role_path_default: "{{ playbook_dir }}/roles"
146 git_clone_retry_delay: 5