diff --git a/scripts/bootstrap-ansible.sh b/scripts/bootstrap-ansible.sh index ea4844a431..dfdc8cfcf6 100755 --- a/scripts/bootstrap-ansible.sh +++ b/scripts/bootstrap-ansible.sh @@ -70,20 +70,13 @@ case ${DISTRO_ID} in ubuntu) apt-get update DEBIAN_FRONTEND=noninteractive apt-get -y install \ - git python-all python-dev curl python2.7-dev build-essential \ - libssl-dev libffi-dev netcat python-requests python-openssl python-pyasn1 \ - python-netaddr python-prettytable python-crypto python-yaml \ - python-virtualenv + git python3-all python3-dev curl python3.5-dev build-essential \ + libssl-dev libffi-dev netcat python3-requests python3-openssl python3-pyasn1 \ + python3-netaddr python3-prettytable python3-crypto python3-yaml \ + python3-virtualenv ;; esac -# NOTE(mhayden): Ubuntu 16.04 needs python-ndg-httpsclient for SSL SNI support. -# This package is not needed in Ubuntu 14.04 and isn't available -# there as a package. -if [[ "${DISTRO_ID}" == 'ubuntu' ]] && [[ "${DISTRO_VERSION_ID}" == '16.04' ]]; then - DEBIAN_FRONTEND=noninteractive apt-get -y install python-ndg-httpsclient -fi - # Install pip get_pip @@ -96,7 +89,7 @@ elif [ -n "$HTTP_PROXY" ]; then fi # Figure out the version of python is being used -PYTHON_EXEC_PATH="$(which python2 || which python)" +PYTHON_EXEC_PATH="$(which python3 || which python2 || which python)" PYTHON_VERSION="$($PYTHON_EXEC_PATH -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')" # Use https when Python with native SNI support is available @@ -106,6 +99,12 @@ UPPER_CONSTRAINTS_PROTO=$([ "$PYTHON_VERSION" == $(echo -e "$PYTHON_VERSION\n2.7 export UPPER_CONSTRAINTS_FILE=${UPPER_CONSTRAINTS_FILE:-"$UPPER_CONSTRAINTS_PROTO://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?id=$(awk '/requirements_git_install_branch:/ {print $2}' playbooks/defaults/repo_packages/openstack_services.yml)"} # Create a Virtualenv for the Ansible runtime +if [ -f "/opt/ansible-runtime/bin/python" ]; then + VENV_PYTHON_VERSION="$(/opt/ansible-runtime/bin/python -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')" + if [ "$PYTHON_VERSION" != "$VENV_PYTHON_VERSION" ]; then + rm -rf /opt/ansible-runtime + fi +fi virtualenv --clear ${VIRTUALENV_OPTIONS} --python="${PYTHON_EXEC_PATH}" /opt/ansible-runtime # The vars used to prepare the Ansible runtime venv diff --git a/tests/roles/bootstrap-host/vars/ubuntu.yml b/tests/roles/bootstrap-host/vars/ubuntu.yml index 916115e93a..324c22ee2b 100644 --- a/tests/roles/bootstrap-host/vars/ubuntu.yml +++ b/tests/roles/bootstrap-host/vars/ubuntu.yml @@ -23,7 +23,9 @@ packages_install: - linux-image-extra-{{ ansible_kernel }} - lvm2 - python2.7 + - python-crypto - python-dev + - python-yaml - sshpass - tmux - vim