From b2be073da6d7899f860893984a5e96e30bcc3c72 Mon Sep 17 00:00:00 2001 From: Logan V Date: Fri, 12 May 2017 15:26:44 -0500 Subject: [PATCH] Isolate ansible-runtime venv site packages In the isolated ansible-runtime venv, we were inheriting the system site packages inside the virtualenv. This breaks the openstack-ansible wrapper because it always assumes that ansible is installed in the ansible-runtime venv. When ansible is already installed on the system, pip does not reinstall it in the venv because it is inherited from the system, so the wrapper fails. This fix also includes a PATH entry in the openstack-ansible wrapper which will make the wrapper more resilient against bugs like this in the future. Change-Id: Ifa5234cf7353f1443c5b77787363d8880b5cf0b6 Closes-Bug: #1690447 (cherry picked from commit 3bec543022099d38c702a9a047ef80a69b3b61e9) --- playbooks/inventory/host_vars/localhost.yml | 16 ++++++++++++++++ scripts/bootstrap-ansible.sh | 8 ++++---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 playbooks/inventory/host_vars/localhost.yml diff --git a/playbooks/inventory/host_vars/localhost.yml b/playbooks/inventory/host_vars/localhost.yml new file mode 100644 index 0000000000..3117a238e5 --- /dev/null +++ b/playbooks/inventory/host_vars/localhost.yml @@ -0,0 +1,16 @@ +--- +# Copyright 2017, Logan Vig +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ansible_python_interpreter: /usr/bin/python diff --git a/scripts/bootstrap-ansible.sh b/scripts/bootstrap-ansible.sh index 61a0916b00..336e3b8750 100755 --- a/scripts/bootstrap-ansible.sh +++ b/scripts/bootstrap-ansible.sh @@ -105,7 +105,7 @@ 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 -virtualenv --clear ${VIRTUALENV_OPTIONS} --system-site-packages --python="${PYTHON_EXEC_PATH}" /opt/ansible-runtime +virtualenv --clear ${VIRTUALENV_OPTIONS} --python="${PYTHON_EXEC_PATH}" /opt/ansible-runtime # The vars used to prepare the Ansible runtime venv PIP_OPTS+=" --upgrade" @@ -166,7 +166,7 @@ cat > /usr/local/bin/openstack-ansible <