diff --git a/templates/etc/nginx/sites-available/_nagios3.j2 b/templates/etc/nginx/sites-available/_nagios3.j2 index cd2a743..e49b0ac 100644 --- a/templates/etc/nginx/sites-available/_nagios3.j2 +++ b/templates/etc/nginx/sites-available/_nagios3.j2 @@ -1,7 +1,7 @@ {% extends "_base.j2" %} {% block root %} - root /usr/share/nagios3/htdocs; + root {{ nginx_nagios_root }}; {% endblock %} {% block template_try_files %} @@ -17,21 +17,27 @@ } location /stylesheets { - alias /etc/nagios3/stylesheets; +{% if nginx_nagios_stylesheets is defined %} + alias {{ nginx_nagios_stylesheets }}; +{% endif %} expires 60d; } {% endblock %} {% block template_upstream_location %} +{% if ansible_distribution == 'Debian' %} location /cgi-bin/nagios3 { root /usr/lib; +{% elif ansible_distribution == 'FreeBSD' %} + location /cgi-bin { +{% endif %} 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_pass unix:{{ nginx_fcgiwrap_sock }}; fastcgi_param AUTH_USER $remote_user; fastcgi_param REMOTE_USER $remote_user; } diff --git a/tests/includes/post_FreeBSD.yml b/tests/includes/post_FreeBSD.yml index cd21505..f301181 100644 --- a/tests/includes/post_FreeBSD.yml +++ b/tests/includes/post_FreeBSD.yml @@ -1,2 +1,31 @@ --- +- name: APT | Install web apps + pkgng: pkg={{ item }} state=present + with_items: + - nagios + - backuppc + +- name: COMMAND | Activate backuppc config + command: > + cp /usr/local/etc/backuppc/config.pl.sample /usr/local/etc/backuppc/config.pl + creates=/usr/local/etc/backuppc/config.pl + +- name: FILE | Fix backuppc permissions + file: > + path=/usr/local/etc/backuppc/config.pl + owner=backuppc + group=backuppc + +- name: FILE | Fix fcgiwrap permission + file: > + path={{ nginx_fcgiwrap_sock }} + mode=0640 + owner={{ nginx_user }} + group={{ nginx_user }} + +# +# We don't manage BackupPC on FreeBSD... too dirty. :/ +# +#- name: SERVICE | Ensure backuppc is started +# service: name=backuppc state=started enabled=yes diff --git a/tests/test.yml b/tests/test.yml index fb178e6..4ba11fe 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -262,6 +262,7 @@ changed_when: false register: authbpc failed_when: authbpc.stdout.find('BackupPC Server Status') == -1 + when: ansible_distribution != 'FreeBSD' # -------------------------------- # Nagios @@ -272,7 +273,7 @@ register: nagios_php failed_when: nagios_php.stdout.find('Nagios Core') == -1 - name: -- VERIFY NAGIOS3 CGI -- - command: "curl -u nagiosadmin:nagios -H 'Host: nagios3.local' http://127.0.0.1/cgi-bin/nagios3/summary.cgi" + command: "curl -u nagiosadmin:nagios -H 'Host: nagios3.local' http://127.0.0.1/cgi-bin{% if ansible_distribution == 'Debian' %}/nagios3{% endif %}/summary.cgi" changed_when: false register: nagios_cgi failed_when: nagios_cgi.stdout.find('Nagios Event Summary') == -1 diff --git a/vars/Debian.yml b/vars/Debian.yml index 4f7c86f..ac83d51 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -1,3 +1,8 @@ nginx_events_use: 'epoll' nginx_pid: '/run/nginx.pid' nginx_etc_dir: '/etc/nginx' + +# Specific vhosts +nginx_nagios_root: '/usr/share/nagios3/htdocs' +nginx_nagios_stylesheets: '/etc/nagios3/stylesheets' +nginx_fcgiwrap_sock: '/var/run/fcgiwrap.socket' diff --git a/vars/FreeBSD.yml b/vars/FreeBSD.yml index 96da262..02c757b 100644 --- a/vars/FreeBSD.yml +++ b/vars/FreeBSD.yml @@ -2,4 +2,6 @@ nginx_events_use: 'kqueue' nginx_pid: '/var/run/nginx.pid' nginx_etc_dir: '/usr/local/etc/nginx' -# TODO: it's a dirty to force variable here! +# Specific vhosts +nginx_nagios_root: '/usr/local/www/nagios' +nginx_fcgiwrap_sock: '/var/run/fcgiwrap/fcgiwrap.sock'