diff options
author | Markos Chandras <mchandras@suse.de> | 2018-03-15 16:51:37 +0000 |
---|---|---|
committer | Markos Chandras <mchandras@suse.de> | 2018-03-20 08:45:22 +0000 |
commit | 77ab4eeda0f42616c63fa3d3baef9063a1e5741e (patch) | |
tree | d7049fa3815d463d06a3a38016137e9884373416 | |
parent | c5d83347c1550efe2e7eb4e114ac2fc0a18f6e6a (diff) |
Add initial support for multiple infra deployers
bifrost is currently the only way to deploy the infrastructure but
in the future other solutions will be added so we need to do some
preparation for XCI integration.
Change-Id: I961dd42157c924d88747074ddba6a318f8b537ac
Signed-off-by: Markos Chandras <mchandras@suse.de>
-rwxr-xr-x | xci/config/user-vars | 9 | ||||
-rw-r--r-- | xci/infra/bifrost/README.md (renamed from bifrost/README.md) | 0 | ||||
-rw-r--r-- | xci/infra/bifrost/infra-provision.sh | 25 | ||||
-rw-r--r-- | xci/infra/bifrost/playbooks/bootstrap-bifrost.yml (renamed from xci/playbooks/bootstrap-bifrost.yml) | 8 | ||||
-rw-r--r-- | xci/infra/bifrost/playbooks/opnfv-virtual.yaml (renamed from bifrost/playbooks/opnfv-virtual.yaml) | 0 | ||||
-rwxr-xr-x | xci/infra/bifrost/scripts/bifrost-provision.sh (renamed from bifrost/scripts/bifrost-provision.sh) | 0 | ||||
-rwxr-xr-x | xci/infra/bifrost/scripts/destroy-env.sh (renamed from bifrost/scripts/destroy-env.sh) | 6 | ||||
-rwxr-xr-x | xci/xci-deploy.sh | 31 |
8 files changed, 50 insertions, 29 deletions
diff --git a/xci/config/user-vars b/xci/config/user-vars index c3b11e8e..1554777d 100755 --- a/xci/config/user-vars +++ b/xci/config/user-vars @@ -35,6 +35,15 @@ export XCI_CEPH_ENABLED=${XCI_CEPH_ENABLED:-false} export INSTALLER_TYPE=${INSTALLER_TYPE:-osa} #------------------------------------------------------------------------------- +# Set DEPLOYMENT +#------------------------------------------------------------------------------- +# Currently, there is a single infra deployment method: bifrost +# Examples: +# export INFRA_DEPLOYMENT="bifrost" +export INFRA_DEPLOYMENT=${INFRA_DEPLOYMENT:-bifrost} + + +#------------------------------------------------------------------------------- # Configure some other stuff #------------------------------------------------------------------------------- # Set the verbosity for ansible diff --git a/bifrost/README.md b/xci/infra/bifrost/README.md index 60d07244..60d07244 100644 --- a/bifrost/README.md +++ b/xci/infra/bifrost/README.md diff --git a/xci/infra/bifrost/infra-provision.sh b/xci/infra/bifrost/infra-provision.sh new file mode 100644 index 00000000..f847e66d --- /dev/null +++ b/xci/infra/bifrost/infra-provision.sh @@ -0,0 +1,25 @@ +#------------------------------------------------------------------------------- +# Start provisioning VM nodes +#------------------------------------------------------------------------------- +# This playbook +# - removes directories that were created by the previous xci run +# - clones opnfv/releng-xci and openstack/bifrost repositories +# - combines opnfv/releng-xci and openstack/bifrost scripts/playbooks +# - destroys VMs, removes ironic db, leases, logs +# - creates and provisions VMs for the chosen flavor +#------------------------------------------------------------------------------- +BIFROST_ROOT_DIR="$(dirname $(realpath ${BASH_SOURCE[0]}))" + +echo "Info: Starting provisining VM nodes using openstack/bifrost" +echo "-------------------------------------------------------------------------" +# We are using sudo so we need to make sure that env_reset is not present +sudo sed -i "s/^Defaults.*env_reset/#&/" /etc/sudoers +cd $BIFROST_ROOT_DIR +sudo -E bash ./scripts/destroy-env.sh +cd $BIFROST_ROOT_DIR/playbooks/ +ansible-playbook ${XCI_ANSIBLE_PARAMS} -i "localhost," bootstrap-bifrost.yml +cd ${XCI_CACHE}/repos/bifrost +bash ./scripts/bifrost-provision.sh +echo "-----------------------------------------------------------------------" +echo "Info: VM nodes are provisioned!" +echo "-----------------------------------------------------------------------" diff --git a/xci/playbooks/bootstrap-bifrost.yml b/xci/infra/bifrost/playbooks/bootstrap-bifrost.yml index 8b8bb30d..23eb976c 100644 --- a/xci/playbooks/bootstrap-bifrost.yml +++ b/xci/infra/bifrost/playbooks/bootstrap-bifrost.yml @@ -11,11 +11,11 @@ connection: local gather_facts: true vars_files: - - ../var/opnfv.yml + - "{{ XCI_PATH }}/xci/var/opnfv.yml" pre_tasks: - name: Load distribution variables include_vars: - file: ../var/{{ ansible_os_family }}.yml + file: "{{ XCI_PATH }}/xci/var/{{ ansible_os_family }}.yml" roles: - role: clone-repository project: "opnfv/bifrost" @@ -26,7 +26,7 @@ tasks: - name: Load distribution variables include_vars: - file: ../var/{{ ansible_os_family }}.yml + file: "{{ XCI_PATH }}/xci/var/{{ ansible_os_family }}.yml" - name: Synchronize local development bifrost repository to XCI paths # command module is much faster than the copy module synchronize: @@ -38,5 +38,5 @@ - OPENSTACK_BIFROST_DEV_PATH != "" - name: combine opnfv/releng-xci and openstack/bifrost scripts/playbooks copy: - src: "{{ XCI_PATH}}/bifrost/" + src: "{{ XCI_PATH}}/xci/infra/bifrost/" dest: "{{ XCI_CACHE }}/repos/bifrost" diff --git a/bifrost/playbooks/opnfv-virtual.yaml b/xci/infra/bifrost/playbooks/opnfv-virtual.yaml index f44adb4d..f44adb4d 100644 --- a/bifrost/playbooks/opnfv-virtual.yaml +++ b/xci/infra/bifrost/playbooks/opnfv-virtual.yaml diff --git a/bifrost/scripts/bifrost-provision.sh b/xci/infra/bifrost/scripts/bifrost-provision.sh index 67d5e2d8..67d5e2d8 100755 --- a/bifrost/scripts/bifrost-provision.sh +++ b/xci/infra/bifrost/scripts/bifrost-provision.sh diff --git a/bifrost/scripts/destroy-env.sh b/xci/infra/bifrost/scripts/destroy-env.sh index 73c0222b..9d53dc15 100755 --- a/bifrost/scripts/destroy-env.sh +++ b/xci/infra/bifrost/scripts/destroy-env.sh @@ -36,8 +36,10 @@ fi # Destroy all XCI VMs if the previous operation failed [[ -n ${XCI_FLAVOR} ]] && \ for vm in ${TEST_VM_NODE_NAMES}; do - virsh destroy $vm || true - virsh undefine $vm || true + if which virsh &>/dev/null; then + virsh destroy $vm || true + virsh undefine $vm || true + fi done service ironic-conductor stop || true diff --git a/xci/xci-deploy.sh b/xci/xci-deploy.sh index 3d5854a4..fb678ec5 100755 --- a/xci/xci-deploy.sh +++ b/xci/xci-deploy.sh @@ -66,6 +66,8 @@ source "$XCI_PATH/xci/installer/${INSTALLER_TYPE}/env" &>/dev/null || true source $XCI_PATH/xci/config/env-vars # Make sure we pass XCI_PATH everywhere export XCI_ANSIBLE_PARAMS+=" -e XCI_PATH=${XCI_PATH}" +# Make sure everybody knows where our global roles are +export ANSIBLE_ROLES_PATH="$HOME/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:${XCI_PATH}/xci/playbooks/roles" if [[ -z $(echo $PATH | grep "$HOME/.local/bin") ]]; then export PATH="$HOME/.local/bin:$PATH" @@ -92,10 +94,12 @@ echo "-------------------------------------------------------------------------" echo "OPNFV scenario: $DEPLOY_SCENARIO" echo "xci flavor: $XCI_FLAVOR" echo "xci installer: $INSTALLER_TYPE" +echo "infra deployment: $INFRA_DEPLOYMENT" echo "opnfv/releng-xci version: $(git rev-parse HEAD)" echo "openstack/bifrost version: $OPENSTACK_BIFROST_VERSION" [[ "$INSTALLER_TYPE" == "osa" ]] && echo "openstack/openstack-ansible version: $OPENSTACK_OSA_VERSION" [[ "$INSTALLER_TYPE" == "kubespray" ]] && echo "kubespray version: $KUBESPRAY_VERSION" +[[ "$INFRA_DEPLOYMENT" == "bifrost" ]] && echo "bifrost version: $OPENSTACK_BIFROST_VERSION" echo "-------------------------------------------------------------------------" #------------------------------------------------------------------------------- @@ -123,29 +127,10 @@ echo "-------------------------------------------------------------------------" #------------------------------------------------------------------------------- source $(find $XCI_SCENARIOS_CACHE/${DEPLOY_SCENARIO} -name xci_overrides) &>/dev/null || : -#------------------------------------------------------------------------------- -# Start provisioning VM nodes -#------------------------------------------------------------------------------- -# This playbook -# - removes directories that were created by the previous xci run -# - clones opnfv/releng-xci and openstack/bifrost repositories -# - combines opnfv/releng-xci and openstack/bifrost scripts/playbooks -# - destroys VMs, removes ironic db, leases, logs -# - creates and provisions VMs for the chosen flavor -#------------------------------------------------------------------------------- -echo "Info: Starting provisining VM nodes using openstack/bifrost" -echo "-------------------------------------------------------------------------" -# We are using sudo so we need to make sure that env_reset is not present -sudo sed -i "s/^Defaults.*env_reset/#&/" /etc/sudoers -cd $XCI_PATH/bifrost/ -sudo -E bash ./scripts/destroy-env.sh -cd $XCI_PLAYBOOKS -ansible-playbook ${XCI_ANSIBLE_PARAMS} -i "localhost," bootstrap-bifrost.yml -cd ${XCI_CACHE}/repos/bifrost -bash ./scripts/bifrost-provision.sh -echo "-----------------------------------------------------------------------" -echo "Info: VM nodes are provisioned!" -echo "-----------------------------------------------------------------------" +# Deploy infrastructure based on the selected deloyment method +echo "Info: Deploying hardware using '${INFRA_DEPLOYMENT}'" +echo "---------------------------------------------------" +source ${XCI_PATH}/xci/infra/${INFRA_DEPLOYMENT}/infra-provision.sh # Deploy OpenStack on the selected installer echo "Info: Deploying '${INSTALLER_TYPE}' installer" |