mirror of
https://github.com/HanXHX/ansible-php.git
synced 2026-04-21 14:02:09 +07:00
Mass cleanup and drop jessie support
This commit is contained in:
9
tests/includes/Debian/dotdeb.yml
Normal file
9
tests/includes/Debian/dotdeb.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
- name: APT | Install DotDeb key
|
||||
apt_key:
|
||||
url: 'http://www.dotdeb.org/dotdeb.gpg'
|
||||
|
||||
- name: APT | Add Dotdeb repository
|
||||
apt_repository:
|
||||
repo: 'deb http://packages.dotdeb.org {{ ansible_distribution_release }} all'
|
||||
9
tests/includes/Debian/sury.yml
Normal file
9
tests/includes/Debian/sury.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
|
||||
- name: APT | Install Sury key
|
||||
apt_key:
|
||||
url: 'https://packages.sury.org/php/apt.gpg'
|
||||
|
||||
- name: APT | Add Sury repository
|
||||
apt_repository:
|
||||
repo: 'deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main'
|
||||
@@ -1,7 +0,0 @@
|
||||
---
|
||||
|
||||
- name: APT | Install DotDeb key
|
||||
apt_key: url='http://www.dotdeb.org/dotdeb.gpg' state=present
|
||||
|
||||
- name: APT | Add Dotdeb repository
|
||||
apt_repository: repo='deb http://packages.dotdeb.org {{ ansible_distribution_release }} all' state=present
|
||||
23
tests/includes/pre_Debian.yml
Normal file
23
tests/includes/pre_Debian.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
|
||||
- name: SET_FACT | Prepare test vars
|
||||
set_fact:
|
||||
__nginx_site_dir: /etc/nginx/sites-enabled
|
||||
|
||||
- name: APT | Install packages
|
||||
apt:
|
||||
pkg: "{{ item }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
with_items:
|
||||
- apt-transport-https
|
||||
- ca-certificates
|
||||
- curl
|
||||
- lsb-release
|
||||
- nginx
|
||||
|
||||
- name: INCLUDE | Sury
|
||||
include: Debian/sury.yml
|
||||
when: >
|
||||
ansible_distribution_major_version | version_compare(9, 'eq') and
|
||||
php_version | version_compare('7.1', 'ge')
|
||||
@@ -1,7 +0,0 @@
|
||||
---
|
||||
|
||||
- name: APT | Install Sury key
|
||||
apt_key: url='https://packages.sury.org/php/apt.gpg' state=present
|
||||
|
||||
- name: APT | Add Sury repository
|
||||
apt_repository: repo='deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main' state=present
|
||||
@@ -5,19 +5,19 @@ server {
|
||||
|
||||
{% if php_fpm_poold.0.status_path is defined %}
|
||||
location = {{ php_fpm_poold.0.status_path }} {
|
||||
include {{ nginx_include }};
|
||||
include fastcgi.conf;
|
||||
fastcgi_pass unix:{{ php_default_fpm_sock }};
|
||||
}
|
||||
{% endif %}
|
||||
{% if php_fpm_poold.0.ping_path is defined %}
|
||||
location = {{ php_fpm_poold.0.ping_path }} {
|
||||
include {{ nginx_include }};
|
||||
include fastcgi.conf;
|
||||
fastcgi_pass unix:{{ php_default_fpm_sock }};
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
location ~ \.php$ {
|
||||
include {{ nginx_include }};
|
||||
include fastcgi.conf;
|
||||
fastcgi_pass unix:{{ php_default_fpm_sock }};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
vars:
|
||||
vhost: 'test.local'
|
||||
php_extra_packages:
|
||||
- '{{ php_apt_prefix }}recode'
|
||||
- '{{ php_package_prefix }}recode'
|
||||
php_install_xdebug: true
|
||||
php_ini_fpm:
|
||||
display_errors: 'Off'
|
||||
@@ -24,54 +24,29 @@
|
||||
|
||||
pre_tasks:
|
||||
|
||||
- name: APT | Install packages
|
||||
apt: pkg={{ item }} update_cache=yes cache_valid_time=3600
|
||||
with_items: ['apt-transport-https', 'curl', 'lsb-release', 'ca-certificates']
|
||||
|
||||
- name: INCLUDE | Dotdeb
|
||||
include: includes/dotdeb.yml
|
||||
when: >
|
||||
ansible_distribution_major_version | version_compare(8, 'eq') and
|
||||
php_version | version_compare('7.0', 'eq')
|
||||
|
||||
- name: INCLUDE | Sury
|
||||
include: includes/sury.yml
|
||||
when: >
|
||||
ansible_distribution_major_version | version_compare(9, 'le') and
|
||||
php_version | version_compare('7.1', 'eq')
|
||||
|
||||
- name: APT | Install nginx
|
||||
apt: pkg=nginx state=present update_cache=yes cache_valid_time=3600
|
||||
|
||||
- name: SHELL | Get nginx version
|
||||
shell: nginx -V 2>&1 | awk -F '/' '/nginx version/ { print $2 }'
|
||||
register: nginx_version
|
||||
changed_when: false
|
||||
|
||||
- set_fact: nginx_include="fastcgi_params"
|
||||
when: nginx_version.stdout | version_compare('1.6', '<', true)
|
||||
|
||||
- set_fact: nginx_include="fastcgi.conf"
|
||||
when: nginx_version.stdout | version_compare('1.6', '>=', true)
|
||||
- name: INCLUDE | Pre tasks related to OS
|
||||
include: "includes/pre_{{ ansible_os_family }}.yml"
|
||||
|
||||
tasks:
|
||||
|
||||
- name: TEMPLATE | Nginx site config
|
||||
template:
|
||||
src: templates/site.j2
|
||||
dest: /etc/nginx/sites-enabled/{{ vhost }}
|
||||
src: "templates/site.j2"
|
||||
dest: "{{ __nginx_site_dir }}/{{ vhost }}"
|
||||
notify: reload nginx
|
||||
|
||||
- name: FILE | Delete default site
|
||||
file:
|
||||
path: /etc/nginx/sites-enabled/default
|
||||
path: "{{ __nginx_site_dir }}/default"
|
||||
state: absent
|
||||
notify: reload nginx
|
||||
|
||||
handlers:
|
||||
|
||||
- name: reload nginx
|
||||
service: name=nginx state=reloaded
|
||||
service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
|
||||
roles:
|
||||
- ../../
|
||||
@@ -85,10 +60,14 @@
|
||||
failed_when: p.stdout == ''
|
||||
|
||||
- name: FILE | Create /var/www
|
||||
file: dest=/var/www state=directory
|
||||
file:
|
||||
dest: /var/www
|
||||
state: directory
|
||||
|
||||
- name: COPY | Add phpinfo
|
||||
copy: dest=/var/www/phpinfo.php content='<?php phpinfo();'
|
||||
copy:
|
||||
dest: /var/www/phpinfo.php
|
||||
content: '<?php phpinfo();'
|
||||
|
||||
- name: SHELL | Check vhost
|
||||
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'"
|
||||
|
||||
Reference in New Issue
Block a user