64 lines
1.9 KiB
YAML
64 lines
1.9 KiB
YAML
---
|
|
|
|
- hosts: all
|
|
pre_tasks:
|
|
- apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 state=present
|
|
with_items:
|
|
- php5-fpm
|
|
- curl
|
|
vars:
|
|
nginx_php: true
|
|
nginx_upstreams:
|
|
- name: 'test'
|
|
servers:
|
|
- path: '127.0.0.1:80'
|
|
max_conns: 150
|
|
weight: 10
|
|
down: false
|
|
nginx_vhosts:
|
|
- name:
|
|
- 'test.local'
|
|
- 'test-alias.local'
|
|
- 'test2-alias.local'
|
|
template: '_base'
|
|
override_try_files: '$uri $uri index.htm index.html'
|
|
manage_local_content: false
|
|
more:
|
|
- 'autoindex off;'
|
|
location:
|
|
'/test':
|
|
- 'return 403;'
|
|
'/gunther':
|
|
- 'return 404;'
|
|
- name: 'test-php.local'
|
|
upstream_params:
|
|
- 'fastcgi_param FOO bar;'
|
|
redirect_from:
|
|
- 'www.test-php.local'
|
|
template: '_php'
|
|
- name: 'test-proxy.local'
|
|
listen:
|
|
- 8080
|
|
template: '_proxy'
|
|
upstream_name: 'test'
|
|
- name: 'deleted.local'
|
|
template: '_base'
|
|
delete: true
|
|
roles:
|
|
- ../../
|
|
post_tasks:
|
|
- name: -- Add PHP file --
|
|
copy: dest="{{ nginx_root }}/test-php.local/public/index.php" content="<?php phpinfo();"
|
|
- name: -- Add HTML file --
|
|
copy: dest="{{ nginx_root }}/test.local/public/index.html" content="Index HTML test OK\n"
|
|
- name: -- VERIFY VHOSTS --
|
|
shell: "curl -H 'Host: {{ item.name[0] }}' http://127.0.0.1{% if item.listen is defined and item.listen is iterable %}:{{ item.listen[0] }}{% endif %}/"
|
|
with_items: nginx_vhosts
|
|
when: item.delete is undefined or not item.delete
|
|
changed_when: false
|
|
- name: -- VERIFY REDIRECT VHOSTS --
|
|
shell: "curl -H 'Host: {{ item.redirect_from[0] }}' http://127.0.0.1/"
|
|
with_items: nginx_vhosts
|
|
when: item.redirect_from is defined and (item.delete is undefined or not item.delete)
|
|
changed_when: false
|