Drop PHP version support (useless) + fix some bugs
parent
2a612a55b9
commit
a9a72dd25f
|
@ -1,11 +1,12 @@
|
|||
env:
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
||||
- PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
||||
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.6,<2.7'
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
- PLATFORM='docker-debian-stretch-sury' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.7,<2.8'
|
||||
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.8,<2.9'
|
||||
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.8,<2.9'
|
||||
- PLATFORM='docker-debian-stretch' ANSIBLE_VERSION='ansible>=2.9,<2.10'
|
||||
- PLATFORM='docker-debian-buster' ANSIBLE_VERSION='ansible>=2.9,<2.10'
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
Vagrant.configure("2") do |config|
|
||||
|
||||
vms_debian = [
|
||||
{ :name => "debian-stretch", :box => "debian/stretch64", :vars => { "nginx_php": [{"version": "7.0"}] }},
|
||||
{ :name => "debian-stretch-sury", :box => "debian/stretch64", :vars => { "nginx_php": [{"version": "7.1"}], "sury": true }},
|
||||
{ :name => "debian-buster", :box => "debian/buster64", :vars => { "nginx_php": [{"version": "7.3"}] }}
|
||||
{ :name => "debian-stretch", :box => "debian/stretch64", :vars => {} },
|
||||
{ :name => "debian-buster", :box => "debian/buster64", :vars => {} }
|
||||
]
|
||||
|
||||
vms_freebsd = [
|
||||
|
@ -17,9 +16,8 @@ Vagrant.configure("2") do |config|
|
|||
]
|
||||
|
||||
conts = [
|
||||
{ :name => "docker-debian-stretch", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "nginx_php": [{"version": "7.0"}] }},
|
||||
{ :name => "docker-debian-stretch-sury", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "nginx_php": [{"version": "7.1"}], "sury": true }},
|
||||
{ :name => "docker-debian-buster", :docker => "hanxhx/vagrant-ansible:debian10", :vars => { "nginx_php": [{"version": "7.3"}] }},
|
||||
{ :name => "docker-debian-stretch", :docker => "hanxhx/vagrant-ansible:debian9", :vars => {} },
|
||||
{ :name => "docker-debian-buster", :docker => "hanxhx/vagrant-ansible:debian10", :vars => {} },
|
||||
]
|
||||
|
||||
config.vm.network "private_network", type: "dhcp"
|
||||
|
|
13
doc/php.md
13
doc/php.md
|
@ -2,8 +2,7 @@ PHP
|
|||
===
|
||||
|
||||
`nginx_php`:
|
||||
- `version`: (M) PHP version
|
||||
- `upstream_name` (O)
|
||||
- `upstream_name` (M)
|
||||
- `sockets`: (O) socket list
|
||||
|
||||
If `sockets` is not provided, if uses local unix socket (based on PHP version).
|
||||
|
@ -16,8 +15,8 @@ Each socket have:
|
|||
|
||||
XOR
|
||||
|
||||
- `host`
|
||||
- `port`
|
||||
- `weight`
|
||||
- `max_fails`
|
||||
- `fail_timeout`
|
||||
- `host` (M)
|
||||
- `port` (M)
|
||||
- `weight` (O)
|
||||
- `max_fails` (O)
|
||||
- `fail_timeout` (O)
|
||||
|
|
|
@ -29,7 +29,6 @@ Common
|
|||
- `proto`: (O) list of protocol used. Default is a list with "http". If you need http and https, you must set a list with "http" and "https". You can only set "https" without http support.
|
||||
- `ssl_name`: (D) name of the key used when using TLS/SSL. Optional when `proto` contains "https". If you don't set this value, it will search by `name`.
|
||||
- `ssl_template` (O) "strong" (default) or "legacy". You can disable SSL helpers and add your own directives by setting "false".
|
||||
- `php_version` (O) Sepecify PHP version (5 or 7)
|
||||
- `http_proxy_protocol_port` (O) Enable proxy protocol on http port.
|
||||
- `https_proxy_protocol_port` (O) Enable proxy protocol on https port.
|
||||
|
||||
|
|
|
@ -1,19 +1,10 @@
|
|||
def php_default_upstream_socket(php_version):
|
||||
return '/run/php/php%s-fpm.sock' % php_version
|
||||
|
||||
def php_default_upstream_name(php_version):
|
||||
return 'default_php_%s' % php_version
|
||||
|
||||
def php_fpm_service(php_version):
|
||||
return 'php%s-fpm' % php_version
|
||||
|
||||
class FilterModule(object):
|
||||
''' PHP module '''
|
||||
|
||||
def filters(self):
|
||||
return {
|
||||
'php_default_upstream_socket': php_default_upstream_socket,
|
||||
'php_default_upstream_name': php_default_upstream_name,
|
||||
'php_fpm_service': php_fpm_service,
|
||||
'php_fpm_package': php_fpm_service
|
||||
}
|
||||
|
|
|
@ -1,34 +1,5 @@
|
|||
---
|
||||
|
||||
- block:
|
||||
|
||||
- name: SET_FACT | temp
|
||||
set_fact:
|
||||
tmp_fpm_pool: |
|
||||
[
|
||||
{% for p in ansible_local.hanxhx_php.fpm_pool %}
|
||||
{
|
||||
"upstream_name": "{{ p.name }}",
|
||||
"sockets": [{
|
||||
{% if p.listen.startswith('/') %}
|
||||
"unix": "{{ p.listen }}"
|
||||
{% else %}
|
||||
{% set host = p.listen.split(":")[0] %}
|
||||
{% set port = p.listen.split(":")[1] %}
|
||||
"host": "{{ host }}",
|
||||
"port": "{{ port }}"
|
||||
{% endif %}
|
||||
}]
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
]
|
||||
|
||||
- name: SET_FACT | new php
|
||||
set_fact:
|
||||
nginx_php: "{{ nginx_php + tmp_fpm_pool }}"
|
||||
|
||||
when: ansible_local.hanxhx_php.fpm_pool is defined
|
||||
|
||||
- name: TEMPLATE | Deploy PHP upstream to Nginx
|
||||
template:
|
||||
src: "etc/nginx/conf.d/php.conf.j2"
|
||||
|
|
|
@ -3,15 +3,13 @@
|
|||
#
|
||||
|
||||
{% for php in nginx_php %}
|
||||
upstream {{ php.upstream_name | default((php.version | php_default_upstream_name)) }} {
|
||||
upstream {{ php.upstream_name }} {
|
||||
{% for sock in php.sockets | default([]) %}
|
||||
{% if sock.host is defined %}
|
||||
server {{ sock.host }}:{{ sock.port }} weight={{ sock.weight | default('1') }} max_fails={{ sock.max_fails | default('5') }} fail_timeout={{ sock.fail_timeout | default('10s') }};
|
||||
{% else %}
|
||||
server unix:{{ sock.unix | default((php.version | php_default_upstream_socket)) }} weight={{ sock.weight | default('1') }};
|
||||
server unix:{{ sock.unix }} weight={{ sock.weight | default('1') }};
|
||||
{% endif %}
|
||||
{% else %}
|
||||
server unix:{{ php.version | php_default_upstream_socket }} weight=1;
|
||||
{% endfor %}
|
||||
}
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
{% extends "_base.j2" %}
|
||||
|
||||
{% if item.php_version is defined %}
|
||||
{% set php_info = 'Explicit PHP version on site' %}
|
||||
{% set php_upstream = (nginx_php|selectattr('version', 'equalto', item.php_version)|first).upstream_name | default(item.php_version | php_default_upstream_name) %}
|
||||
{% elif item.php_upstream is defined %}
|
||||
{% set php_info = 'Explicit Nginx/PHP upstream on site' %}
|
||||
{% set php_upstream = item.php_upstream %}
|
||||
{% else %}
|
||||
{% set php_info = 'Warning: using first PHP version on config' %}
|
||||
{% set php_upstream = nginx_php.0.upstream_name | default(nginx_php.0.version | php_default_upstream_name) %}
|
||||
{% endif %}
|
||||
|
||||
{% block template_index %}
|
||||
index {{ item.index | default('index.html index.htm index.php') }};
|
||||
{% endblock %}
|
||||
|
@ -21,8 +10,7 @@
|
|||
|
||||
{% block template_upstream_location %}
|
||||
location ~ \.php$ {
|
||||
# {{ php_info }}
|
||||
fastcgi_pass {{ php_upstream }};
|
||||
fastcgi_pass {{ item.php_upstream }};
|
||||
fastcgi_index index.php;
|
||||
{% if item.upstream_params is defined and item.upstream_params is iterable %}
|
||||
{% for param in item.upstream_params %}
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
|
||||
{% block template_upstream_location %}
|
||||
location = /index.php {
|
||||
# {{ php_info }}
|
||||
fastcgi_pass {{ php_upstream }};
|
||||
fastcgi_pass {{ item.php_upstream }};
|
||||
fastcgi_index index.php;
|
||||
{% if item.upstream_params is defined and item.upstream_params is iterable %}
|
||||
{% for param in item.upstream_params %}
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
{% block template_upstream_location %}
|
||||
location = /index.php {
|
||||
# {{ php_info }}
|
||||
fastcgi_pass {{ php_upstream }};
|
||||
fastcgi_pass {{ item.php_upstream }};
|
||||
fastcgi_index index.php;
|
||||
{% if item.upstream_params is defined and item.upstream_params is iterable %}
|
||||
{% for param in item.upstream_params %}
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
}
|
||||
|
||||
location ~ ^/index\.php(/|$) {
|
||||
# {{ php_info }}
|
||||
fastcgi_pass {{ php_upstream }};
|
||||
fastcgi_pass {{ item.php_upstream }};
|
||||
fastcgi_index index.php;
|
||||
{% if item.upstream_params is defined and item.upstream_params is iterable %}
|
||||
{% for param in item.upstream_params %}
|
||||
|
|
|
@ -6,24 +6,6 @@
|
|||
state: present
|
||||
when: nginx_backports
|
||||
|
||||
- block:
|
||||
|
||||
- name: APT | Install apt-transport-https
|
||||
apt:
|
||||
pkg: apt-transport-https
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: APT_KEY | Install GPG key
|
||||
apt_key:
|
||||
url: 'https://packages.sury.org/php/apt.gpg'
|
||||
|
||||
- name: APT_REPOSITORY | Add APT repository
|
||||
apt_repository:
|
||||
repo: 'deb https://packages.sury.org/php {{ ansible_distribution_release }} main'
|
||||
|
||||
when: sury | default(false)
|
||||
|
||||
- name: APT | Install needed packages
|
||||
apt:
|
||||
pkg: "{{ packages }}"
|
||||
|
@ -44,12 +26,19 @@
|
|||
|
||||
- name: APT | Install PHP
|
||||
apt:
|
||||
pkg: "{{ item.version | php_fpm_package }}"
|
||||
pkg: "{{ pkgs }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: 3600
|
||||
state: present
|
||||
loop: "{{ nginx_php }}"
|
||||
register: apt_php
|
||||
vars:
|
||||
pkgs:
|
||||
- php-cli
|
||||
- php-fpm
|
||||
|
||||
- name: SHELL | Get current PHP version
|
||||
shell: php --version | awk '/^PHP/ { print $2 }' | grep -o -E '^.{3}'
|
||||
changed_when: false
|
||||
register: cur_php_version
|
||||
|
||||
- name: SERVICE | Force start fcgiwrap
|
||||
service:
|
||||
|
@ -58,11 +47,10 @@
|
|||
|
||||
# Bypasses Ansible+Docker issue. With service module... php is not really started!
|
||||
- name: COMMAND | Force start PHP
|
||||
command: "service {{ item.version | php_fpm_service }} start"
|
||||
command: "service php{{ cur_php_version.stdout }}-fpm start"
|
||||
args:
|
||||
creates: "{{ item.version | php_default_upstream_socket }}"
|
||||
creates: "/run/php/php{{ cur_php_version.stdout }}-fpm.pid"
|
||||
warn: false
|
||||
loop: "{{ nginx_php }}"
|
||||
|
||||
- name: GET_URL | Download ngrok
|
||||
get_url:
|
||||
|
@ -88,7 +76,7 @@
|
|||
include_role:
|
||||
name: "{{ playbook_dir }}/HanXHX.php"
|
||||
vars:
|
||||
php_version: "{{ nginx_php.0.version }}"
|
||||
php_version: "{{ cur_php_version.stdout }}"
|
||||
php_autoremove_default_pool: false
|
||||
php_fpm_poold:
|
||||
- name: 'hx_unix'
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
- hosts: all
|
||||
pre_tasks:
|
||||
|
||||
- name: INCLUDE_TASKS | Pre_tasks related to OS version
|
||||
include_tasks: "includes/pre_{{ ansible_distribution }}.yml"
|
||||
|
||||
|
@ -23,6 +24,7 @@
|
|||
src: "file/test.key"
|
||||
dest: "{{ int_ansible_ssl_dir }}/test.key"
|
||||
|
||||
- debug: var=nginx_sites
|
||||
- name: COPY | Add all hosts in /etc/hosts
|
||||
copy:
|
||||
content: |
|
||||
|
@ -203,7 +205,7 @@
|
|||
- '/'
|
||||
- '/a'
|
||||
- name: 'test-php.local'
|
||||
php_version: "{{ nginx_php.1.version if nginx_php.1 is defined else nginx_php.0.version }}"
|
||||
php_upstream: "manual"
|
||||
upstream_params:
|
||||
- 'fastcgi_param FOO bar;'
|
||||
redirect_from:
|
||||
|
@ -274,6 +276,9 @@
|
|||
ssl_name: '{{ ngrok.stdout }}'
|
||||
headers:
|
||||
'X-acme': '1'
|
||||
|
||||
#nginx_php: "{{ __nginx_php + [{'upstream_name': 'manual', 'sockets': [{'host': '127.0.0.1', 'port': '9636' }] }] }}"
|
||||
nginx_php: "{{ [{'upstream_name': 'manual', 'sockets': [{'host': '127.0.0.1', 'port': '9636' }] }] }}"
|
||||
nginx_dh_length: 1024
|
||||
roles:
|
||||
- ../../
|
||||
|
@ -374,7 +379,7 @@
|
|||
when: >
|
||||
item.template is defined and
|
||||
(item.template == '_php' or item.template == '_php_index' or item.template == '_php_index2')
|
||||
failed_when: p.content.find('PHP Version ' + item.php_version if 'php_version' in item else nginx_php.0.version) == -1
|
||||
failed_when: p.content.find('PHP Version') == -1
|
||||
|
||||
- name: -- VERIFY INDEX2 --
|
||||
uri:
|
||||
|
|
Loading…
Reference in New Issue