diff options
author | Markos Chandras <mchandras@suse.de> | 2018-03-20 17:28:50 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-03-20 17:28:50 +0000 |
commit | 346df57c53fde3795fbe675477cdb2c1a453b6f7 (patch) | |
tree | 9eb7a43cb3613e28f6a99c3f09c50bf6bc87839e | |
parent | c7fd1fe87d8ae59757cefc79fe73ef249dd7952c (diff) | |
parent | dd0ac7518cc1dd5790314b72bd671d65435c1912 (diff) |
Merge changes from topic 'allow-deployment-overrides'
* changes:
xci: infra: bifrost: Avoid installing Ansible twice
Add initial support for multiple infra deployers
-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) | 31 | ||||
-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, 54 insertions, 56 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..939acb58 100755 --- a/bifrost/scripts/bifrost-provision.sh +++ b/xci/infra/bifrost/scripts/bifrost-provision.sh @@ -13,11 +13,7 @@ set -o pipefail export PYTHONUNBUFFERED=1 SCRIPT_HOME="$(cd "$(dirname "$0")" && pwd)" BIFROST_HOME=$SCRIPT_HOME/.. -ANSIBLE_INSTALL_ROOT=${ANSIBLE_INSTALL_ROOT:-/opt/stack} ENABLE_VENV="false" -USE_DHCP="false" -USE_VENV="true" -BUILD_IMAGE=true PROVISION_WAIT_TIMEOUT=${PROVISION_WAIT_TIMEOUT:-3600} # This is normally exported by XCI env but we should initialize it here # in case we run this script on its own for debug purposes @@ -67,13 +63,6 @@ WRITE_INTERFACES_FILE=true export DIB_DEV_USER_PWDLESS_SUDO=yes export DIB_DEV_USER_PASSWORD=devuser -# Settings for distro: xenial/ubuntu-minimal, 7/centos7, 42.2/suse -export DIB_OS_RELEASE=${DIB_OS_RELEASE:-xenial} -export DIB_OS_ELEMENT=${DIB_OS_ELEMENT:-ubuntu-minimal} - -# DIB OS packages -export DIB_OS_PACKAGES=${DIB_OS_PACKAGES:-"vlan,vim,less,bridge-utils,language-pack-en,iputils-ping,rsyslog,curl"} - # Additional dib elements export EXTRA_DIB_ELEMENTS=${EXTRA_DIB_ELEMENTS:-"openssh-server"} @@ -103,20 +92,8 @@ if [[ -e ${XCI_PATH}/deployment_image.qcow2 ]]; then sudo mv ${XCI_PATH}/deployment_image.qcow2* /httpboot/ fi -if [ ${USE_VENV} = "true" ]; then - export VENV=/opt/stack/bifrost - $SCRIPT_HOME/env-setup.sh &>/dev/null - # Note(cinerama): activate is not compatible with "set -u"; - # disable it just for this line. - set +u - source ${VENV}/bin/activate - set -u - ANSIBLE=${VENV}/bin/ansible-playbook - ENABLE_VENV="true" -else - $SCRIPT_HOME/env-setup.sh &>/dev/null - ANSIBLE=${HOME}/.local/bin/ansible-playbook -fi +# Install missing dependencies +$(which pip) install -q --user --upgrade -r "$(dirname $0)/../requirements.txt" # Change working directory cd $BIFROST_HOME/playbooks @@ -132,7 +109,7 @@ if [[ -e /etc/centos-release ]]; then fi # Create the VMS -${ANSIBLE} ${XCI_ANSIBLE_PARAMS} \ +ansible-playbook ${XCI_ANSIBLE_PARAMS} \ -i inventory/localhost \ test-bifrost-create-vm.yaml \ -e test_vm_num_nodes=${TEST_VM_NUM_NODES} \ @@ -143,7 +120,7 @@ ${ANSIBLE} ${XCI_ANSIBLE_PARAMS} \ -e ${INVENTORY_FILE_FORMAT}=${BAREMETAL_DATA_FILE} # Execute the installation and VM startup test -${ANSIBLE} ${XCI_ANSIBLE_PARAMS} \ +ansible-playbook ${XCI_ANSIBLE_PARAMS} \ -i inventory/bifrost_inventory.py \ ${TEST_PLAYBOOK} \ -e use_cirros=${USE_CIRROS} \ 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" |