⚗️ Modernize and add CI

This commit is contained in:
Emilien Mantel
2025-06-02 12:09:08 +02:00
parent 4aef107c1a
commit b0834f9a1a
49 changed files with 599 additions and 506 deletions

View File

@@ -6,12 +6,6 @@
state: "{{ 'present' if php_install_fpm else 'absent' }}"
when: ansible_os_family == 'Debian'
- name: SERVICE | Enable service on FreeBSD
ansible.builtin.service:
name: "{{ php_fpm_service }}"
enabled: "{{ 'true' if php_install_fpm else 'false' }}"
when: ansible_os_family == 'FreeBSD'
- name: LINEINFILE | PHP configuration
ansible.builtin.lineinfile:
dest: '{{ php_fpm_ini }}'
@@ -22,7 +16,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 +26,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

View File

@@ -19,6 +19,11 @@
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- name: SET_FACT | Prepare PHP version if not defined
ansible.builtin.set_fact:
php_version: "{{ php_default_version }}"
when: php_version is none or php_version == '' or php_version is not defined
- name: SET_FACT | Transform data
ansible.builtin.set_fact:
__php_fpm_full_pool: |
@@ -54,7 +59,7 @@
- name: COPY | Manage facts
ansible.builtin.copy:
content: "{ \"fpm_pool\": {{ php_fpm_full_pool | to_nice_json }} }"
content: "{ \"fpm_pool\": {{ php_fpm_full_pool | to_nice_json }}, \"php_version\": \"{{ php_version }}\" }"
dest: /etc/ansible/facts.d/hanxhx_php.fact
owner: root
group: root
@@ -76,14 +81,7 @@
install_recommends: false
vars:
pkgs: "{{ php_packages + php_extra_packages | flatten }}"
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
when: ansible_os_family == 'FreeBSD'
notify: Restart php-fpm
- name: IMPORT_TASKS | PHP-FPM
ansible.builtin.import_tasks: fpm.yml
@@ -101,26 +99,9 @@
- name: APT | Install and configure opcache
ansible.builtin.import_tasks: opcache.yml
- name: SERVICE | Ensure PHP-FPM is started
- name: SERVICE | Ensure PHP-FPM is started and enabled
when: php_install_fpm
ansible.builtin.service:
name: '{{ php_fpm_service }}'
state: started
when: php_install_fpm and ansible_virtualization_type != 'docker'
- block:
- name: COMMAND | Check if PHP-FPM is started (Docker)
ansible.builtin.command: 'service {{ php_fpm_service }} status'
args:
warn: false
register: dps
changed_when: false
failed_when: false
- name: COMMAND | Ensure PHP-FPM is started (Docker)
ansible.builtin.command: 'service {{ php_fpm_service }} start'
args:
warn: false
when: dps.stdout.find('is not running') != -1
when: php_install_fpm and ansible_virtualization_type == 'docker'
enabled: true

View File

@@ -1,30 +1,14 @@
---
- block:
- name: APT | Install APCu
ansible.builtin.apt:
pkg: "{{ php_apcu_package }}"
install_recommends: false
- name: APT | Install APCu
ansible.builtin.apt:
pkg: "{{ php_apcu_package }}"
install_recommends: false
- name: APT | Install Opcache
ansible.builtin.apt:
pkg: "{{ php_package_prefix }}opcache"
install_recommends: false
when: ansible_os_family == 'Debian'
- block:
- name: PKGNG | Install APCu
community.general.pkgng:
name: "php{{ php_version | replace('.', '') }}-pecl-APCu"
- name: PKGNG | Install Opcache
community.general.pkgng:
name: "{{ php_package_prefix }}opcache"
when: ansible_os_family == 'FreeBSD'
- name: APT | Install Opcache
ansible.builtin.apt:
pkg: "{{ php_package_prefix }}opcache"
install_recommends: false
- name: TEMPLATE | Configure Opcache
ansible.builtin.template:
@@ -33,7 +17,7 @@
owner: root
group: root
mode: 0644
notify: restart php-fpm
notify: Restart php-fpm
- name: TEMPLATE | Configure APCu
ansible.builtin.template:
@@ -42,4 +26,4 @@
owner: root
group: root
mode: 0644
notify: restart php-fpm
notify: Restart php-fpm

View File

@@ -1,7 +1,8 @@
---
- block:
- name: BLOCK | Install Xdebug
when: php_install_xdebug
block:
- name: APT | Install xdebug
ansible.builtin.apt:
pkg: "{{ php_xdebug_package }}"
@@ -11,33 +12,16 @@
install_recommends: false
when: ansible_os_family == 'Debian'
- name: PKGNG | Install xdebug
community.general.pkgng:
name: "{{ php_xdebug_package }}"
when: ansible_os_family == 'FreeBSD' and php_xdebug_package is defined
- name: TEMPLATE | Deploy module configurations
ansible.builtin.template:
src: "etc/__php__/mods-available/xdebug.ini.j2"
dest: "{{ php_mods_dir }}/xdebug.ini"
owner: root
mode: 0644
notify: restart php-fpm
when: php_install_xdebug
- block:
- name: APT | Uninstall xdebug
ansible.builtin.apt:
pkg: "{{ php_xdebug_package }}"
state: absent
when: ansible_os_family == 'Debian'
- name: PKGNG | Uninstall xdebug
community.general.pkgng:
name: "{{ php_xdebug_package }}"
state: absent
when: ansible_os_family == 'FreeBSD'
notify: Restart php-fpm
- name: APT | Uninstall xdebug
ansible.builtin.apt:
pkg: "{{ php_xdebug_package }}"
state: absent
when: not php_install_xdebug