initial ansible code

This commit is contained in:
Oli
2022-10-09 21:41:56 +00:00
parent 4a64eab4a0
commit feaec34dd2
103 changed files with 4473 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
# Default PHP installation without version/module specification
# php_old_version: # specify old verison to uninstall
php_version: "8.1"
php_modules: ["common"]

View File

@@ -0,0 +1,5 @@
---
- name: restart php-fpm
systemd:
name: php{{ php_version }}-fpm.service
state: reloaded

3
roles/php/meta/main.yml Normal file
View File

@@ -0,0 +1,3 @@
---
dependencies:
- role: nginx

29
roles/php/tasks/main.yml Normal file
View File

@@ -0,0 +1,29 @@
---
- name: Add Sury PHP Repository
apt_repository:
repo: ppa:ondrej/php
state: present
update_cache: true
when: php_version is defined # add repo when version is specified, otherwise use default repo
- name: "Uninstall old PHP version"
apt:
name: "php{{ php_old_version }}*"
state: absent
purge: true
when: php_old_version is defined # uninstall when old version is specified
- name: "Install custom PHP modules {{ php_modules }}"
apt:
name: "{{ ['php' + php_version] | product(php_modules) | map('join', '-') | list }}"
state: latest
update_cache: true
cache_valid_time: 3600
- name: Copy Nginx PHP-Handler
template:
dest: /etc/nginx/conf.d/php-handler.conf
src: php-handler.conf.j2
mode: 0644
when: '"fpm" in php_modules'
notify: reload nginx

View File

@@ -0,0 +1,6 @@
## Managed by Ansible ##
# PHP Handler
upstream php-handler {
server unix:{{ php_socket }};
}

2
roles/php/vars/main.yml Normal file
View File

@@ -0,0 +1,2 @@
---
php_socket: "/run/php/php{{ php_version }}-fpm.sock"