diff --git a/inventory/dynamic_inventory.py b/inventory/dynamic_inventory.py index d50940d5df..53abd91391 100755 --- a/inventory/dynamic_inventory.py +++ b/inventory/dynamic_inventory.py @@ -40,7 +40,7 @@ def args(arg_list): '--config', help='Path containing the user defined configuration files', required=False, - default=None + default=os.getenv('OSA_CONFIG_DIR', None) ) parser.add_argument( '--list', diff --git a/inventory/group_vars/all/all.yml b/inventory/group_vars/all/all.yml index 1c997c6c2b..2e203c9852 100644 --- a/inventory/group_vars/all/all.yml +++ b/inventory/group_vars/all/all.yml @@ -16,6 +16,9 @@ ## OpenStack Source Code Release openstack_release: "{{ lookup('env', 'OSA_VERSION') | default('undefined', true) }}" +## OpenStack Configuration directory +openstack_config_dir: "{{ lookup('env', 'OSA_CONFIG_DIR') | default('/etc/openstack_deploy') }}" + ## Verbosity Options debug: False diff --git a/inventory/group_vars/all/ceph.yml b/inventory/group_vars/all/ceph.yml index 2d334ab58a..facf594ecb 100644 --- a/inventory/group_vars/all/ceph.yml +++ b/inventory/group_vars/all/ceph.yml @@ -26,7 +26,7 @@ ceph_repository: community # ceph-ansible roles. It is defaulted in ceph_client but set here to keep the # OSA/ceph-ansible integrations in sync. ceph_stable_release: mimic -fetch_directory: /etc/openstack_deploy/ceph-fetch/ +fetch_directory: "{{ openstack_config_dir }}/ceph-fetch/" # tries to create /var/log/ceph as a directory and fails if the log link already # exists. we handle the log dir creation so this is not something we need # ceph-common to prepare for us. diff --git a/scripts/openstack-ansible.rc b/scripts/openstack-ansible.rc index 2450233c7c..8e8c45af14 100644 --- a/scripts/openstack-ansible.rc +++ b/scripts/openstack-ansible.rc @@ -12,9 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +export OSA_CONFIG_DIR="${OSA_CONFIG_DIR:-/etc/openstack_deploy}" + export ANSIBLE_RETRY_FILES_ENABLED="${ANSIBLE_RETRY_FILES_ENABLED:-False}" -export ANSIBLE_INVENTORY="${ANSIBLE_INVENTORY:-OSA_INVENTORY_PATH/dynamic_inventory.py,OSA_INVENTORY_PATH/inventory.ini,/etc/openstack_deploy/inventory.ini}" +export ANSIBLE_INVENTORY="${ANSIBLE_INVENTORY:-OSA_INVENTORY_PATH/dynamic_inventory.py,OSA_INVENTORY_PATH/inventory.ini,${OSA_CONFIG_DIR}/inventory.ini}" export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_PATH:-/openstack/log/ansible-logging/ansible.log}" mkdir -p "$(dirname ${ANSIBLE_LOG_PATH})" || unset ANSIBLE_LOG_PATH @@ -33,7 +35,7 @@ export ANSIBLE_GATHERING="${ANSIBLE_GATHERING:-smart}" export ANSIBLE_GATHER_SUBSET="${ANSIBLE_GATHER_SUBSET:-network,hardware,virtual}" export ANSIBLE_CACHE_PLUGIN="${ANSIBLE_CACHE_PLUGIN:-jsonfile}" -export ANSIBLE_CACHE_PLUGIN_CONNECTION="${ANSIBLE_CACHE_PLUGIN_CONNECTION:-/etc/openstack_deploy/ansible_facts}" +export ANSIBLE_CACHE_PLUGIN_CONNECTION="${ANSIBLE_CACHE_PLUGIN_CONNECTION:-${OSA_CONFIG_DIR}/ansible_facts}" export ANSIBLE_CACHE_PLUGIN_TIMEOUT="${ANSIBLE_CACHE_PLUGIN_TIMEOUT:-86400}" if [[ "${ANSIBLE_CACHE_PLUGIN}" == "memcached" ]];then diff --git a/scripts/openstack-ansible.sh b/scripts/openstack-ansible.sh index cbe677bd12..c368c987a7 100644 --- a/scripts/openstack-ansible.sh +++ b/scripts/openstack-ansible.sh @@ -38,17 +38,17 @@ if [[ "${PWD}" == *"OSA_CLONE_DIR"* ]] || [ "${RUN_CMD}" == "openstack-ansible" . /usr/local/bin/openstack-ansible.rc # Load userspace group vars - if [[ -d /etc/openstack_deploy/group_vars || -d /etc/openstack_deploy/host_vars ]]; then - if [[ ! -f /etc/openstack_deploy/inventory.ini ]]; then - echo '[all]' > /etc/openstack_deploy/inventory.ini + if [[ -d ${OSA_CONFIG_DIR}/group_vars || -d ${OSA_CONFIG_DIR}/host_vars ]]; then + if [[ ! -f ${OSA_CONFIG_DIR}/inventory.ini ]]; then + echo '[all]' > ${OSA_CONFIG_DIR}/inventory.ini fi fi # Check whether there are any user configuration files - if ls -1 /etc/openstack_deploy/user_*.yml &> /dev/null; then + if ls -1 ${OSA_CONFIG_DIR}/user_*.yml &> /dev/null; then # Discover the variable files. - VAR1="$(for i in $(ls /etc/openstack_deploy/user_*.yml); do echo -ne "-e @$i "; done)" + VAR1="$(for i in $(ls ${OSA_CONFIG_DIR}/user_*.yml); do echo -ne "-e @$i "; done)" # Provide information on the discovered variables. info "Variable files: \"${VAR1}\""