diff --git a/templates/etc/nginx/sites-available/_nagios3.j2 b/templates/etc/nginx/sites-available/_nagios3.j2 index b9ea7d0..cd2a743 100644 --- a/templates/etc/nginx/sites-available/_nagios3.j2 +++ b/templates/etc/nginx/sites-available/_nagios3.j2 @@ -5,7 +5,6 @@ {% endblock %} {% block template_try_files %} - try_files $uri $uri/; {% endblock %} {% block template_index %} @@ -21,18 +20,18 @@ alias /etc/nagios3/stylesheets; expires 60d; } - location /nagios3 { - alias /usr/share/nagios3/htdocs; - } {% endblock %} {% block template_upstream_location %} - location ~ \.cgi$ { - alias /usr/lib/cgi-bin/nagios3; - gzip off; - include /etc/nginx/fastcgi_params; + location /cgi-bin/nagios3 { + root /usr/lib; + try_files $uri =404; +{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %} + include fastcgi_params; +{% else %} + include fastcgi.conf; +{% endif %} fastcgi_pass unix:/var/run/fcgiwrap.socket; - fastcgi_param SCRIPT_FILENAME /usr/lib/cgi-bin/nagios3$fastcgi_script_name; fastcgi_param AUTH_USER $remote_user; fastcgi_param REMOTE_USER $remote_user; } diff --git a/tests/test.yml b/tests/test.yml index c6cd0f9..9c620a2 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -34,6 +34,11 @@ state: 'absent' - name: 'hanx' password: 'qwerty' + - name: 'nagios' + description: 'Please login to Nagios!' + users: + - name: 'nagiosadmin' + password: 'nagios' - name: 'deleteme' description: 'Please login!' users: [] @@ -145,7 +150,7 @@ htpasswd: 'hello' - name: 'nagios3.local' template: '_nagios3' - htpasswd: 'hello' + htpasswd: 'nagios' - name: 'test-ssl.local' proto: ['http', 'https'] template: '_base' @@ -215,13 +220,20 @@ changed_when: false register: authbpc failed_when: authbpc.stdout.find('BackupPC Server Status') == -1 + +# -------------------------------- +# Nagios +# -------------------------------- - name: -- VERIFY NAGIOS3 PHP -- - command: "curl -u hanx:qwerty -H 'Host: nagios3.local' http://127.0.0.1/side.php" + command: "curl -u nagiosadmin:nagios -H 'Host: nagios3.local' http://127.0.0.1/side.php" changed_when: false - failed_when: authok.stdout.find('Nagios Core') != -1 + register: nagios_php + failed_when: nagios_php.stdout.find('Nagios Core') == -1 - name: -- VERIFY NAGIOS3 CGI -- - command: "curl -u hanx:qwerty -H 'Host: nagios3.local' http://127.0.0.1/side.php" + command: "curl -u nagiosadmin:nagios -H 'Host: nagios3.local' http://127.0.0.1/cgi-bin/nagios3/summary.cgi" changed_when: false + register: nagios_cgi + failed_when: nagios_cgi.stdout.find('Nagios Event Summary') == -1 - name: -- VERIFY SSL -- command: "curl --insecure -H 'Host: {{ item }}' https://127.0.0.1/" changed_when: false