48 lines
1.5 KiB
YAML
48 lines
1.5 KiB
YAML
---
|
|
|
|
- hosts: all
|
|
pre_tasks:
|
|
- apt: pkg={{ item }} update_cache=yes cache_valid_time=3600 state=present
|
|
with_items:
|
|
- php5-fpm
|
|
- lineinfile: >
|
|
dest=/etc/hosts
|
|
line="127.0.2.2 {% for name in nginx_vhosts|map(attribute='name') %}{{ name | join(' ') }} {% endfor %}"
|
|
- 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 %}"
|
|
vars:
|
|
nginx_php: true
|
|
nginx_vhosts:
|
|
- name:
|
|
- 'test.local'
|
|
- 'test-alias.local'
|
|
- 'test2-alias.local'
|
|
template: '_base'
|
|
location:
|
|
'/test':
|
|
- 'return 403;'
|
|
'/gunther':
|
|
- 'return 404;'
|
|
- name:
|
|
- 'test-php.local'
|
|
redirect_from:
|
|
- 'www.test-php.local'
|
|
template: '_php'
|
|
- 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 --
|
|
get_url: dest="/tmp/ansible_{{ item.name[0] }}.txt" url="http://{{ item.name[0] }}" validate_certs=no
|
|
with_items: nginx_vhosts
|
|
changed_when: false
|
|
|