ansible-php/tests/test.yml

89 lines
2.1 KiB
YAML
Raw Normal View History

2015-07-23 21:35:25 +07:00
---
- hosts: all
2015-07-23 22:10:15 +07:00
vars:
vhost: 'test.local'
2015-07-24 15:03:11 +07:00
php_extra_packages:
2018-03-18 23:28:57 +07:00
- '{{ php_package_prefix }}recode'
2015-07-27 23:09:52 +07:00
php_install_xdebug: true
2017-11-10 18:19:39 +07:00
php_ini_fpm:
display_errors: 'Off'
php_ini_cli:
error_reporting: 'E_ALL'
2017-11-22 23:02:51 +07:00
php_fpm_poold:
- pool_name: 'www'
listen: '{{ php_default_fpm_sock }}'
pm: 'dynamic'
pm_max_children: 250
pm_start_servers: 10
pm_min_spare_servers: 10
pm_max_spare_servers: 20
status_path: '/status'
ping_path: '/ping'
ping_response: 'ok'
2017-03-17 00:22:32 +07:00
2015-07-23 22:10:15 +07:00
pre_tasks:
2017-03-17 00:22:32 +07:00
2018-03-18 23:28:57 +07:00
- name: INCLUDE | Pre tasks related to OS
include: "includes/pre_{{ ansible_os_family }}.yml"
2017-03-17 00:22:32 +07:00
2016-01-22 21:57:29 +07:00
tasks:
2017-03-17 00:22:32 +07:00
2017-11-22 23:02:51 +07:00
- name: TEMPLATE | Nginx site config
template:
2018-03-18 23:28:57 +07:00
src: "templates/site.j2"
dest: "{{ __nginx_site_dir }}/{{ vhost }}"
2017-11-22 23:02:51 +07:00
notify: reload nginx
- name: FILE | Delete default site
file:
2018-03-18 23:28:57 +07:00
path: "{{ __nginx_site_dir }}/default"
2017-11-22 23:02:51 +07:00
state: absent
2015-07-23 22:10:15 +07:00
notify: reload nginx
2017-03-17 00:22:32 +07:00
2015-07-23 22:10:15 +07:00
handlers:
2017-03-17 00:22:32 +07:00
2015-07-23 22:10:15 +07:00
- name: reload nginx
2018-03-18 23:28:57 +07:00
service:
name: nginx
state: reloaded
2017-03-17 00:22:32 +07:00
2015-07-23 21:35:25 +07:00
roles:
- ../../
2017-03-17 00:22:32 +07:00
2015-07-23 22:10:15 +07:00
post_tasks:
2017-03-17 00:22:32 +07:00
2015-07-24 14:48:47 +07:00
- name: SHELL | Test php-cli
shell: php -i | grep '^PHP Version => {{ php_version }}' | head -n 1
2015-07-23 22:10:15 +07:00
changed_when: false
2016-01-22 21:57:29 +07:00
register: p
failed_when: p.stdout == ''
2017-03-17 00:22:32 +07:00
2015-07-23 22:10:15 +07:00
- name: FILE | Create /var/www
2018-03-18 23:28:57 +07:00
file:
dest: /var/www
state: directory
2017-03-17 00:22:32 +07:00
2015-07-23 22:10:15 +07:00
- name: COPY | Add phpinfo
2018-03-18 23:28:57 +07:00
copy:
dest: /var/www/phpinfo.php
content: '<?php phpinfo();'
2017-03-17 00:22:32 +07:00
2015-07-24 14:48:47 +07:00
- name: SHELL | Check vhost
2017-06-06 21:27:11 +07:00
shell: "curl -v -H 'Host: {{ vhost }}' http://127.0.0.1/phpinfo.php 2> /dev/null | grep h1 | grep -o 'PHP Version {{ php_version }}' | sed -r 's/<//g'"
2017-03-17 00:31:16 +07:00
args:
warn: false
2015-07-23 22:10:15 +07:00
changed_when: false
2016-01-22 21:57:29 +07:00
register: c
failed_when: c.stdout == ''
2017-11-22 23:02:51 +07:00
- name: URI | Check ping
uri:
url: "http://localhost{{ php_fpm_poold.0.ping_path }}"
when: php_fpm_poold.0.ping_path is defined
- name: URI | Check status
uri:
url: "http://localhost{{ php_fpm_poold.0.status_path }}"
when: php_fpm_poold.0.status_path is defined