Lenverge/roles/php/tasks/main.yml
2025-06-15 13:52:01 +08:00

42 lines
1.2 KiB
YAML

---
- name: "Install required PHP versions and extensions"
ansible.builtin.apt:
name:
- "php{{ item }}"
- "php{{ item }}-fpm"
- "php{{ item }}-cli"
- "php{{ item }}-common"
- "php{{ item }}-mysql"
- "php{{ item }}-pgsql"
- "php{{ item }}-xml"
- "php{{ item }}-zip"
- "php{{ item }}-mbstring"
- "php{{ item }}-curl"
- "php{{ item }}-bcmath"
state: present
loop: "{{ php_versions_to_install }}"
when: php_versions_to_install is defined and php_versions_to_install | length > 0
- name: "Ensure all PHP-FPM services are enabled and started"
ansible.builtin.service:
name: "php{{ item }}-fpm"
enabled: yes
state: started
loop: "{{ php_versions_to_install }}"
when: php_versions_to_install is defined and php_versions_to_install | length > 0
- name: "Deploy the smart PHP wrapper script"
ansible.builtin.template:
src: php-wrapper.sh.j2
dest: /usr/local/bin/php
owner: root
group: root
mode: '0755'
- name: "Deploy the smart Artisan wrapper script"
ansible.builtin.template:
src: artisan-wrapper.sh.j2
dest: /usr/local/bin/artisan
owner: root
group: root
mode: '0755'