Skip to content

Commit

Permalink
Isolate ansible-runtime venv site packages
Browse files Browse the repository at this point in the history
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
  • Loading branch information
logan2211 committed May 14, 2017
1 parent ca826b0 commit 3bec543
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
16 changes: 16 additions & 0 deletions playbooks/inventory/host_vars/localhost.yml
@@ -0,0 +1,16 @@
---
# Copyright 2017, Logan Vig <logan2211@gmail.com>
#
# 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
8 changes: 4 additions & 4 deletions scripts/bootstrap-ansible.sh
Expand Up @@ -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"
Expand Down Expand Up @@ -166,7 +166,7 @@ cat > /usr/local/bin/openstack-ansible <<EOF
# OpenStack wrapper tool to ease the use of ansible with multiple variable files.
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}"
export PATH="/opt/ansible-runtime/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}"
function info() {
if [ "\${ANSIBLE_NOCOLOR:-0}" -eq "1" ]; then
Expand Down Expand Up @@ -207,9 +207,9 @@ fi
# Execute the Ansible command.
if [ "\${RUN_CMD}" == "openstack-ansible" ] || [ "\${RUN_CMD}" == "ansible-playbook" ]; then
/opt/ansible-runtime/bin/ansible-playbook "\${@}" \${VAR1}
ansible-playbook "\${@}" \${VAR1}
else
/opt/ansible-runtime/bin/\${RUN_CMD} "\${@}"
\${RUN_CMD} "\${@}"
fi
EOF

Expand Down

0 comments on commit 3bec543

Please sign in to comment.