From fb0487945c680d1a0168493cf35ecd98572dab62 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Wed, 28 Mar 2018 18:23:22 +0200 Subject: [PATCH] Add runme script to foreman inventory tests --- .../targets/foreman_inventory/runme.sh | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 test/integration/targets/foreman_inventory/runme.sh diff --git a/test/integration/targets/foreman_inventory/runme.sh b/test/integration/targets/foreman_inventory/runme.sh new file mode 100755 index 0000000000..c9ca14a49a --- /dev/null +++ b/test/integration/targets/foreman_inventory/runme.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +[[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x + +set -euo pipefail + +export ANSIBLE_CONFIG=ansible.cfg +export FOREMAN_HOST="${FOREMAN_HOST:-localhost}" +export FOREMAN_PORT="${FOREMAN_PORT:-8080}" +FOREMAN_CONFIG=test-config.foreman.yaml + +# flag for checking whether cleanup has already fired +_is_clean= + +function _cleanup() { + [[ -n "$_is_clean" ]] && return # don't double-clean + echo Cleanup: removing $FOREMAN_CONFIG... + rm -vf "$FOREMAN_CONFIG" + unset ANSIBLE_CONFIG + unset FOREMAN_HOST + unset FOREMAN_PORT + unset FOREMAN_CONFIG + _is_clean=1 +} +trap _cleanup INT TERM EXIT + +cat > "$FOREMAN_CONFIG" <