mirror of
https://github.com/HanXHX/ansible-php.git
synced 2026-03-16 11:02:10 +07:00
Use FQCN builtins
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
---
|
||||
|
||||
- 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 }}'
|
||||
@@ -25,7 +25,7 @@
|
||||
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
|
||||
@@ -35,7 +35,7 @@
|
||||
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'
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
---
|
||||
|
||||
- name: INCLUDE_VARS | Related to OS family
|
||||
include_vars: "OS_Family_{{ ansible_os_family }}.yml"
|
||||
ansible.builtin.include_vars: "OS_Family_{{ ansible_os_family }}.yml"
|
||||
|
||||
- name: INCLUDE_VARS | Related to OS version
|
||||
include_vars: "{{ item }}"
|
||||
ansible.builtin.include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
|
||||
|
||||
- name: SET_FACT | Transform data
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
__php_fpm_full_pool: |
|
||||
[
|
||||
{% for p in php_fpm_poold %}
|
||||
@@ -32,17 +32,20 @@
|
||||
]
|
||||
|
||||
- name: SET_FACT | To YAML
|
||||
set_fact:
|
||||
ansible.builtin.set_fact:
|
||||
php_fpm_full_pool: "{{ __php_fpm_full_pool | from_yaml }}"
|
||||
|
||||
- name: FILE | Creates ansible facts.d
|
||||
file:
|
||||
ansible.builtin.file:
|
||||
path: /etc/ansible/facts.d
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
recurse: true
|
||||
|
||||
- name: COPY | Manage facts
|
||||
copy:
|
||||
ansible.builtin.copy:
|
||||
content: "{ \"fpm_pool\": {{ php_fpm_full_pool | to_nice_json }} }"
|
||||
dest: /etc/ansible/facts.d/hanxhx_php.fact
|
||||
owner: root
|
||||
@@ -51,13 +54,13 @@
|
||||
register: f
|
||||
|
||||
- name: SETUP | Gathers new facts
|
||||
setup:
|
||||
ansible.builtin.setup:
|
||||
when: f.changed
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: APT | Install PHP packages
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ pkgs }}"
|
||||
state: present
|
||||
update_cache: true
|
||||
@@ -68,29 +71,29 @@
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: PKGNG | Install PHP packages
|
||||
pkgng:
|
||||
ansible.builtin.pkgng:
|
||||
name: "{{ php_packages + php_extra_packages | flatten | join(',') }}"
|
||||
notify: restart php-fpm
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
- name: IMPORT_TASKS | PHP-FPM
|
||||
import_tasks: fpm.yml
|
||||
ansible.builtin.import_tasks: fpm.yml
|
||||
|
||||
- name: LINEINFILE | PHP CLI configuration
|
||||
lineinfile:
|
||||
ansible.builtin.lineinfile:
|
||||
dest: '{{ php_cli_ini }}'
|
||||
regexp: '^;?{{ item.key }}'
|
||||
line: '{{ item.key }} = {{ item.value }}'
|
||||
loop: "{{ php_ini | combine(php_ini_cli) | dict2items }}"
|
||||
|
||||
- name: IMPORT_TASKS | Xdebug
|
||||
import_tasks: xdebug.yml
|
||||
ansible.builtin.import_tasks: xdebug.yml
|
||||
|
||||
- name: APT | Install and configure opcache
|
||||
import_tasks: opcache.yml
|
||||
ansible.builtin.import_tasks: opcache.yml
|
||||
|
||||
- name: SERVICE | Ensure PHP-FPM is started
|
||||
service:
|
||||
ansible.builtin.service:
|
||||
name: '{{ php_fpm_service }}'
|
||||
state: started
|
||||
when: php_install_fpm and ansible_virtualization_type != 'docker'
|
||||
@@ -98,7 +101,7 @@
|
||||
- block:
|
||||
|
||||
- name: COMMAND | Check if PHP-FPM is started (Docker)
|
||||
command: 'service {{ php_fpm_service }} status'
|
||||
ansible.builtin.command: 'service {{ php_fpm_service }} status'
|
||||
args:
|
||||
warn: false
|
||||
register: dps
|
||||
@@ -106,7 +109,7 @@
|
||||
failed_when: false
|
||||
|
||||
- name: COMMAND | Ensure PHP-FPM is started (Docker)
|
||||
command: 'service {{ php_fpm_service }} start'
|
||||
ansible.builtin.command: 'service {{ php_fpm_service }} start'
|
||||
args:
|
||||
warn: false
|
||||
when: dps.stdout.find('is not running') != -1
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
- block:
|
||||
|
||||
- name: APT | Install APCu
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "php-apcu"
|
||||
|
||||
- name: APT | Install Opcache
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ php_package_prefix }}opcache"
|
||||
|
||||
when: ansible_os_family == 'Debian'
|
||||
@@ -15,17 +15,17 @@
|
||||
- block:
|
||||
|
||||
- name: PKGNG | Install APCu
|
||||
pkgng:
|
||||
ansible.builtin.pkgng:
|
||||
name: "php{{ php_version | replace('.', '') }}-pecl-APCu"
|
||||
|
||||
- name: PKGNG | Install Opcache
|
||||
pkgng:
|
||||
ansible.builtin.pkgng:
|
||||
name: "{{ php_package_prefix }}opcache"
|
||||
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
- name: TEMPLATE | Configure Opcache
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "etc/__php__/mods-available/opcache.ini.j2"
|
||||
dest: "{{ php_mods_dir }}/opcache.ini"
|
||||
owner: root
|
||||
@@ -34,7 +34,7 @@
|
||||
notify: restart php-fpm
|
||||
|
||||
- name: TEMPLATE | Configure APCu
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "etc/__php__/mods-available/apcu.ini.j2"
|
||||
dest: "{{ php_mods_dir }}/apcu.ini"
|
||||
owner: root
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
- block:
|
||||
|
||||
- name: APT | Install xdebug
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ php_xdebug_package }}"
|
||||
state: present
|
||||
update_cache: true
|
||||
@@ -11,12 +11,12 @@
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: PKGNG | Install xdebug
|
||||
pkgng:
|
||||
ansible.builtin.pkgng:
|
||||
name: "{{ php_xdebug_package }}"
|
||||
when: ansible_os_family == 'FreeBSD' and php_xdebug_package is defined
|
||||
|
||||
- name: TEMPLATE | Deploy module configurations
|
||||
template:
|
||||
ansible.builtin.template:
|
||||
src: "etc/__php__/mods-available/xdebug.ini.j2"
|
||||
dest: "{{ php_mods_dir }}/xdebug.ini"
|
||||
owner: root
|
||||
@@ -28,13 +28,13 @@
|
||||
- block:
|
||||
|
||||
- name: APT | Uninstall xdebug
|
||||
apt:
|
||||
ansible.builtin.apt:
|
||||
pkg: "{{ php_xdebug_package }}"
|
||||
state: absent
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- name: PKGNG | Uninstall xdebug
|
||||
pkgng:
|
||||
ansible.builtin.pkgng:
|
||||
name: "{{ php_xdebug_package }}"
|
||||
state: absent
|
||||
when: ansible_os_family == 'FreeBSD'
|
||||
|
||||
Reference in New Issue
Block a user