Add initial support for multiple infra deployers 47/53947/4
authorMarkos Chandras <mchandras@suse.de>
Thu, 15 Mar 2018 16:51:37 +0000 (16:51 +0000)
committerMarkos Chandras <mchandras@suse.de>
Tue, 20 Mar 2018 08:45:22 +0000 (08:45 +0000)
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>
xci/config/user-vars
xci/infra/bifrost/README.md [moved from bifrost/README.md with 100% similarity]
xci/infra/bifrost/infra-provision.sh [new file with mode: 0644]
xci/infra/bifrost/playbooks/bootstrap-bifrost.yml [moved from xci/playbooks/bootstrap-bifrost.yml with 86% similarity]
xci/infra/bifrost/playbooks/opnfv-virtual.yaml [moved from bifrost/playbooks/opnfv-virtual.yaml with 100% similarity]
xci/infra/bifrost/scripts/bifrost-provision.sh [moved from bifrost/scripts/bifrost-provision.sh with 100% similarity]
xci/infra/bifrost/scripts/destroy-env.sh [moved from bifrost/scripts/destroy-env.sh with 95% similarity]
xci/xci-deploy.sh

index c3b11e8..1554777 100755 (executable)
@@ -34,6 +34,15 @@ export XCI_CEPH_ENABLED=${XCI_CEPH_ENABLED:-false}
 #    export INSTALLER_TYPE="kubespray"
 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
 #-------------------------------------------------------------------------------
diff --git a/xci/infra/bifrost/infra-provision.sh b/xci/infra/bifrost/infra-provision.sh
new file mode 100644 (file)
index 0000000..f847e66
--- /dev/null
@@ -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 "-----------------------------------------------------------------------"
similarity index 86%
rename from xci/playbooks/bootstrap-bifrost.yml
rename to xci/infra/bifrost/playbooks/bootstrap-bifrost.yml
index 8b8bb30..23eb976 100644 (file)
   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"
similarity index 95%
rename from bifrost/scripts/destroy-env.sh
rename to xci/infra/bifrost/scripts/destroy-env.sh
index 73c0222..9d53dc1 100755 (executable)
@@ -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
index 3d5854a..fb678ec 100755 (executable)
@@ -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"