Fix tests for Debian Stretch

- nagios is not available
- curl can use HTTP2 (headers are lowercase)
- bypass tests when htpasswd is empty (bypass issue #28)
pull/35/head
Emilien Mantel 2017-07-27 14:25:22 +02:00
parent 6935404939
commit e83395271d
2 changed files with 61 additions and 44 deletions

View File

@ -1,11 +1,19 @@
--- ---
- name: APT | Install web apps - name: APT | Install webapps
apt: pkg={{ item }} state=present install_recommends=no apt:
pkg: "{{ item }}"
state: present
install_recommends: no
with_items: with_items:
- backuppc - backuppc
- nagios3
# - owncloud # - owncloud
- name: APT | Install nagios3 (only on old Debian releases)
apt:
pkg: nagios3
state: present
when: ansible_distribution_major_version < 9
- name: SERVICE | Ensure backuppc is started - name: SERVICE | Ensure backuppc is started
service: name=backuppc state=started service: name=backuppc state=started

View File

@ -316,35 +316,40 @@
# -------------------------------- # --------------------------------
# Basic Auth # Basic Auth
# -------------------------------- # --------------------------------
- name: -- VERIFY AUTH BASIC NONE --
command: "curl -H 'Host: test-htpasswd.local' http://127.0.0.1/hello/"
changed_when: false
register: authnone
failed_when: authnone.stdout.find('401 Authorization Required') == -1
- name: -- VERIFY AUTH BASIC FAIL -- - block:
command: "curl -u fail:fail -H 'Host: test-htpasswd.local' http://127.0.0.1/hello/"
changed_when: false
register: authfail
failed_when: authfail.stdout.find('401 Authorization Required') == -1
- name: -- VERIFY AUTH BASIC OK -- - name: -- VERIFY AUTH BASIC NONE --
command: "curl -u hanx:qwerty -H 'Host: test-htpasswd.local' http://127.0.0.1/hello/" command: "curl -H 'Host: test-htpasswd.local' http://127.0.0.1/hello/"
changed_when: false changed_when: false
register: authok register: authnone
failed_when: authok.stdout.find('hello') == -1 failed_when: authnone.stdout.find('401 Authorization Required') == -1
- name: -- VERIFY AUTH BASIC FAIL GLOBAL -- - name: -- VERIFY AUTH BASIC FAIL --
command: "curl -u fail:fail -H 'Host: test-htpasswd-all.local' http://127.0.0.1/" command: "curl -u fail:fail -H 'Host: test-htpasswd.local' http://127.0.0.1/hello/"
changed_when: false changed_when: false
register: authgfail register: authfail
failed_when: authgfail.stdout.find('401 Authorization Required') == -1 failed_when: authfail.stdout.find('401 Authorization Required') == -1
- name: -- VERIFY AUTH BASIC OK -- - name: -- VERIFY AUTH BASIC OK --
command: "curl -u hanx:qwerty -H 'Host: test-htpasswd-all.local' http://127.0.0.1/" command: "curl -u hanx:qwerty -H 'Host: test-htpasswd.local' http://127.0.0.1/hello/"
changed_when: false changed_when: false
register: authgok register: authok
failed_when: authgok.stdout.find('401 Authorization Required') != -1 failed_when: authok.stdout.find('hello') == -1
- name: -- VERIFY AUTH BASIC FAIL GLOBAL --
command: "curl -u fail:fail -H 'Host: test-htpasswd-all.local' http://127.0.0.1/"
changed_when: false
register: authgfail
failed_when: authgfail.stdout.find('401 Authorization Required') == -1
- name: -- VERIFY AUTH BASIC OK --
command: "curl -u hanx:qwerty -H 'Host: test-htpasswd-all.local' http://127.0.0.1/"
changed_when: false
register: authgok
failed_when: authgok.stdout.find('401 Authorization Required') != -1
when: nginx_htpasswd | length > 0
# -------------------------------- # --------------------------------
# BackupPC # BackupPC
@ -357,19 +362,23 @@
when: ansible_distribution != 'FreeBSD' when: ansible_distribution != 'FreeBSD'
# -------------------------------- # --------------------------------
# Nagios # Nagios (not avaiblable on Debian >= 9)
# -------------------------------- # --------------------------------
- name: -- VERIFY NAGIOS3 PHP -- - block:
command: "curl -u nagiosadmin:nagios -H 'Host: nagios3.local' http://127.0.0.1/side.php"
changed_when: false
register: nagios_php
failed_when: nagios_php.stdout.find('Nagios Core') == -1
- name: -- VERIFY NAGIOS3 CGI -- - name: -- VERIFY NAGIOS3 PHP --
command: "curl -u nagiosadmin:nagios -H 'Host: nagios3.local' http://127.0.0.1/cgi-bin{% if ansible_distribution == 'Debian' %}/nagios3{% endif %}/summary.cgi" command: "curl -u nagiosadmin:nagios -H 'Host: nagios3.local' http://127.0.0.1/side.php"
changed_when: false changed_when: false
register: nagios_cgi register: nagios_php
failed_when: nagios_cgi.stdout.find('Nagios Event Summary') == -1 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{% if ansible_distribution == 'Debian' %}/nagios3{% endif %}/summary.cgi"
changed_when: false
register: nagios_cgi
failed_when: nagios_cgi.stdout.find('Nagios Event Summary') == -1
when: ansible_distribution_major_version < 9
# -------------------------------- # --------------------------------
# Owncloud # Owncloud
@ -425,7 +434,7 @@
register: vdefault register: vdefault
failed_when: > failed_when: >
vdefault.stdout.find('Index HTML test OK') == -1 or vdefault.stdout.find('Index HTML test OK') == -1 or
vdefault.stderr.find('X-ansible-default') == -1 vdefault.stderr.lower().find('x-ansible-default') == -1
- name: -- VERIFY DEFAULT SSL SITE -- - name: -- VERIFY DEFAULT SSL SITE --
command: "curl --insecure -v https://127.0.0.1/" command: "curl --insecure -v https://127.0.0.1/"
@ -433,26 +442,26 @@
register: defaultssl register: defaultssl
failed_when: > failed_when: >
defaultssl.stdout.find('Index HTML test OK') == -1 or defaultssl.stdout.find('Index HTML test OK') == -1 or
defaultssl.stderr.find('X-ansible-default') == -1 defaultssl.stderr.lower().find('x-ansible-default') == -1
- name: -- VERIFY NOT DEFAULT SITE -- - name: -- VERIFY NOT DEFAULT SITE --
command: "curl -v -H 'Host: test-php.local' http://127.0.0.1/" command: "curl -v -H 'Host: test-php.local' http://127.0.0.1/"
changed_when: false changed_when: false
register: vphp register: vphp
failed_when: vphp.stderr.find('X-ansible-default') != -1 failed_when: vphp.stderr.lower().find('x-ansible-default') != -1
- name: -- VERIFY NOT DEFAULT SSL SITE -- - name: -- VERIFY NOT DEFAULT SSL SITE --
command: "curl --insecure -v -H 'Host: test-ssl.local' https://127.0.0.1/" command: "curl --insecure -v -H 'Host: test-ssl.local' https://127.0.0.1/"
changed_when: false changed_when: false
register: notdefaultssl register: notdefaultssl
failed_when: notdefaultssl.stderr.find('X-ansible-default') != -1 failed_when: notdefaultssl.stderr.lower().find('x-ansible-default') != -1
- name: -- VERIFY DEFAULT SITE + STUB_STATUS -- - name: -- VERIFY DEFAULT SITE + STUB_STATUS --
command: "curl -v http://127.0.0.1/status" command: "curl -v http://127.0.0.1/status"
changed_when: false changed_when: false
register: vdefault_status register: vdefault_status
failed_when: > failed_when: >
vdefault_status.stderr.find('X-ansible-default') == -1 or vdefault_status.stderr.lower().find('x-ansible-default') == -1 or
vdefault_status.stdout.find('Active connections') == -1 vdefault_status.stdout.find('Active connections') == -1
# -------------------------------- # --------------------------------