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
This commit is contained in:
parent
ca826b02ae
commit
3bec543022
16
playbooks/inventory/host_vars/localhost.yml
Normal file
16
playbooks/inventory/host_vars/localhost.yml
Normal file
@ -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
|
@ -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 <<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
|
||||
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user