New release (#14)

* Manages Debian 11
* Migrate to new TravisCI version
* Fix lint errors
* Use FQCN builtins
* Drop Ubuntu Xenial support (16.04)
This commit is contained in:
Emilien M
2021-09-01 09:57:23 +02:00
committed by GitHub
parent 3209f6b010
commit 309824dabf
22 changed files with 276 additions and 194 deletions

View File

@@ -1,9 +1,9 @@
---
- name: APT | Install Sury key
apt_key:
ansible.builtin.apt_key:
url: 'https://packages.sury.org/php/apt.gpg'
- name: APT_REPOSITORY | Add Sury repository
apt_repository:
ansible.builtin.apt_repository:
repo: 'deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main'

View File

@@ -1,25 +1,24 @@
---
- name: SET_FACT | Prepare test vars
set_fact:
ansible.builtin.set_fact:
__nginx_conf: /etc/nginx/nginx.conf
- name: APT | Install packages
apt:
ansible.builtin.apt:
pkg: "{{ p }}"
update_cache: yes
update_cache: true
cache_valid_time: 3600
vars:
p:
- apt-transport-https
- ca-certificates
- curl
- gpg
- lsb-release
- nginx
- vim
- name: INCLUDE_TASKS | Sury
include_tasks: Debian/sury.yml
when:
((ansible_distribution_major_version is version('9', 'eq')) and (php_version is version('7.1', 'ge'))) or
((ansible_distribution_major_version is version('10', 'eq')) and (php_version is version('7.4', 'ge')))
ansible.builtin.include_tasks: Debian/sury.yml
when: php_version != php_default_version

View File

@@ -1,10 +1,10 @@
---
- name: SET_FACT | Prepare test vars
set_fact:
ansible.builtin.set_fact:
__nginx_conf: /usr/local/etc/nginx/nginx.conf
php_xdebug_package: 'php72-pecl-xdebug-2.6.1'
- name: PKGNG | Install packages
pkgng:
community.general.pkgng:
name: ['curl', 'nginx']

View File

@@ -32,70 +32,73 @@
pre_tasks:
- name: INCLUDE_TASKS | Pre tasks related to OS
include_tasks: "includes/pre_{{ ansible_os_family }}.yml"
ansible.builtin.include_tasks: "includes/pre_{{ ansible_os_family }}.yml"
- name: USER | Create PHP user
user:
ansible.builtin.user:
name: 'foo'
system: yes
create_home: no
system: true
create_home: false
shell: '/usr/sbin/nologin'
tasks:
- name: TEMPLATE | Nginx site config
template:
ansible.builtin.template:
src: "templates/nginx.conf.j2"
dest: "{{ __nginx_conf }}"
mode: 0644
owner: root
group: root
notify: reload nginx
- name: COMMAND | Fix nginx config
command: "cp {{ __nginx_conf | dirname }}/fastcgi_params {{ __nginx_conf | dirname }}/fastcgi.conf"
ansible.builtin.command: "cp {{ __nginx_conf | dirname }}/fastcgi_params {{ __nginx_conf | dirname }}/fastcgi.conf"
args:
creates: "{{ __nginx_conf | dirname }}/fastcgi.conf"
notify: reload nginx
- name: LINEINFILE | Fix nginx config (second step)
lineinfile:
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
- name: SERVICE | Ensure nginx is started
service:
ansible.builtin.service:
name: nginx
state: started
when: ansible_virtualization_type != 'docker'
- block:
- name: COMMAND | Docker nginx status
command: service nginx status
args:
warn: false
changed_when: false
failed_when: false
register: ngs
- name: COMMAND | Docker nginx status
ansible.builtin.command: service nginx status
args:
warn: false
changed_when: false
failed_when: false
register: ngs
- name: COMMAND | Docker start nginx
command: service nginx start
args:
warn: false
when: ngs.stdout.find('nginx is not running') != -1
- name: COMMAND | Docker start nginx
ansible.builtin.command: service nginx start
args:
warn: false
when: ngs.stdout.find('nginx is not running') != -1
when: ansible_virtualization_type == 'docker'
handlers:
- name: reload nginx
service:
ansible.builtin.service:
name: nginx
state: reloaded
notify: docker reload nginx
- name: docker reload nginx
command: service nginx reload
ansible.builtin.command: service nginx reload
args:
warn: false
notify: docker reload nginx
@@ -107,36 +110,48 @@
post_tasks:
- name: SHELL | Test php-cli
shell: php -i | grep '^PHP Version => {{ php_version }}' | head -n 1
ansible.builtin.shell: set -o pipefail && php -i | grep '^PHP Version => {{ php_version }}' | head -n 1
changed_when: false
register: p
failed_when: p.stdout == ''
args:
executable: /bin/bash
- name: FILE | Create /var/www
file:
ansible.builtin.file:
dest: /var/www
state: directory
owner: root
group: root
mode: 0755
- name: COPY | Add phpinfo
copy:
ansible.builtin.copy:
dest: /var/www/phpinfo.php
content: '<?php phpinfo();'
owner: root
group: root
mode: 0644
- name: COPY | Add ini test file
copy:
ansible.builtin.copy:
dest: /var/www/ini.php
content: '<?php echo ini_get("memory_limit") . "\n";'
owner: root
group: root
mode: 0644
- 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'"
ansible.builtin.shell: "set -o pipefail && 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'"
args:
warn: false
executable: /bin/bash
changed_when: false
register: c
failed_when: c.stdout == ''
- name: SHELL | Check custom php value
shell: "curl -H 'Host: {{ vhost }}' http://127.0.0.1/ini.php 2> /dev/null"
ansible.builtin.shell: "curl -H 'Host: {{ vhost }}' http://127.0.0.1/ini.php 2> /dev/null"
args:
warn: false
changed_when: false
@@ -144,11 +159,11 @@
failed_when: 'php_fpm_poold.1.php_admin_value.memory_limit not in c.stdout'
- name: URI | Check ping
uri:
ansible.builtin.uri:
url: "http://localhost{{ php_fpm_poold.0.ping_path }}"
when: php_fpm_poold.0.ping_path is defined
- name: URI | Check status
uri:
ansible.builtin.uri:
url: "http://localhost{{ php_fpm_poold.0.status_path }}"
when: php_fpm_poold.0.status_path is defined