From a3b26d9b48c04c51b15807184ace868294dbe7f9 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 11 Oct 2017 15:13:04 +0100 Subject: xci: xci-deploy.sh: Allow scenarios to overrides XCI variables. Scenario may want to override variables exported by the XCI so allow them to define their own 'xci_overrides' file in the root directory of the role to do so. Change-Id: I6648eb43831a2aecc08d745a8c0fc191ce56e1b2 Signed-off-by: Markos Chandras --- xci/xci-deploy.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xci/xci-deploy.sh b/xci/xci-deploy.sh index d73cf5cd..1e70d0dd 100755 --- a/xci/xci-deploy.sh +++ b/xci/xci-deploy.sh @@ -128,6 +128,13 @@ fi # TODO: The xci playbooks can be put into a playbook which will be done later. +#------------------------------------------------------------------------------- +# Get scenario variables overrides +#------------------------------------------------------------------------------- +if [[ -f $XCI_PATH/scenarios/${OPNFV_SCENARIO:-_no_scenario_}/xci_overrides ]]; then + source $XCI_PATH/scenarios/$OPNFV_SCENARIO/xci_overrides +fi + #------------------------------------------------------------------------------- # Start provisioning VM nodes #------------------------------------------------------------------------------- -- cgit 1.2.3-korg From 4c1be188401e8cf3aa7ff818f1e285756f2a4d7c Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 12 Oct 2017 09:11:59 +0100 Subject: xci: Clone all XCI scenarios in advance similar to a-r-r In order to plug the scenarios' roles properly, we need to have all roles physically present in advance. As such, add a opnfv-scenario-requirements.yml file which can be used to populate the roles directory with all the scenarios. Change-Id: I0cdadb63849e4565c31559817660d23217879053 Signed-off-by: Markos Chandras --- xci/opnfv-scenario-requirements.yml | 18 +++++++ xci/playbooks/get-opnfv-scenario-requirements.yml | 61 +++++++++++++++++++++++ xci/playbooks/roles/.gitignore | 8 +++ xci/xci-deploy.sh | 14 +++++- 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 xci/opnfv-scenario-requirements.yml create mode 100644 xci/playbooks/get-opnfv-scenario-requirements.yml create mode 100644 xci/playbooks/roles/.gitignore diff --git a/xci/opnfv-scenario-requirements.yml b/xci/opnfv-scenario-requirements.yml new file mode 100644 index 00000000..ee9b2baf --- /dev/null +++ b/xci/opnfv-scenario-requirements.yml @@ -0,0 +1,18 @@ +--- +# SPDX-license-identifier: Apache-2.0 +############################################################################## +# Copyright (c) 2017 SUSE LINUX GmbH and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +# +# OPNFV scenarios participating in XCI must create their own entry in this file so +# XCI can make use of them. +# +- scenario: os-odl-sfc + scm: git + src: https://gerrit.opnfv.org/gerrit/sfc + version: master + role: scenarios/os-odl-sfc/role/os-odl-sfc diff --git a/xci/playbooks/get-opnfv-scenario-requirements.yml b/xci/playbooks/get-opnfv-scenario-requirements.yml new file mode 100644 index 00000000..23aa1d41 --- /dev/null +++ b/xci/playbooks/get-opnfv-scenario-requirements.yml @@ -0,0 +1,61 @@ +--- +# 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 + tasks: + - name: Remove target directory + file: + path: "{{ item.path | default(scenario_path_default) + '/' + item.scenario }}" + state: absent + when: + - item.scm == "git" or item.scm is undefined + with_items: "{{ scenarios }}" + + - name: Clone git repos (with git) + git: + repo: "{{ item.src }}" + dest: "{{ item.path | default(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 }}" + + - name: Plug in the roles to XCI + file: + state: link + src: "{{ item.path | default(scenario_path_default) }}/{{ item.scenario | default(item.src | basename) }}/{{ item.role }}" + dest: "{{ role_path_default }}/{{ item.scenario }}" + force: yes + with_items: "{{ scenarios }}" + + vars: + ansible_python_interpreter: "/usr/bin/python" + scenarios: "{{ lookup('file', scenario_file) | from_yaml }}" + scenario_file: '../opnfv-scenario-requirements.yml' + scenario_path_default: "{{ lookup('env', 'XCI_PATH') }}/.cache/repos/scenarios" + role_path_default: "{{ playbook_dir }}/roles" + git_clone_retries: 2 + git_clone_retry_delay: 5 diff --git a/xci/playbooks/roles/.gitignore b/xci/playbooks/roles/.gitignore new file mode 100644 index 00000000..e0b47770 --- /dev/null +++ b/xci/playbooks/roles/.gitignore @@ -0,0 +1,8 @@ +* +!.gitignore +!clone-repository/ +!configure-network/ +!configure-nfs/ +!prepare-functest/ +!remote-folders/ +!synchronize-time/ diff --git a/xci/xci-deploy.sh b/xci/xci-deploy.sh index 1e70d0dd..d33e0c80 100755 --- a/xci/xci-deploy.sh +++ b/xci/xci-deploy.sh @@ -50,7 +50,7 @@ fi # override any of them. #------------------------------------------------------------------------------- # find where are we -XCI_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +export XCI_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # source user vars source $XCI_PATH/config/user-vars # source pinned versions @@ -128,6 +128,18 @@ fi # TODO: The xci playbooks can be put into a playbook which will be done later. +# Clone OPNFV scenario repositories +#------------------------------------------------------------------------------- +# This playbook +# - removes existing scenario roles +# - clones OPNFV scenario roles based on the file/opnfv-scenario-requirements.yml file +#------------------------------------------------------------------------------- +echo "Info: Cloning OPNFV scenario repositories" +echo "-------------------------------------------------------------------------" +cd $XCI_PATH/playbooks +ansible-playbook ${XCI_ANSIBLE_VERBOSITY} -i inventory get-opnfv-scenario-requirements.yml +echo "-------------------------------------------------------------------------" + #------------------------------------------------------------------------------- # Get scenario variables overrides #------------------------------------------------------------------------------- -- cgit 1.2.3-korg From 481f9031ff8cd0a3b0692c110af6c8e2d04460da Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 12 Oct 2017 09:50:38 +0100 Subject: xci: playbooks: Add generic playbook for scenarios to plug their roles The new bootstrap-scenarios.yml playbook is aimed to be used by scenarios to configure themselves right before we proceed with the bootstrapping. This way we can avoid having scenario specific stuff into the generic code. Change-Id: I3026013719a50458c65405439712270f25f569ff Signed-off-by: Markos Chandras --- xci/playbooks/bootstrap-scenarios.yml | 10 ++++++++++ xci/playbooks/configure-opnfvhost.yml | 1 + 2 files changed, 11 insertions(+) create mode 100644 xci/playbooks/bootstrap-scenarios.yml diff --git a/xci/playbooks/bootstrap-scenarios.yml b/xci/playbooks/bootstrap-scenarios.yml new file mode 100644 index 00000000..e7bd7dc9 --- /dev/null +++ b/xci/playbooks/bootstrap-scenarios.yml @@ -0,0 +1,10 @@ +--- +# +# This file is aimed to be used by scenarios to plug into the XCI. +# Ideally, all they need to do at this point is to include their +# role using a statement like the following one +# +# - name: Include foobar role +# include_role: +# name: "foobar" +# when: OPNFV_SCENARIO == "foobar" diff --git a/xci/playbooks/configure-opnfvhost.yml b/xci/playbooks/configure-opnfvhost.yml index faae623f..798fe522 100644 --- a/xci/playbooks/configure-opnfvhost.yml +++ b/xci/playbooks/configure-opnfvhost.yml @@ -98,6 +98,7 @@ shell: "/bin/cp -rf {{OPNFV_RELENG_PATH}}/xci/file/openstack_services.yml {{OPENSTACK_OSA_PATH}}/playbooks/defaults/repo_packages/openstack_services.yml" when: - OPENSTACK_OSA_VERSION != "master" + - include: bootstrap-scenarios.yml - name: bootstrap ansible on opnfv host command: "/bin/bash ./scripts/bootstrap-ansible.sh" args: -- cgit 1.2.3-korg