Skip to content

Commit

Permalink
New release (#14)
Browse files Browse the repository at this point in the history
* Manages Debian 11
* Migrate to new TravisCI version
* Fix lint errors
* Use FQCN builtins
* Drop Ubuntu Xenial support (16.04)
  • Loading branch information
HanXHX authored Sep 1, 2021
1 parent 3209f6b commit 309824d
Show file tree
Hide file tree
Showing 22 changed files with 281 additions and 199 deletions.
8 changes: 8 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

# TODO: enable later
enable_list:
- fqcn-builtins

skip_list:
- role-name
53 changes: 33 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
---

env:
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-debian-buster-php73' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.6,<2.7'
- PLATFORM='docker-debian-stretch-php70' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-debian-stretch-php74' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-debian-buster-php73' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-debian-buster-php74' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-ubuntu-xenial-php70' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.7,<2.8'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='ansible>=2.7,<2.8'

sudo: required

dist: trusty
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'
- PLATFORM='docker-debian-buster-php74' ANSIBLE_VERSION='>=2.11,<2.12'
- PLATFORM='docker-ubuntu-bionic-php72' ANSIBLE_VERSION='>=2.11,<2.12'

os:
- linux
dist: focal

language: python
python: 2.7
python:
- 3.8

services:
- docker

before_install:
- wget https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.deb
- sudo dpkg -i vagrant_2.0.1_x86_64.deb
- sudo apt-get -q update
- sudo apt-get install -y yamllint
- sudo wget -nv https://releases.hashicorp.com/vagrant/${VAGRANT_VERSION}/vagrant_${VAGRANT_VERSION}_x86_64.deb
- sudo dpkg -i vagrant_${VAGRANT_VERSION}_x86_64.deb

install:
- pip install "$ANSIBLE_VERSION"
- sudo pip install "ansible-core$ANSIBLE_VERSION"
- sudo pip install ansible-lint
- ansible-galaxy collection install community.general

script:
- VAGRANT_DEFAULT_PROVIDER=docker vagrant up $PLATFORM
Expand All @@ -37,6 +42,14 @@ script:
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
- VAGRANT_DEFAULT_PROVIDER=docker vagrant status
- >
yamllint .
&& (echo 'YAML lint test: pass' && exit 0)
|| (echo 'YAML lint test: fail' && exit 1)
- >
ansible-lint -v tests/test.yml
&& (echo 'Ansible lint test: pass' && exit 0)
|| (echo 'Ansible lint test: fail' && exit 1)
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
6 changes: 6 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

extends: default

rules:
line-length: disable
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
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://travis-ci.org/HanXHX/ansible-php.svg?branch=master)](https://travis-ci.org/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
---------------------

| OS | PHP 7.0 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 |
|:---------------------:|:-------------------:|:--------------------------:|:--------------------------:|:-------------------------:|:--------------------------:
| Debian Stretch (9) | :heavy_check_mark: | :heavy_check_mark: (Sury) | :heavy_check_mark: (Sury) | :heavy_check_mark: (Sury) | :heavy_check_mark: (Sury) |
| Debian Buster (10) | :x: | :x: | :x: | :heavy_check_mark: | :heavy_check_mark: (Sury) |
| Ubuntu Xenial (16.04) | :heavy_check_mark: | :x: | :x: | :x: | :x: |
| Ubuntu Bionic (18.04) | :x: | :x: | :heavy_check_mark: | :x: | :x: |
| FreeBSD 11 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Need tests... |
| FreeBSD 12 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Need tests... |
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:

| OS | PHP 7.0 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP >= 7.4 |
|:---------------------:|:-------------------:|:--------------------:|:--------------------:|:--------------------:|:--------------------:
| Ubuntu Bionic (18.04) | :x: | :x: | :heavy_check_mark: | :x: | :x: |
| FreeBSD 11 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Need tests... |
| FreeBSD 12 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Need tests... |

Links:
- [Sury](https://deb.sury.org/)

Requirements
------------

If you need PHP-FPM, you must install a webserver with FastCGI support. You can use my [nginx role](https://github.com/HanXHX/ansible-nginx).
- Ansible >= 2.11
- Collections: [community.general](https://galaxy.ansible.com/community/general)
- If you need PHP-FPM, you must install a webserver with FastCGI support. You can use my [nginx role](https://github.com/HanXHX/ansible-nginx).

FreeBSD limitations
-------------------
Expand Down Expand Up @@ -160,12 +163,12 @@ Example Playbook
roles:
- { role: HanXHX.php }

### Debian Stretch with PHP 7.2 CLI (no FPM)
### Debian Bullseye with PHP 8.0 CLI (no FPM)

- hosts: servers
roles:
- { role: HanXHX.sury }
- { role: HanXHX.php, php_version: '7.2', php_install_fpm: false }
- { role: HanXHX.php, php_version: '8.0', php_install_fpm: false }

License
-------
Expand Down
44 changes: 25 additions & 19 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
Vagrant.configure("2") do |config|

vms_debian = [
{ :name => "debian-stretch-php70", :box => "debian/stretch64", :vars => { }},
{ :name => "debian-stretch-php71", :box => "debian/stretch64", :vars => { "php_version": '7.1' }},
{ :name => "debian-stretch-php72", :box => "debian/stretch64", :vars => { "php_version": '7.2' }},
{ :name => "debian-stretch-php73", :box => "debian/stretch64", :vars => { "php_version": '7.3' }},
{ :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 => "ubuntu-xenial-php70", :box => "ubuntu/xenial64", :vars => { }},
{ :name => "ubuntu-bionic-php72", :box => "ubuntu/bionic64", :vars => { }},
{ :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 => { }},
{ :name => "debian-bullseye-php80", :box => "debian/bullseye64", :vars => { "php_version": '8.0' }},
{ :name => "ubuntu-bionic-php72", :box => "ubuntu/bionic64", :vars => { }},
]

vms_freebsd = [
Expand All @@ -23,15 +21,13 @@ Vagrant.configure("2") do |config|
]

conts = [
{ :name => "docker-debian-stretch-php70", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { }},
{ :name => "docker-debian-stretch-php71", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.1' }},
{ :name => "docker-debian-stretch-php72", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.2' }},
{ :name => "docker-debian-stretch-php73", :docker => "hanxhx/vagrant-ansible:debian9", :vars => { "php_version": '7.3' }},
{ :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-ubuntu-xenial-php70", :docker => "hanxhx/vagrant-ansible:ubuntu16.04", :vars => { }},
{ :name => "docker-ubuntu-bionic-php72", :docker => "hanxhx/vagrant-ansible:ubuntu18.04", :vars => { }},
{ :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 => { }},
{ :name => "docker-debian-bullseye-php80", :docker => "hanxhx/vagrant-ansible:debian11", :vars => { "php_version": '8.0' }},
{ :name => "docker-ubuntu-bionic-php72", :docker => "hanxhx/vagrant-ansible:ubuntu18.04", :vars => { }},
]

config.vm.network "private_network", type: "dhcp"
Expand All @@ -43,7 +39,12 @@ Vagrant.configure("2") do |config|
d.remains_running = true
d.has_ssh = true
end
m.vm.provision "shell", inline: "apt-get update && apt-get install -y python python-apt"

if opts[:name].include? "bullseye"
m.vm.provision "shell", inline: "[ -f '/root/first_provision' ] || (apt-get update -qq && apt-get -y dist-upgrade && touch /root/first_provision)"
end

#m.vm.provision "shell", inline: "apt-get update && apt-get install -y python python-apt"
m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv'
Expand All @@ -61,6 +62,11 @@ Vagrant.configure("2") do |config|
v.memory = 256
end
m.vm.provision "shell", inline: "apt-get update && apt-get install -y ifupdown python"

if opts[:name].include? "bullseye"
m.vm.provision "shell", inline: "[ -f '/root/first_provision' ] || (apt-get update -qq && apt-get -y dist-upgrade && touch /root/first_provision)"
end

m.vm.provision "ansible" do |ansible|
ansible.playbook = "tests/test.yml"
ansible.verbose = 'vv'
Expand Down
4 changes: 2 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---

- name: restart php-fpm
service:
ansible.builtin.service:
name: '{{ php_fpm_service }}'
state: restarted
when: php_install_fpm
notify: docker restart php-fpm

- name: docker restart php-fpm
command: 'service {{ php_fpm_service }} restart'
ansible.builtin.command: 'service {{ php_fpm_service }} restart'
args:
warn: false
when: ansible_virtualization_type == 'docker'
48 changes: 24 additions & 24 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
---
galaxy_info:
author: Emilien Mantel
description: Install and configure PHP 7.0/7.1/7.2/7.3
description: Install and configure PHP 7.0/7.1/7.2/7.3/7.4/8.0
company:
license: GPLv2
min_ansible_version: 2.6
min_ansible_version: 2.11
platforms:
- name: Debian
versions:
- stretch
- buster
- name: Ubuntu
versions:
- xenial
- bionic
- name: FreeBSD
versions:
- 11.0
- 11.1
- 12.0
- name: Debian
versions:
- stretch
- buster
- bullseye
- name: Ubuntu
versions:
- bionic
- name: FreeBSD
versions:
- 11.0
- 11.1
- 12.0
galaxy_tags:
- development
- web
- php
- php-fpm
- php7
- debian
- ubuntu
- freebsd
- development
- web
- php
- fpm
- php7
- php8
- debian
- ubuntu
- freebsd
dependencies: []

20 changes: 13 additions & 7 deletions tasks/fpm.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
---

- name: APT | Install PHP-FPM for Debian based systems
apt:
ansible.builtin.apt:
pkg: "{{ php_fpm_service }}"
state: "{{ 'present' if php_install_fpm else 'absent' }}"
when: ansible_os_family == 'Debian'

- name: SERVICE | Enable service on FreeBSD
service:
ansible.builtin.service:
name: "{{ php_fpm_service }}"
enabled: "{{ 'yes' if php_install_fpm else 'no' }}"
enabled: "{{ 'true' if php_install_fpm else 'false' }}"
when: ansible_os_family == 'FreeBSD'

- name: LINEINFILE | PHP configuration
lineinfile:
ansible.builtin.lineinfile:
dest: '{{ php_fpm_ini }}'
regexp: '^;?{{ item.key }}'
line: '{{ item.key }} = {{ item.value }}'
create: yes
create: true
owner: root
group: root
mode: 0644
loop: "{{ php_ini | combine(php_ini_fpm) | dict2items }}"
notify: restart php-fpm

- name: TEMPLATE | Deploy pool configuration
template:
ansible.builtin.template:
src: etc/__php__/fpm/pool.d/pool.conf.j2
dest: '{{ php_fpm_pool_dir }}/{{ item.name }}.conf'
owner: root
group: root
mode: 0644
loop: "{{ ansible_local.hanxhx_php.fpm_pool }}"
notify: restart php-fpm

- name: FILE | Delete default pool if necessary
file:
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'
Expand Down
Loading

0 comments on commit 309824d

Please sign in to comment.