Skip to content
Permalink
Browse files

[ci] Add tests for Ansible local fact scripts

  • Loading branch information...
drybjed committed Aug 11, 2019
1 parent 7fac942 commit 9bd53f6cfd419e5c6824d71a9c9d3493f21fd687
Showing with 16 additions and 0 deletions.
  1. +1 −0 Vagrantfile
  2. +15 −0 lib/tests/jane
@@ -284,6 +284,7 @@ export CI_JOB_ID="#{ENV['CI_JOB_ID']}"
export CI_JOB_NAME="#{ENV['CI_JOB_NAME']}"
export CI_JOB_STAGE="#{ENV['CI_JOB_STAGE']}"
export JANE_TEST_PLAY="#{ENV['JANE_TEST_PLAY']}"
export JANE_TEST_FACT="#{ENV['JANE_TEST_FACT']}"
export JANE_FORCE_TESTS="#{ENV['JANE_FORCE_TESTS']}"
export JANE_INVENTORY_DIRS="#{ENV['JANE_INVENTORY_DIRS']}"
export JANE_INVENTORY_GROUPS="#{ENV['JANE_INVENTORY_GROUPS']}"
@@ -64,6 +64,7 @@ readonly JANE_DIFF_PATTERN="${JANE_DIFF_PATTERN:-.*}"
readonly JANE_LOG_PATTERN="${JANE_LOG_PATTERN:-}"
readonly JANE_FORCE_TESTS="${JANE_FORCE_TESTS:-}"
readonly JANE_TEST_PLAY="${JANE_TEST_PLAY:-}"
readonly JANE_TEST_FACT="${JANE_TEST_FACT:-}"
readonly JANE_ANSIBLE_CONFIG="${JANE_ANSIBLE_CONFIG:-/vagrant/lib/tests/ansible.cfg}"
readonly JANE_ANSIBLE_INVENTORY="${JANE_ANSIBLE_INVENTORY:-/vagrant/lib/tests/jane}"
readonly JANE_INVENTORY_DIRS="${JANE_INVENTORY_DIRS:-common}"
@@ -346,6 +347,7 @@ sub__ansible__playbook () {
local ANSIBLE_CONFIG="${JANE_ANSIBLE_CONFIG}"
local ANSIBLE_INVENTORY="${JANE_ANSIBLE_INVENTORY}"
local jane_test_play="${JANE_TEST_PLAY}"
local jane_test_fact="${JANE_TEST_FACT}"
local inventory_path
IFS=':' read -r -a inventory_path <<< "${INVENTORY_PATH}"
local jane_inventory_dirs
@@ -410,6 +412,19 @@ sub__ansible__playbook () {
else
status_msg ok "The playbook is idempotent"
fi

if [ -n "${jane_test_fact}" ] ; then
local fact_script="/etc/ansible/facts.d/${jane_test_fact%.fact}.fact"
if [ -f "${fact_script}" ] ; then
if [ -x "${fact_script}" ] ; then
status_msg info "Executing the '${jane_test_fact%.fact}' Ansible local fact script..."
"${fact_script}"
else
status_msg info "Contents of the '${jane_test_fact}' local fact:"
cat "${fact_script}"
fi
fi
fi
}


0 comments on commit 9bd53f6

Please sign in to comment.
You can’t perform that action at this time.