Improve tests (#90)

* Update .travis.yml

* Create Travis build matrix

* Add nginx-modules.yml test playbook to Travis build matrix

* Improve template test playbook

* Change HTML template variables from Ansible to NGINX variables
This commit is contained in:
Alessandro Fael Garcia 2019-01-21 12:19:30 +01:00 committed by GitHub
parent fdfff7efca
commit 1d3b03ea2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 278 additions and 125 deletions

View File

@ -2,124 +2,196 @@
sudo: required sudo: required
services: services:
- docker - docker
env: matrix:
- distribution: centos include:
version: 6 - env:
playbook: basic distribution: centos
- distribution: centos version: 6
version: 6 playbook: basic
playbook: push - env:
- distribution: centos distribution: centos
version: 6 version: 6
playbook: stable playbook: modules
- distribution: centos - env:
version: 6 distribution: centos
playbook: template version: 6
- distribution: centos playbook: push
version: 6 - env:
playbook: unit distribution: centos
- distribution: centos version: 6
version: 7 playbook: stable
playbook: basic - env:
- distribution: centos distribution: centos
version: 7 version: 6
playbook: template playbook: template
- distribution: centos - env:
version: 7 distribution: centos
playbook: stable version: 6
- distribution: centos playbook: unit
version: 7 - env:
playbook: push distribution: centos
- distribution: centos version: 7
version: 7 playbook: basic
playbook: unit - env:
- distribution: debian distribution: centos
version: jessie version: 7
playbook: basic playbook: modules
- distribution: debian - env:
version: jessie distribution: centos
playbook: template version: 7
- distribution: debian playbook: push
version: jessie - env:
playbook: stable distribution: centos
- distribution: debian version: 7
version: jessie playbook: template
playbook: push - env:
- distribution: debian distribution: centos
version: jessie version: 7
playbook: unit playbook: stable
- distribution: debian - env:
version: stretch distribution: centos
playbook: basic version: 7
- distribution: debian playbook: unit
version: stretch - env:
playbook: template distribution: debian
- distribution: debian version: jessie
version: stretch playbook: basic
playbook: stable - env:
- distribution: debian distribution: debian
version: stretch version: jessie
playbook: push playbook: modules
- distribution: debian - env:
version: stretch distribution: debian
playbook: unit version: jessie
- distribution: ubuntu playbook: push
version: trusty - env:
playbook: basic distribution: debian
- distribution: ubuntu version: jessie
version: trusty playbook: template
playbook: template - env:
- distribution: ubuntu distribution: debian
version: trusty version: jessie
playbook: stable playbook: stable
- distribution: ubuntu - env:
version: trusty distribution: debian
playbook: push version: jessie
- distribution: ubuntu playbook: unit
version: xenial - env:
playbook: basic distribution: debian
- distribution: ubuntu version: stretch
version: xenial playbook: basic
playbook: template - env:
- distribution: ubuntu distribution: debian
version: xenial version: stretch
playbook: stable playbook: modules
- distribution: ubuntu - env:
version: xenial distribution: debian
playbook: push version: stretch
- distribution: ubuntu playbook: push
version: xenial - env:
playbook: unit distribution: debian
- distribution: ubuntu version: stretch
version: artful playbook: template
playbook: basic - env:
- distribution: ubuntu distribution: debian
version: artful version: stretch
playbook: push playbook: stable
- distribution: ubuntu - env:
version: artful distribution: debian
playbook: stable version: stretch
- distribution: ubuntu playbook: unit
version: artful - env:
playbook: template distribution: ubuntu
- distribution: ubuntu version: trusty
version: artful playbook: basic
playbook: unit - env:
- distribution: ubuntu distribution: ubuntu
version: bionic version: trusty
playbook: basic playbook: modules
- distribution: ubuntu - env:
version: bionic distribution: ubuntu
playbook: push version: trusty
- distribution: ubuntu playbook: push
version: bionic - env:
playbook: stable distribution: ubuntu
- distribution: ubuntu version: trusty
version: bionic playbook: template
playbook: template - env:
- distribution: ubuntu distribution: ubuntu
version: bionic version: trusty
playbook: unit playbook: stable
- env:
distribution: ubuntu
version: xenial
playbook: basic
- env:
distribution: ubuntu
version: xenial
playbook: modules
- env:
distribution: ubuntu
version: xenial
playbook: push
- env:
distribution: ubuntu
version: xenial
playbook: template
- env:
distribution: ubuntu
version: xenial
playbook: stable
- env:
distribution: ubuntu
version: xenial
playbook: unit
- env:
distribution: ubuntu
version: artful
playbook: basic
- env:
distribution: ubuntu
version: artful
playbook: modules
- env:
distribution: ubuntu
version: artful
playbook: push
- env:
distribution: ubuntu
version: artful
playbook: stable
- env:
distribution: ubuntu
version: artful
playbook: template
- env:
distribution: ubuntu
version: artful
playbook: unit
- env:
distribution: ubuntu
version: bionic
playbook: basic
- env:
distribution: ubuntu
version: bionic
playbook: modules
- env:
distribution: ubuntu
version: bionic
playbook: push
- env:
distribution: ubuntu
version: bionic
playbook: stable
- env:
distribution: ubuntu
version: bionic
playbook: template
- env:
distribution: ubuntu
version: bionic
playbook: unit
before_install: before_install:
- 'sudo docker pull ${distribution}:${version}' - 'sudo docker pull ${distribution}:${version}'
- 'sudo docker build --no-cache --rm --file=tests/dockerfiles/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests' - 'sudo docker build --no-cache --rm --file=tests/dockerfiles/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'

View File

@ -154,8 +154,6 @@ nginx_main_template:
# Enable creating dynamic templated NGINX HTTP configuration files. # Enable creating dynamic templated NGINX HTTP configuration files.
# Defaults will not produce a valid configuration. Instead they are meant to showcase # Defaults will not produce a valid configuration. Instead they are meant to showcase
# the options available for templating. Each key represents a new configuration file. # the options available for templating. Each key represents a new configuration file.
# Comment out load_balancer or web_server depending on whether you wish to create a web server
# or load balancer configuration file.
nginx_http_template_enable: false nginx_http_template_enable: false
nginx_http_template: nginx_http_template:
default: default:

View File

@ -81,8 +81,8 @@ clearTimeout(ref);
<img alt="NGINX Logo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWAAAABICAMAAAD/N9+RAAAAVFBMVEUAAAAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQAAmQDBect+AAAAG3RSTlMAB0AY8SD5SM82v1npsJ/YjSl0EVLftqllgMdZgsoQAAAHd0lEQVR42szZ6XabMBCG4ZGFxSazLzZz//fZc9I4JpbEN8LQ0/dnGwJ5DJGG0HdpM9kkuzVXiqussmRpLrRdnwqDp9ePyY7zXdFbqptHOz00RTVUxWiyquvJ26Upknp2/heWN0Uyzt3qYtKMn805ybsW/LdK01YVC6sVELH81XJ9o6j5q6Qkcepe83dJp8ipf161HSgm1TyP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n0S4M8J7i7ROq1lhCVHzzwGvBpYbJ5AOEgq4EEzZn5K01MrmqvNOmDTLrft+8FSRzQecFBpO05p26tlnw7oIso14YnJ3i5aL6DF0wMuleqkM4Qn+smcAKRTL1Y65UDQVAO+WK2+7gTplH54usjWAXek+K+LCuxEwGMLul0R4EPFfz8L18zzKmDxIKSCN95LIuBGr3GujpevErqxGQDuLaPuyUAfBAPGg6Mx4OME2DhQVgUJWAIzQnBFfRAeMI5N1XEjBBiwjCxg0+qHYG7wt/GA8capDh+CqYkpCoykjPKWesio2gywEwD4qDEuDNjUJGCptQqUAB5MB3w1APBhg4gYsPQtCbib00Zpi3wrwM1FAOBjR2lrZBXCARY3J623bAS4yAQAPnIYHAOWkgSc2xS+T7MV4CAA8LF2BhiwBAwYP4+lPBsBdgIAH2XIgQHjTf+SrRw5auEAG5Dg9ID3t5TBgM3EWR88eMAVCVieYM5aDXgHUyQAmKiZR9nIFckJC/gFnALUgHew9QKAiZq5A3+EXspDAw7gP64GvIcxXQvfHl2B7tiozSf+y1JSNQ31gRYDQb6HteKQ4B3s4QucflRrDW8OKiHBujCO3s0u5qAjwKR0vnkDozL1emgd5W6EWa1ud7l97G0n3jhYzACOEMlHtVpjeBA/mLf/7IOoQsa7y+b7GDR3Rbw98fKQLy+5xv7VIXowIhy1ztUfbdzLYrz7cbrvRb/K+nf7wPPQpAXsEQ/7l2AXW97/AGkCwaNsIif8zU3y5eZaO/mK/jKDV1s872/Fz11K5TLE1zzEiP1km8ndDMcj3JvmFfqdvubhD8TgHPiN+LViAAAAAElFTkSuQmCC"/>
<div class="info"> <div class="info">
<p><span>Web Server name:</span> <span> {{ item.value.web_server_name }} </span></p> <p><span>Web Server name:</span> <span> {{ item.value.web_server_name }} </span></p>
<p><span>Server name:</span> <span> {{ ansible_hostname }} </span></p> <p><span>Server name:</span> <span>server_hostname</span></p>
<p><span>Server address:</span> <span> {{ ansible_eth0.ipv4.address }} </span></p> <p><span>Server address:</span> <span>server_address</span></p>
<p><span>User Agent:</span> <span><small>client_browser</small></span></p> <p><span>User Agent:</span> <span><small>client_browser</small></span></p>
<p class="smaller"><span>URI:</span> <span>server_url</span></p> <p class="smaller"><span>URI:</span> <span>server_url</span></p>
<p class="smaller"><span>Doc Root:</span> <span>document_root</span></p> <p class="smaller"><span>Doc Root:</span> <span>document_root</span></p>

View File

@ -0,0 +1,15 @@
---
- hosts: localhost
become: true
remote_user: root
roles:
- ansible-role-nginx
vars:
nginx_modules:
njs: true
perl: true
waf: false
geoip: true
image_filter: true
rtmp: true
xslt: true

View File

@ -7,19 +7,87 @@
vars: vars:
nginx_http_template_enable: true nginx_http_template_enable: true
nginx_http_template: nginx_http_template:
default: app:
template_file: http/default.conf.j2 template_file: http/default.conf.j2
conf_file_name: default.conf conf_file_name: default.conf
conf_file_location: /etc/nginx/conf.d/ conf_file_location: /etc/nginx/conf.d/
port: 80 port: 80
server_name: localhost server_name: localhost
error_page: /usr/share/nginx/html error_page: /usr/share/nginx/html
reverse_proxy:
locations:
frontend:
location: /
proxy_pass: http://frontend_servers/
backend:
location: /backend
proxy_pass: http://backend_servers/
upstreams:
upstream_1:
name: frontend_servers
lb_method: least_conn
zone_name: frontend
zone_size: 64k
sticky_cookie: false
servers:
frontend_server_1:
address: localhost
port: 8081
weight: 1
health_check: max_fails=3 fail_timeout=5s
upstream_2:
name: backend_servers
lb_method: least_conn
zone_name: backend
zone_size: 64k
sticky_cookie: false
servers:
backend_server_1:
address: localhost
port: 8082
weight: 1
health_check: max_fails=3 fail_timeout=5s
frontend:
template_file: http/default.conf.j2
conf_file_name: frontend_default.conf
conf_file_location: /etc/nginx/conf.d/
port: 8081
server_name: localhost
error_page: /usr/share/nginx/html
autoindex: false autoindex: false
web_server: web_server:
locations: locations:
default: default:
location: / location: /
html_file_location: /usr/share/nginx/html html_file_location: /usr/share/nginx/html
html_file_name: index.html html_file_name: frontend_index.html
autoindex: false autoindex: false
http_demo_conf: false http_demo_conf: true
backend:
template_file: http/default.conf.j2
conf_file_name: backend_default.conf
conf_file_location: /etc/nginx/conf.d/
port: 8082
server_name: localhost
error_page: /usr/share/nginx/html
autoindex: false
web_server:
locations:
default:
location: /
html_file_location: /usr/share/nginx/html
html_file_name: backend_index.html
autoindex: false
http_demo_conf: true
nginx_html_demo_template_enable: true
nginx_html_demo_template:
frontend:
template_file: www/index.html.j2
html_file_name: frontend_index.html
html_file_location: /usr/share/nginx/html
web_server_name: Frontend
backend:
template_file: www/index.html.j2
html_file_name: backend_index.html
html_file_location: /usr/share/nginx/html
web_server_name: Backend