Compare commits
No commits in common. "0a51826e2f82a61436ec6d1de5c0cce8aa3a9f52" and "4aef107c1a1aa2e1cdc5d17e0d194c2e716ec114" have entirely different histories.
0a51826e2f
...
4aef107c1a
|
@ -4,6 +4,8 @@ env:
|
|||
global:
|
||||
- VAGRANT_VERSION='2.2.18'
|
||||
jobs:
|
||||
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-debian-stretch-php74' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-debian-buster-php73' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-debian-bullseye-php74' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
- PLATFORM='docker-debian-bullseye-php80' ANSIBLE_VERSION='>=2.11,<2.12'
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
Ansible PHP (+FPM) role for Debian / Ubuntu / FreeBSD
|
||||
=====================================================
|
||||
|
||||
[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-hanxhx.php-blue.svg)](https://galaxy.ansible.com/hanxhx.php) [![Build Status](https://app.travis-ci.com/HanXHX/ansible-php.svg?branch=master)](https://app.travis-ci.com/HanXHX/ansible-php)
|
||||
[![Ansible Galaxy](http://img.shields.io/badge/ansible--galaxy-HanXHX.php-blue.svg)](https://galaxy.ansible.com/HanXHX/php) [![Build Status](https://app.travis-ci.com/HanXHX/ansible-php.svg?branch=master)](https://app.travis-ci.com/HanXHX/ansible-php)
|
||||
|
||||
Install PHP on Debian / Ubuntu / FreeBSD. Manage PHP-FPM, APCu, Opcache and Xdebug.
|
||||
|
||||
Managed OS / Versions
|
||||
---------------------
|
||||
|
||||
On all Debian versions, you can install all PHP versions by using [Sury's APT repository](https://deb.sury.org/).
|
||||
On all Debian versions, you can install all PHP versions (from PHP 5.6 to 8.1 beta) by using [Sury's APT repository](https://deb.sury.org/).
|
||||
|
||||
Other cases:
|
||||
|
||||
|
@ -161,14 +161,14 @@ Example Playbook
|
|||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: hanxhx.php }
|
||||
- { role: HanXHX.php }
|
||||
|
||||
### Debian Bullseye with PHP 8.0 CLI (no FPM)
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: HanXHX.sury }
|
||||
- { role: hanxhx.php, php_version: '8.0', php_install_fpm: false }
|
||||
- { role: HanXHX.php, php_version: '8.0', php_install_fpm: false }
|
||||
|
||||
License
|
||||
-------
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
Vagrant.configure("2") do |config|
|
||||
|
||||
vms_debian = [
|
||||
{ :name => "debian-stretch-php70", :box => "debian/stretch64", :vars => { }},
|
||||
{ :name => "debian-stretch-php74", :box => "debian/stretch64", :vars => { "php_version": '7.4' }},
|
||||
{ :name => "debian-buster-php73", :box => "debian/buster64", :vars => { }},
|
||||
{ :name => "debian-buster-php74", :box => "debian/buster64", :vars => { "php_version": '7.4' }},
|
||||
{ :name => "debian-bullseye-php74", :box => "debian/bullseye64", :vars => { }},
|
||||
|
@ -19,6 +21,8 @@ Vagrant.configure("2") do |config|
|
|||
]
|
||||
|
||||
conts = [
|
||||
{ :name => "docker-debian-stretch-php70", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { }},
|
||||
{ :name => "docker-debian-stretch-php74", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.4' }},
|
||||
{ :name => "docker-debian-buster-php73", :docker => "hanxhx/vagrant-ansible:debian10", :vars => { }},
|
||||
{ :name => "docker-debian-buster-php74", :docker => "hanxhx/vagrant-ansible:debian10", :vars => { "php_version": '7.4' }},
|
||||
{ :name => "docker-debian-bullseye-php74", :docker => "hanxhx/vagrant-ansible:debian11", :vars => { }},
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
---
|
||||
|
||||
- name: Restart php-fpm
|
||||
- name: restart php-fpm
|
||||
ansible.builtin.service:
|
||||
name: '{{ php_fpm_service }}'
|
||||
state: restarted
|
||||
when: php_install_fpm
|
||||
notify: Docker restart php-fpm
|
||||
notify: docker restart php-fpm
|
||||
|
||||
- name: Docker restart php-fpm
|
||||
- name: docker restart php-fpm
|
||||
ansible.builtin.command: 'service {{ php_fpm_service }} restart'
|
||||
args:
|
||||
warn: false
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
|
||||
argument_specs:
|
||||
main:
|
||||
short_description: Main entry point
|
||||
options: {}
|
|
@ -1,15 +1,14 @@
|
|||
---
|
||||
galaxy_info:
|
||||
author: Emilien Mantel
|
||||
role_name: php
|
||||
namespace: hanxhx
|
||||
description: Install and configure PHP 7.x/8.x
|
||||
company: TripleStack
|
||||
description: Install and configure PHP 7.0/7.1/7.2/7.3/7.4/8.0
|
||||
company:
|
||||
license: GPLv2
|
||||
min_ansible_version: '2.11'
|
||||
min_ansible_version: 2.11
|
||||
platforms:
|
||||
- name: Debian
|
||||
versions:
|
||||
- stretch
|
||||
- buster
|
||||
- bullseye
|
||||
- name: Ubuntu
|
||||
|
@ -17,9 +16,9 @@ galaxy_info:
|
|||
- bionic
|
||||
- name: FreeBSD
|
||||
versions:
|
||||
- '11.0'
|
||||
- '11.1'
|
||||
- '12.0'
|
||||
- 11.0
|
||||
- 11.1
|
||||
- 12.0
|
||||
galaxy_tags:
|
||||
- development
|
||||
- web
|
||||
|
@ -30,5 +29,4 @@ galaxy_info:
|
|||
- debian
|
||||
- ubuntu
|
||||
- freebsd
|
||||
|
||||
dependencies: []
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
group: root
|
||||
mode: 0644
|
||||
loop: "{{ php_ini | combine(php_ini_fpm) | dict2items }}"
|
||||
notify: Restart php-fpm
|
||||
notify: restart php-fpm
|
||||
|
||||
- name: TEMPLATE | Deploy pool configuration
|
||||
ansible.builtin.template:
|
||||
|
@ -32,11 +32,11 @@
|
|||
group: root
|
||||
mode: 0644
|
||||
loop: "{{ ansible_local.hanxhx_php.fpm_pool }}"
|
||||
notify: Restart php-fpm
|
||||
notify: restart php-fpm
|
||||
|
||||
- name: FILE | Delete default pool if necessary
|
||||
ansible.builtin.file:
|
||||
path: "{{ php_fpm_pool_dir }}/www.conf"
|
||||
state: absent
|
||||
when: '"www" not in (ansible_local.hanxhx_php.fpm_pool | map(attribute="name") | list) and php_autoremove_default_pool'
|
||||
notify: Restart php-fpm
|
||||
notify: restart php-fpm
|
||||
|
|
|
@ -29,11 +29,10 @@
|
|||
listen: "{{ p.listen | default(php_version | php_socket(p.name | default(p.pool_name))) }}",
|
||||
user: "{{ p.user | default(php_default_user_group) }}",
|
||||
group: "{% if p.user is defined %}{{ p.group | default(p.user) }}{% else %}{{ p.group | default(php_default_user_group) }}{% endif %}",
|
||||
php_env: {% if p.php_env is defined %}{{ p.php_env | to_nice_json }}{% else %}{}{% endif %},
|
||||
php_value: {% if p.php_value is defined %}{{ p.php_value | to_nice_json }}{% else %}{}{% endif %},
|
||||
php_admin_value: {% if p.php_admin_value is defined %}{{ p.php_admin_value | to_nice_json }}{% else %}{}{% endif %},
|
||||
{% for k, v in p.items() | list %}
|
||||
{% if k not in ['name', 'pool_name', 'listen', 'user', 'group', 'php_env', 'php_value', 'php_admin_value'] %}
|
||||
{% if k not in ['name', 'pool_name', 'listen', 'user', 'group', 'php_value', 'php_admin_value'] %}
|
||||
{{ k }}: "{{ v }}"{% if not loop.last %},{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
@ -61,8 +60,6 @@
|
|||
group: root
|
||||
mode: 0644
|
||||
register: f
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: SETUP | Gathers new facts
|
||||
ansible.builtin.setup:
|
||||
|
@ -79,13 +76,13 @@
|
|||
install_recommends: false
|
||||
vars:
|
||||
pkgs: "{{ php_packages + php_extra_packages | flatten }}"
|
||||
notify: Restart php-fpm
|
||||
notify: restart php-fpm
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: PKGNG | Install PHP packages
|
||||
community.general.pkgng:
|
||||
name: "{{ php_packages + php_extra_packages | flatten | join(',') }}"
|
||||
notify: Restart php-fpm
|
||||
notify: restart php-fpm
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
- name: IMPORT_TASKS | PHP-FPM
|
||||
|
@ -110,9 +107,7 @@
|
|||
state: started
|
||||
when: php_install_fpm and ansible_virtualization_type != 'docker'
|
||||
|
||||
- name: BLOCK | Ensure PHP-FPM is started if running on Docker
|
||||
when: php_install_fpm and ansible_virtualization_type == 'docker'
|
||||
block:
|
||||
- block:
|
||||
|
||||
- name: COMMAND | Check if PHP-FPM is started (Docker)
|
||||
ansible.builtin.command: 'service {{ php_fpm_service }} status'
|
||||
|
@ -127,3 +122,5 @@
|
|||
args:
|
||||
warn: false
|
||||
when: dps.stdout.find('is not running') != -1
|
||||
|
||||
when: php_install_fpm and ansible_virtualization_type == 'docker'
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
---
|
||||
|
||||
- name: Install opcache/apcu on Debian
|
||||
when: ansible_os_family == 'Debian'
|
||||
block:
|
||||
- block:
|
||||
|
||||
- name: APT | Install APCu
|
||||
ansible.builtin.apt:
|
||||
|
@ -14,10 +12,9 @@
|
|||
pkg: "{{ php_package_prefix }}opcache"
|
||||
install_recommends: false
|
||||
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: Install opcache/apcu on FreeBSD
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
block:
|
||||
- block:
|
||||
|
||||
- name: PKGNG | Install APCu
|
||||
community.general.pkgng:
|
||||
|
@ -27,6 +24,8 @@
|
|||
community.general.pkgng:
|
||||
name: "{{ php_package_prefix }}opcache"
|
||||
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
- name: TEMPLATE | Configure Opcache
|
||||
ansible.builtin.template:
|
||||
src: "etc/__php__/mods-available/opcache.ini.j2"
|
||||
|
@ -34,7 +33,7 @@
|
|||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: Restart php-fpm
|
||||
notify: restart php-fpm
|
||||
|
||||
- name: TEMPLATE | Configure APCu
|
||||
ansible.builtin.template:
|
||||
|
@ -43,4 +42,4 @@
|
|||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify: Restart php-fpm
|
||||
notify: restart php-fpm
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
---
|
||||
|
||||
- name: BLOCK | Uninstall xdebug
|
||||
when: php_install_xdebug
|
||||
block:
|
||||
- block:
|
||||
|
||||
- name: APT | Install xdebug
|
||||
ansible.builtin.apt:
|
||||
|
@ -24,12 +22,11 @@
|
|||
dest: "{{ php_mods_dir }}/xdebug.ini"
|
||||
owner: root
|
||||
mode: 0644
|
||||
notify: Restart php-fpm
|
||||
notify: restart php-fpm
|
||||
|
||||
when: php_install_xdebug
|
||||
|
||||
- name: BLOCK | Uninstall xdebug
|
||||
when: not php_install_xdebug
|
||||
block:
|
||||
- block:
|
||||
|
||||
- name: APT | Uninstall xdebug
|
||||
ansible.builtin.apt:
|
||||
|
@ -42,3 +39,5 @@
|
|||
name: "{{ php_xdebug_package }}"
|
||||
state: absent
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
when: not php_install_xdebug
|
||||
|
|
|
@ -421,9 +421,6 @@ catch_workers_output = {{ item.catch_workers_output | default('no') }}
|
|||
;php_admin_value[error_log] = /var/log/fpm-php.www.log
|
||||
;php_admin_flag[log_errors] = on
|
||||
;php_admin_value[memory_limit] = 32M
|
||||
{% for k, v in item.php_env.items() | list %}
|
||||
env[{{ k }}] = {{ v }}
|
||||
{% endfor %}
|
||||
{% for k, v in item.php_value.items() | list %}
|
||||
php_value[{{ k }}] = {{ v }}
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
---
|
||||
|
||||
- hosts: all
|
||||
name: Test all
|
||||
vars:
|
||||
vhost: 'test.local'
|
||||
php_extra_packages:
|
||||
|
@ -25,8 +24,6 @@
|
|||
ping_response: 'ok'
|
||||
- name: 'test_ansible2'
|
||||
user: 'foo'
|
||||
php_env:
|
||||
foo: bar
|
||||
php_value:
|
||||
display_errors: 'Off'
|
||||
php_admin_value:
|
||||
|
@ -53,20 +50,20 @@
|
|||
mode: 0644
|
||||
owner: root
|
||||
group: root
|
||||
notify: Reload nginx
|
||||
notify: reload nginx
|
||||
|
||||
- name: COMMAND | Fix nginx config
|
||||
ansible.builtin.command: "cp {{ __nginx_conf | dirname }}/fastcgi_params {{ __nginx_conf | dirname }}/fastcgi.conf"
|
||||
args:
|
||||
creates: "{{ __nginx_conf | dirname }}/fastcgi.conf"
|
||||
notify: Reload nginx
|
||||
notify: reload nginx
|
||||
|
||||
- name: LINEINFILE | Fix nginx config (second step)
|
||||
ansible.builtin.lineinfile:
|
||||
regexp: '^fastcgi_param\s+SCRIPT_FILENAME'
|
||||
line: "fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;"
|
||||
dest: "{{ __nginx_conf | dirname }}/fastcgi.conf"
|
||||
notify: Reload nginx
|
||||
notify: reload nginx
|
||||
|
||||
- name: SERVICE | Ensure nginx is started
|
||||
ansible.builtin.service:
|
||||
|
@ -74,9 +71,7 @@
|
|||
state: started
|
||||
when: ansible_virtualization_type != 'docker'
|
||||
|
||||
- name: Start nginx if testing with Docker
|
||||
when: ansible_virtualization_type == 'docker'
|
||||
block:
|
||||
- block:
|
||||
|
||||
- name: COMMAND | Docker nginx status
|
||||
ansible.builtin.command: service nginx status
|
||||
|
@ -92,19 +87,21 @@
|
|||
warn: false
|
||||
when: ngs.stdout.find('nginx is not running') != -1
|
||||
|
||||
when: ansible_virtualization_type == 'docker'
|
||||
|
||||
handlers:
|
||||
|
||||
- name: Reload nginx
|
||||
- name: reload nginx
|
||||
ansible.builtin.service:
|
||||
name: nginx
|
||||
state: reloaded
|
||||
notify: Docker reload nginx
|
||||
notify: docker reload nginx
|
||||
|
||||
- name: Docker reload nginx
|
||||
- name: docker reload nginx
|
||||
ansible.builtin.command: service nginx reload
|
||||
args:
|
||||
warn: false
|
||||
notify: Docker reload nginx
|
||||
notify: docker reload nginx
|
||||
when: ansible_virtualization_type == 'docker'
|
||||
|
||||
roles:
|
||||
|
@ -171,9 +168,7 @@
|
|||
url: "http://localhost{{ php_fpm_poold.0.status_path }}"
|
||||
when: php_fpm_poold.0.status_path is defined
|
||||
|
||||
- name: Debian extra checks
|
||||
when: ansible_os_family == 'Debian'
|
||||
block:
|
||||
- block:
|
||||
|
||||
- name: SHELL | Check if we installed multiple PHP versions
|
||||
ansible.builtin.shell: set -o pipefail && (dpkg -l | grep 'php[[:digit:]].*common' | wc -l)
|
||||
|
@ -188,3 +183,5 @@
|
|||
ansible.builtin.fail:
|
||||
msg: "Multiple PHP versions detected"
|
||||
when: check_multiple_php.stdout != '1'
|
||||
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
|
||||
php_default_version: '7.0'
|
Loading…
Reference in New Issue