61d65c76a6
The tripleo_compute_node is a "meta" role that imports the compute node standalone playbooks for the purposes of molecule testing. The molecule default scenario executes the standalone playbooks against a podman in podman container with systemd as the process, in order to simulate a compute node. Change-Id: I14408ad4d2e4fb4ae265a105af18a876158200dc Signed-off-by: James Slagle <jslagle@redhat.com>
112 lines
4.3 KiB
Bash
Executable File
112 lines
4.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright 2019 Red Hat, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# 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.
|
|
|
|
|
|
## Shell Opts ----------------------------------------------------------------
|
|
|
|
set -o pipefail
|
|
set -xeuo
|
|
|
|
## Vars ----------------------------------------------------------------------
|
|
|
|
export PROJECT_DIR="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../"
|
|
export ROLE_NAME="${ROLE_NAME:-$1}"
|
|
export TRIPLEO_JOB_ANSIBLE_ARGS=${TRIPLEO_JOB_ANSIBLE_ARGS:-""}
|
|
export TOX_CONSTRAINTS_FILE=${TOX_CONSTRAINTS_FILE:-"https://releases.openstack.org/constraints/upper/master"}
|
|
|
|
# NOTE(cloudnull): Disable ansible compat check, caters to the case where
|
|
# system ansible may be installed.
|
|
export ANSIBLE_SKIP_CONFLICT_CHECK=1
|
|
|
|
## Functions -----------------------------------------------------------------
|
|
|
|
function run_pip {
|
|
"${HOME}/test-python/bin/pip" install \
|
|
-c "${TOX_CONSTRAINTS_FILE}" \
|
|
-c "${PROJECT_DIR}/ansible-requirements.txt" \
|
|
-r "${PROJECT_DIR}/requirements.txt" \
|
|
-r "${PROJECT_DIR}/test-requirements.txt" \
|
|
-r "${PROJECT_DIR}/molecule-requirements.txt" ${@:-}
|
|
# Required by authorized_key module used in tripleo_ansible/playbooks/prepare-test-host.yml
|
|
"${HOME}/test-python/bin/ansible-galaxy" collection install ansible.posix
|
|
}
|
|
|
|
## Main ----------------------------------------------------------------------
|
|
|
|
# Source distribution information
|
|
source /etc/os-release || source /usr/lib/os-release
|
|
RHT_PKG_MGR=$(command -v dnf || command -v yum)
|
|
PYTHON_EXEC=$(command -v python3 || command -v python)
|
|
|
|
# Install the requirements we need to run local tests
|
|
sudo dnf -y install gcc
|
|
case "${ID,,}" in
|
|
amzn|fedora)
|
|
sudo "${RHT_PKG_MGR}" install -y python*-virtualenv
|
|
;;
|
|
rhel|centos)
|
|
# Virtualenv no longer packaged for RHEL/CentOS 9. We will have to use
|
|
# system pip to install it.
|
|
sudo dnf -y install python*-pip
|
|
sudo pip install virtualenv
|
|
;;
|
|
esac
|
|
|
|
# Ensure the required ci file is presnet
|
|
sudo mkdir -p /etc/ci
|
|
sudo touch /etc/ci/mirror_info.sh
|
|
|
|
# Create a virtual env
|
|
"${PYTHON_EXEC}" -m virtualenv --system-site-packages "${HOME}/test-python"
|
|
|
|
# Run bindep
|
|
"${HOME}/test-python/bin/pip" install pip setuptools bindep --upgrade
|
|
"${PROJECT_DIR}/scripts/bindep-install"
|
|
|
|
# Install local requirements
|
|
if [[ -d "${HOME}/.cache/pip/wheels" ]]; then
|
|
rm -rf "${HOME}/.cache/pip/wheels"
|
|
fi
|
|
run_pip
|
|
|
|
# NOTE(cloudnull): In some cases ansible will not be installed due to wheel
|
|
# building issues, caused by pip. If this happens we
|
|
# re-install the packages with the force flag, which will
|
|
# ensure everything is rebuilt and installed correctly.
|
|
if [ ! -f "${HOME}/test-python/bin/ansible" ]; then
|
|
run_pip --force
|
|
fi
|
|
|
|
# Display list of installed packages with versions (debugging failures)
|
|
"${HOME}/test-python/bin/pip" freeze
|
|
|
|
# Ensure we don't keep any dangling sudo session in the shell
|
|
sudo -k
|
|
|
|
# Run local test
|
|
PS1="[\u@\h \W]\$" source "${HOME}/test-python/bin/activate"
|
|
source "${PROJECT_DIR}/ansible-test-env.rc"
|
|
export ANSIBLE_ROLES_PATH="${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles"
|
|
ansible-playbook -i "${PROJECT_DIR}/tests/hosts.ini" \
|
|
-e "tripleo_src=$(realpath --relative-to="${HOME}" "${PROJECT_DIR}")" \
|
|
-e "tripleo_role_name=${ROLE_NAME}" \
|
|
-e "tripleo_job_ansible_args='${TRIPLEO_JOB_ANSIBLE_ARGS}'" \
|
|
-e "ansible_user=${USER}" \
|
|
-e "ansible_user_dir=${HOME}" \
|
|
"${PROJECT_DIR}/tripleo_ansible/playbooks/prepare-test-host.yml" \
|
|
"${PROJECT_DIR}/zuul.d/playbooks/run-local.yml" \
|
|
-v
|