From fa45db18d3a30df4cd1d1a67009af7aa61b4bf3f Mon Sep 17 00:00:00 2001 From: Theo Chatzimichos Date: Nov 15 2017 18:04:12 +0000 Subject: bin/prepare_test_show_highstate_env.sh: make the secrets stripping optional --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fc218b2..aa8c169 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,7 @@ test_custom_grains: test_show_highstate_against_upstream_formulas: stage: test before_script: - - bin/prepare_test_show_highstate_env.sh + - bin/prepare_test_show_highstate_env.sh -s - bin/get_formulas.py -c -d /srv/formula -s script: bin/test_show_highstate.sh allow_failure: true @@ -34,7 +34,7 @@ test_show_highstate_against_forked_formulas: # TODO: get rid of GIT_SSL_NO_VERIFY as soon as we switch to letsencrypt wildcard certs GIT_SSL_NO_VERIFY: 'true' before_script: - - bin/prepare_test_show_highstate_env.sh + - bin/prepare_test_show_highstate_env.sh -s - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' --clone-branch production script: bin/test_show_highstate.sh tags: diff --git a/bin/prepare_test_show_highstate_env.sh b/bin/prepare_test_show_highstate_env.sh index 1f08bd7..b3ba14b 100755 --- a/bin/prepare_test_show_highstate_env.sh +++ b/bin/prepare_test_show_highstate_env.sh @@ -13,6 +13,25 @@ if [[ $(whoami) != 'root' ]]; then fi fi +help() { + echo "Prepares the CI runner or workstation environment to run the show_highstate tests" + echo + echo "Arguments:" + echo + echo "-s Strip out secrets files (CI runner can't read them)" + echo +} + +[[ $1 == '--help' ]] && help && exit + +while getopts sh arg; do + case ${arg} in + s) STRIP_SECRETS=1 ;; + h) help && exit ;; + *) help && exit 1 ;; + esac +done + $SUDO zypper -qn in --no-recommends salt git python3 python3-PyYAML $SUDO rm -rf /srv/{salt,pillar} $SUDO ln -s $PWD/salt /srv/salt @@ -22,4 +41,4 @@ ROLES=$(bin/get_roles.py --yaml) printf "city:\ncountry:\ndomain: infra.opensuse.org\nosfullname:\nosmajorrelease:\nosrelease_info:\n$ROLES\nsalt_cluster: opensuse\nvirt_cluster:" | $SUDO tee /etc/salt/grains > /dev/null sed -i -e 's/^production:$/base:/' /srv/{salt,pillar}/top.sls touch pillar/id/${ID//./_}.sls -sed -i -e "s#\- secrets\..*#- id.${ID//./_}#g" $(grep -lr "\- secrets\.") +[[ -n $STRIP_SECRETS ]] && sed -i -e "s#\- secrets\..*#- id.${ID//./_}#g" $(grep -lr "\- secrets\." pillar)