From 769162389d016903b067ec93593644eac1023415 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 26 Jun 2017 16:54:20 +0100 Subject: [PATCH] Ensure that role path is absolute Currently the role search path is relative to the current directory, which yields unpredictable results when playbooks are executed from unexpected paths. This ensures that the role path we want to set is absolute. Change-Id: I16c0789c99a253ac3fb25a5aeaad24e51e631b84 --- scripts/bootstrap-ansible.sh | 2 ++ scripts/openstack-ansible.rc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/bootstrap-ansible.sh b/scripts/bootstrap-ansible.sh index dbb66478f0..ea4844a431 100755 --- a/scripts/bootstrap-ansible.sh +++ b/scripts/bootstrap-ansible.sh @@ -49,6 +49,7 @@ export OSA_CLONE_DIR="$(pwd)" # Set the variable to the role file to be the absolute path ANSIBLE_ROLE_FILE="$(readlink -f "${ANSIBLE_ROLE_FILE}")" OSA_INVENTORY_PATH="$(readlink -f playbooks/inventory)" +OSA_PLAYBOOK_PATH="$(readlink -f playbooks)" # Create the ssh dir if needed ssh_key_create @@ -143,6 +144,7 @@ popd # Write the OSA Ansible rc file sed "s|OSA_INVENTORY_PATH|${OSA_INVENTORY_PATH}|g" scripts/openstack-ansible.rc > /usr/local/bin/openstack-ansible.rc +sed -i "s|OSA_PLAYBOOK_PATH|${OSA_PLAYBOOK_PATH}|g" /usr/local/bin/openstack-ansible.rc sed -i "s|OSA_GROUP_VARS_DIR|${OSA_CLONE_DIR}/group_vars/|g" /usr/local/bin/openstack-ansible.rc sed -i "s|OSA_HOST_VARS_DIR|${OSA_CLONE_DIR}/host_vars/|g" /usr/local/bin/openstack-ansible.rc diff --git a/scripts/openstack-ansible.rc b/scripts/openstack-ansible.rc index 97c057e28d..704f8644ea 100644 --- a/scripts/openstack-ansible.rc +++ b/scripts/openstack-ansible.rc @@ -19,7 +19,7 @@ export ANSIBLE_INVENTORY="${ANSIBLE_INVENTORY:-OSA_INVENTORY_PATH}" export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_PATH:-/openstack/log/ansible-logging/ansible.log}" mkdir -p "$(dirname ${ANSIBLE_LOG_PATH})" || unset ANSIBLE_LOG_PATH -export ANSIBLE_ROLES_PATH="${ANSIBLE_ROLES_PATH:-/etc/ansible/roles:roles}" +export ANSIBLE_ROLES_PATH="${ANSIBLE_ROLES_PATH:-/etc/ansible/roles:OSA_PLAYBOOK_PATH/roles}" export ANSIBLE_LIBRARY="${ANSIBLE_LIBRARY:-/etc/ansible/roles/plugins/library}" export ANSIBLE_LOOKUP_PLUGINS="${ANSIBLE_LOOKUP_PLUGINS:-/etc/ansible/roles/plugins/lookup}"