diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd5c302..ba49f36 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,7 @@ test_nginx: GIT_SSL_NO_VERIFY: 'true' before_script: - bin/prepare_test_highstate_env.sh -s -p nginx - - cp -rp /etc/nginx /etc/nginx_orig + - cp -a /etc/nginx /etc/nginx_orig - bin/get_formulas.py -c -d /srv/formula -s --clone-from 'https://gitlab.infra.opensuse.org/saltstack-formulas' --clone-branch production -f nginx script: bin/test_nginx.sh tags: diff --git a/bin/test_nginx.sh b/bin/test_nginx.sh index da601e4..6a70edc 100755 --- a/bin/test_nginx.sh +++ b/bin/test_nginx.sh @@ -2,19 +2,12 @@ # Validate the salt-generated nginx configs -if [[ $(whoami) != 'root' ]]; then - if [[ -f /usr/bin/sudo ]]; then - SUDO='/usr/bin/sudo' - else - echo 'Please install sudo first, or run this script as root' - exit 1 - fi -fi +[[ $(whoami) == 'root' ]] || { echo 'Please run this script as root'; exit 1; } reset_nginx() { rm -rf /etc/nginx cp -a /etc/nginx_orig /etc/nginx - printf "roles:\n- $role" | $SUDO tee /etc/salt/grains > /dev/null + printf "roles:\n- $role" > /etc/salt/grains } reset_ip() { @@ -35,7 +28,7 @@ create_fake_certs() { echo "pillar/role/$role.sls \"ssl_certificate_key: $key\" should have extension .key" STATUS=1 else - $SUDO cp test/fixtures/domain.key $key + cp test/fixtures/domain.key $key fi done @@ -45,7 +38,7 @@ create_fake_certs() { echo "pillar/role/$role.sls \"ssl_certificate: $cert\" should have extension .crt" STATUS=1 else - $SUDO cp test/fixtures/domain.crt $cert + cp test/fixtures/domain.crt $cert fi done } @@ -57,7 +50,7 @@ for role in ${WEB_ROLES[@]}; do echo "Testing role: $role" reset_nginx reset_ip - $SUDO salt-call --local -l quiet state.apply role.$role > /dev/null + salt-call --local -l quiet state.apply role.$role > /dev/null create_fake_certs if $(nginx -tq); then echo 'PASSED'