--- # 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: Create scenario directories file: path: "{{ role_path_default }}/{{ item.scenario }}" state: directory with_items: "{{ scenarios }}" loop_control: label: "{{ item.scenario }}" - name: Clone git repos (with git) 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 when: - item.scm == "git" or item.scm is undefined 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: Check that scenarios exist stat: path: "{{ scenario_path_default }}/{{ item.scenario }}/{{ item.role }}" register: scenarios_list_exists with_items: "{{ scenarios }}" loop_control: label: "{{ item.scenario }}" - name: Plug in the scenario to XCI synchronize: src: "{{ scenario_path_default }}/{{ item.item.scenario }}/{{ item.item.role }}/" dest: "{{ role_path_default }}/{{ item.item.scenario }}" when: item.stat.exists with_items: "{{ scenarios_list_exists.results }}" loop_control: label: "{{ item.item.scenario }}" - name: Synchronize local changes to scenarios' master branch synchronize: src: "{{ XCI_PATH }}/{{ item.item.role }}/" dest: "{{ role_path_default }}/{{ item.item.scenario }}" failed_when: false when: - item.stat.exists - item.item.version == 'master' with_items: "{{ scenarios_list_exists.results }}" loop_control: label: "{{ item.item.scenario }}" - name: Plug in the scenario to XCI (fallback) synchronize: src: "{{ XCI_PATH }}/{{ item.item.role }}/" dest: "{{ role_path_default }}/{{ item.item.scenario }}" when: not item.stat.exists with_items: "{{ scenarios_list_exists.results }}" loop_control: label: "{{ item.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: - set_fact: deploy_scenario_nfvi: "{{ item }}" with_items: "{{ deploy_scenario.nfvis }}" loop_control: label: "{{ item.nfvi }}" when: item.nfvi == XCI_NFVI - set_fact: deploy_scenario_flavor: "{{ (XCI_FLAVOR in deploy_scenario_nfvi.flavors) | bool }}" when: - deploy_scenario_nfvi - set_fact: deploy_scenario_distro: "{{ (XCI_DISTRO in deploy_scenario_nfvi.distros) | bool }}" when: - deploy_scenario_nfvi - deploy_scenario_flavor when: deploy_scenario is defined - name: Fail if {{ DEPLOY_SCENARIO }} is not supported fail: msg: - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - ERROR! The {{ DEPLOY_SCENARIO }} scenario can't be deployed. This is because - the {{ XCI_NFVI }} NFVI 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 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