bifrost: Use virtual environment for bifrost 11/42011/2
authorMarkos Chandras <mchandras@suse.de>
Tue, 12 Sep 2017 21:57:31 +0000 (15:57 -0600)
committerFatih Degirmenci <fatih.degirmenci@ericsson.com>
Fri, 15 Sep 2017 16:02:09 +0000 (16:02 +0000)
bifrost forces us to use an old Ansible version which means we can't
take advantage of new features in XCI playbooks. As such, we move the
entire bifrost step to a virtual environment so we can have a newer
version of Ansible on the host.

Change-Id: I94874d600a29247b7826324cc111901995df90dc
Signed-off-by: Markos Chandras <mchandras@suse.de>
bifrost/scripts/bifrost-provision.sh

index ad02807..0cca82d 100755 (executable)
@@ -17,7 +17,7 @@ ANSIBLE_INSTALL_ROOT=${ANSIBLE_INSTALL_ROOT:-/opt/stack}
 ANSIBLE_VERBOSITY=${ANSIBLE_VERBOSITY-"-vvvv"}
 ENABLE_VENV="false"
 USE_DHCP="false"
-USE_VENV="false"
+USE_VENV="true"
 BUILD_IMAGE=true
 PROVISION_WAIT_TIMEOUT=${PROVISION_WAIT_TIMEOUT:-3600}
 
@@ -67,6 +67,21 @@ export DIB_OS_PACKAGES=${DIB_OS_PACKAGES:-"vlan,vim,less,bridge-utils,language-p
 # Additional dib elements
 export EXTRA_DIB_ELEMENTS=${EXTRA_DIB_ELEMENTS:-"openssh-server"}
 
+if [ ${USE_VENV} = "true" ]; then
+    export VENV=/opt/stack/bifrost
+    $SCRIPT_HOME/env-setup.sh
+    # 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
+    ANSIBLE=${HOME}/.local/bin/ansible-playbook
+fi
+
 # Source Ansible
 set +x +o nounset
 $SCRIPT_HOME/env-setup.sh