ansible-role-php/tasks/php.yml
2023-03-17 21:55:48 +01:00

59 lines
2 KiB
YAML

---
- name: "PHP | Copy custom PHP configuration"
ansible.builtin.template:
src: php.ini
dest: "/etc/php/{{ php_version.stdout }}/mods-available/{{ inventory_hostname }}.ini"
mode: "0644"
- name: "PHP | Copy custom PHP-FPM configuration"
ansible.builtin.template:
src: php-fpm.ini
dest: "/etc/php/{{ php_version.stdout }}/mods-available/{{ inventory_hostname }}-fpm.ini"
mode: "0644"
- name: "PHP | Enable PHP configuration for mod_php"
ansible.builtin.file:
src: "/etc/php/{{ php_version.stdout }}/mods-available/{{ inventory_hostname }}.ini"
dest: "/etc/php/{{ php_version.stdout }}/apache2/conf.d/30-{{ inventory_hostname }}.ini"
state: link
when: "'apache_php_module_name' in ansible_facts.packages"
notify: reload apache2
- name: "PHP | Enable PHP cli configuration"
ansible.builtin.file:
src: "/etc/php/{{ php_version.stdout }}/mods-available/{{ inventory_hostname }}.ini"
dest: "/etc/php/{{ php_version.stdout }}/cli/conf.d/30-{{ inventory_hostname }}.ini"
state: link
- name: "PHP | Create log directory"
ansible.builtin.file:
path: "{{ php_fpm_log_dir }}"
state: directory
mode: "0755"
- name: "PHP | Enable PHP FPM configuration"
ansible.builtin.file:
src: "/etc/php/{{ php_version.stdout }}/mods-available/{{ inventory_hostname }}-fpm.ini"
dest: "/etc/php/{{ php_version.stdout }}/fpm/conf.d/30-{{ inventory_hostname }}-fpm.ini"
state: link
when: "'php-fpm' in ansible_facts.packages"
notify: reload php-fpm
- name: "PHP | Copy template for PHP-FPM systemd service and socket"
ansible.builtin.template:
src: "systemd/{{ item }}"
dest: "/etc/systemd/system/{{ item }}"
mode: "0644"
loop:
- php-fpm@.service
- php-fpm@.socket
notify:
- stop php-fpm-socket
- stop php-fpm-service
- start php-fpm-socket
- name: "PHP | Create systemd override directory"
ansible.builtin.file:
path: /etc/systemd/system/php-fpm@.service.d
state: directory
mode: "0755"