This commit is contained in:
decentral1se
2022-05-30 09:34:37 +02:00
commit f2506c4203
11 changed files with 252 additions and 0 deletions

36
tasks/composer.yml Normal file
View File

@ -0,0 +1,36 @@
---
- name: Check if Composer is installed
tags: composer
stat:
path: /usr/local/bin/composer
register: composer_bin
- block:
- name: Download Composer into tmp directory
get_url:
url: https://getcomposer.org/installer
dest: "{{ php_composer_install_file }}"
checksum: "{{ php_composer_checksum }}"
- name: Run Composer installer
command: "
php {{ php_composer_install_file }}
--install-dir=/usr/local/bin
--filename=composer
--version={{ php_composer_version }}
"
- name: Delete composer installer
file:
path: "{{ php_composer_install_file }}"
state: absent
tags: composer
when: not composer_bin.stat.exists
- name: Update composer if necessary
tags: composer
shell: composer selfupdate
register: composer_update_output
changed_when: "'Updating to version' in composer_update_output.stdout"
when: php_composer_update | bool

7
tasks/main.yml Normal file
View File

@ -0,0 +1,7 @@
---
- import_tasks: php.yml
- import_tasks: composer.yml
when: php_composer_install | bool
tags: php-composer

43
tasks/php.yml Normal file
View File

@ -0,0 +1,43 @@
---
- name: Install APT HTTPS support
package:
name: apt-transport-https
state: present
- name: Install signed GPG key for sury.org PHP packages
apt_key:
url: https://packages.sury.org/php/apt.gpg
id: 15058500A0235D97F5D10063B188E2B695BD4743
state: present
- name: Install APT repository for sury.org PHP packages
apt_repository:
repo: "deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main"
state: present
- name: Refresh the APT cache
apt:
update_cache: true
retries: 3
delay: 10
tags:
- molecule-idempotence-notest
- name: "Install PHP {{ php_ver }}"
apt:
name: "{{ item.name }}"
state: "{{ item.state }}"
with_items: "{{ php_extensions }}"
- name: "Start php{{ php_ver }}-fpm service"
service:
name: "php{{ php_ver }}-fpm"
state: started
enabled: true
- name: Install PHP configuration file
template:
src: php.ini.j2
dest: "/etc/php/{{ php_ver }}/fpm/php.ini"
notify: Reload php-fpm