ansible-nginx/tests/test.yml

44 lines
1.4 KiB
YAML
Raw Normal View History

2015-07-15 17:14:39 +07:00
---
- hosts: all
2015-07-15 21:26:27 +07:00
pre_tasks:
2015-07-15 22:24:50 +07:00
- apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 state=present
with_items:
- php5-fpm
2015-07-30 18:02:21 +07:00
- lineinfile: >
dest=/etc/hosts
line="127.0.2.2 {% for name in nginx_vhosts|map(attribute='name') %}{{ name | join(' ') }} {% endfor %}"
2015-07-30 20:53:45 +07:00
- lineinfile: >
dest=/etc/hosts
line="127.0.3.3 {% for n in nginx_vhosts %}{% if n.redirect_from is defined %}{% for r in n.redirect_from %}{{ r }} {% endfor %}{% endif %}{% endfor %}"
2015-07-15 20:18:51 +07:00
vars:
2015-07-15 21:26:27 +07:00
nginx_php: true
2015-07-15 20:18:51 +07:00
nginx_vhosts:
2015-07-30 18:02:21 +07:00
- name:
- 'test.local'
- 'test-alias.local'
- 'test2-alias.local'
template: '_base'
2015-07-31 05:38:16 +07:00
location:
'/test':
- 'return 403;'
'/gunther':
- 'return 404;'
2015-07-30 18:02:21 +07:00
- name:
- 'test-php.local'
2015-07-30 20:53:45 +07:00
redirect_from:
- 'www.test-php.local'
2015-07-30 18:02:21 +07:00
template: '_php'
2015-07-15 17:14:39 +07:00
roles:
- ../../
2015-07-15 22:24:50 +07:00
post_tasks:
2015-07-16 21:24:44 +07:00
- name: -- Add PHP file --
2015-07-30 18:02:21 +07:00
copy: dest="{{ nginx_root }}/test-php.local/public/index.php" content="<?php phpinfo();"
2015-07-16 21:24:44 +07:00
- name: -- Add HTML file --
2015-07-30 18:02:21 +07:00
copy: dest="{{ nginx_root }}/test.local/public/index.html" content="Index HTML test OK\n"
2015-07-15 22:24:50 +07:00
- name: -- VERIFY VHOSTS --
2015-07-30 18:02:21 +07:00
get_url: dest="/tmp/ansible_{{ item.name[0] }}.txt" url="http://{{ item.name[0] }}" validate_certs=no
2015-07-15 22:24:50 +07:00
with_items: nginx_vhosts
changed_when: false