mirror of
https://github.com/HanXHX/ansible-nginx.git
synced 2026-02-24 09:03:29 +07:00
Fix and improve tests/vhosts + php_index vhost
This commit is contained in:
@@ -36,6 +36,8 @@
|
||||
redirect_from:
|
||||
- 'www.test-php.local'
|
||||
template: '_php'
|
||||
- name: 'test-php-index.local'
|
||||
template: '_php_index'
|
||||
- name: 'test-proxy.local'
|
||||
listen:
|
||||
- 8080
|
||||
@@ -48,16 +50,24 @@
|
||||
- ../../
|
||||
post_tasks:
|
||||
- name: -- Add PHP file --
|
||||
copy: dest="{{ nginx_root }}/test-php.local/public/index.php" content="<?php phpinfo();"
|
||||
copy: dest="{{ nginx_root }}/{{ item }}/public/index.php" content="<?php phpinfo();"
|
||||
with_items: ['test-php.local', 'test-php-index.local']
|
||||
- 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 %}/"
|
||||
shell: "curl -H 'Host: {{ item.name if item.name is string else item.name[0] }}' http://127.0.0.1{% if item.listen is defined %}:{{ item.listen[0] }}{% endif %}/"
|
||||
with_items: nginx_vhosts
|
||||
when: item.delete is undefined or not item.delete
|
||||
changed_when: false
|
||||
- name: -- VERIFY FORBIDDEN --
|
||||
command: "curl -H 'Host: test-php-index.local' http://127.0.0.1/phpinfo.php"
|
||||
register: f
|
||||
failed_when: f.stdout.find('403 Forbidden') == -1
|
||||
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
|
||||
register: r
|
||||
failed_when: r.stdout.find('301 Moved Permanently') == -1
|
||||
|
||||
Reference in New Issue
Block a user