From 7db49d7d280e551fa869e65d01f60193ee716061 Mon Sep 17 00:00:00 2001 From: Christian Boltz Date: Dec 22 2022 13:19:54 +0000 Subject: Merge branch 'cboltz-nginx-conftest' into production https://gitlab.infra.opensuse.org/infra/salt/-/merge_requests/600 --- diff --git a/bin/test_nginx.sh b/bin/test_nginx.sh index 5a9cdba..70d80aa 100755 --- a/bin/test_nginx.sh +++ b/bin/test_nginx.sh @@ -71,6 +71,7 @@ cp -a /etc/nginx /etc/nginx_orig WEB_ROLES=( $(bin/get_roles.py) ) for role in ${WEB_ROLES[@]}; do + rolestatus=0 if grep nginx salt/role/$role.sls > /dev/null; then echo_INFO "Testing role: $role" reset_nginx @@ -78,7 +79,20 @@ for role in ${WEB_ROLES[@]}; do salt-call --local -l quiet state.apply role.$role > /dev/null create_fake_certs touch_includes $role - if $(nginx -tq); then + + # test config file syntax + nginx -tq || rolestatus=1 + + # make sure all vhost config files are named *.conf (without that suffix, they get ignored) + for file in /etc/nginx/vhosts.d/* ; do + test "$file" == "/etc/nginx/vhosts.d/*" && continue # skip loop if no file exists in vhosts.d/ + echo "$file" | grep -q '\.conf$' || { + echo "ERROR: $file is not named *.conf" + rolestatus=1 + } + done + + if test $rolestatus = 0; then echo_PASSED else echo_FAILED