lxc-php: refactor tasks for better maintainability
This commit is contained in:
parent
2d2889ac16
commit
12cebfa71c
|
@ -35,14 +35,15 @@ The **patch** part changes incrementally at each release.
|
||||||
* evolinux-base: use "evolinux_internal_group" for SSH authentication
|
* evolinux-base: use "evolinux_internal_group" for SSH authentication
|
||||||
* evomaintenance: Turn on API by default (instead of DB)
|
* evomaintenance: Turn on API by default (instead of DB)
|
||||||
* evomaintenance: upstream version 0.5.1
|
* evomaintenance: upstream version 0.5.1
|
||||||
* php: By default, allow 128M for OpCache (instead of 64M)
|
|
||||||
* squid: Remove wait time when we turn off squid
|
|
||||||
* squid: split systemd tasks into own file
|
|
||||||
* varnish: remove custom ExecReload= script for Debian 10+
|
|
||||||
* lxc: remove useless loop in apt execution
|
* lxc: remove useless loop in apt execution
|
||||||
* lxc: update our default template to be compatible with Debian 10
|
* lxc: update our default template to be compatible with Debian 10
|
||||||
* lxc: rely on lxc_container module instead of command module
|
* lxc: rely on lxc_container module instead of command module
|
||||||
|
* lxc-php: refactor tasks for better maintainability
|
||||||
|
* php: By default, allow 128M for OpCache (instead of 64M)
|
||||||
* php: Don't set a chroot for the default fpm pool
|
* php: Don't set a chroot for the default fpm pool
|
||||||
|
* squid: Remove wait time when we turn off squid
|
||||||
|
* squid: split systemd tasks into own file
|
||||||
|
* varnish: remove custom ExecReload= script for Debian 10+
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* lxc-php: Don't remove the default pool
|
* lxc-php: Don't remove the default pool
|
||||||
|
|
|
@ -3,16 +3,22 @@
|
||||||
include_role:
|
include_role:
|
||||||
name: lxc
|
name: lxc
|
||||||
|
|
||||||
- include: "php.yml name={{item.name}}"
|
- name: Update APT cache
|
||||||
|
command: "lxc-attach -n {{name}} -- apt-get update"
|
||||||
|
|
||||||
|
- include: "php56.yml"
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ lxc_containers }}"
|
- "{{ lxc_containers }}"
|
||||||
|
when: name == "php56"
|
||||||
|
|
||||||
- name: Ensure containers root directory is 755
|
- include: "php70.yml"
|
||||||
file:
|
|
||||||
path: "/var/lib/lxc/{{ item.name }}/rootfs"
|
|
||||||
state: directory
|
|
||||||
mode: '0755'
|
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ lxc_containers }}"
|
- "{{ lxc_containers }}"
|
||||||
|
when: name == "php70"
|
||||||
|
|
||||||
|
- include: "php73.yml"
|
||||||
|
with_items:
|
||||||
|
- "{{ lxc_containers }}"
|
||||||
|
when: name == "php73"
|
||||||
|
|
||||||
|
- include: "misc.yml"
|
||||||
|
|
24
lxc-php/tasks/misc.yml
Normal file
24
lxc-php/tasks/misc.yml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Configure ssmtp
|
||||||
|
replace:
|
||||||
|
name: "/var/lib/lxc/{{name}}/rootfs/etc/ssmtp/ssmtp.conf"
|
||||||
|
regexp: "{{ item.regexp }}"
|
||||||
|
replace: "{{ item.replace }}"
|
||||||
|
with_dict:
|
||||||
|
- { regexp: "^mailhub=.*$", replace: "mailhub=127.0.0.1"}
|
||||||
|
- { regexp: "^#FromLineOverride=.*$", replace: "FromLineOverride=YES"}
|
||||||
|
- { regexp: "^hostname=.*", replace: "hostname={{ansible_fqdn}}"}
|
||||||
|
|
||||||
|
- name: Configure timezone
|
||||||
|
copy:
|
||||||
|
dest: "/var/lib/lxc/{{name}}/rootfs/etc/timezone"
|
||||||
|
content: "Europe/Paris\n"
|
||||||
|
|
||||||
|
- name: Ensure containers root directory is 755
|
||||||
|
file:
|
||||||
|
path: "/var/lib/lxc/{{ item.name }}/rootfs"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
with_items:
|
||||||
|
- "{{ lxc_containers }}"
|
|
@ -1,109 +0,0 @@
|
||||||
#
|
|
||||||
# This playbook configures PHP (php-fpm and specific extensions) inside
|
|
||||||
# container {{name}}.
|
|
||||||
#
|
|
||||||
|
|
||||||
---
|
|
||||||
- name: Update APT cache
|
|
||||||
command: "lxc-attach -n {{name}} -- apt-get update"
|
|
||||||
|
|
||||||
- name: Install PHP packages
|
|
||||||
command: "lxc-attach -n {{name}} -- apt-get install -y php5-fpm php5-cli php5-gd php5-imap php5-ldap php5-mcrypt php5-mysql php5-pgsql php-gettext php5-intl php5-curl php5-ssh2 libphp-phpmailer ssmtp git zip unzip"
|
|
||||||
when: name == 'php56'
|
|
||||||
|
|
||||||
- name: Update APT cache
|
|
||||||
command: "lxc-attach -n {{name}} -- apt-get update"
|
|
||||||
when: name == 'php70'
|
|
||||||
|
|
||||||
- name: Install PHP packages
|
|
||||||
command: "lxc-attach -n {{name}} -- apt-get install -y php-fpm php-cli php-gd php-intl php-imap php-ldap php-mcrypt php-mysql php-pgsql php-gettext php-curl php-ssh2 composer libphp-phpmailer ssmtp git zip unzip php-zip"
|
|
||||||
when: name == 'php70'
|
|
||||||
|
|
||||||
- name: Update APT cache
|
|
||||||
command: "lxc-attach -n {{name}} -- apt-get update"
|
|
||||||
when: name == 'php73'
|
|
||||||
|
|
||||||
- name: Install requirements for sury repository
|
|
||||||
command: "lxc-attach -n {{name}} -- apt-get install -y --no-install-recommends wget apt-transport-https ca-certificates gnupg"
|
|
||||||
when: name == 'php73'
|
|
||||||
|
|
||||||
- name: Add sury APT repository
|
|
||||||
copy:
|
|
||||||
content: "deb https://packages.sury.org/php/ stretch main"
|
|
||||||
dest: "/var/lib/lxc/{{name}}/rootfs/etc/apt/sources.list.d/sury.list"
|
|
||||||
mode: "0644"
|
|
||||||
when: name == 'php73'
|
|
||||||
|
|
||||||
- name: Add sury GPG key
|
|
||||||
shell: "wget -O- https://packages.sury.org/php/apt.gpg |lxc-attach -n {{name}} -- apt-key add -"
|
|
||||||
when: name == 'php73'
|
|
||||||
|
|
||||||
- name: Update APT cache
|
|
||||||
command: "lxc-attach -n {{name}} -- apt-get update"
|
|
||||||
when: name == 'php73'
|
|
||||||
|
|
||||||
- name: Install PHP packages
|
|
||||||
command: "lxc-attach -n {{name}} -- apt-get install -y php7.3 php7.3-fpm php7.3-cli php7.3-curl php7.3-mysql php7.3-pgsql php7.3-ldap php7.3-imap php7.3-gd php-ssh2 php-gettext composer libphp-phpmailer ssmtp git zip unzip php7.3-zip"
|
|
||||||
when: name == 'php73'
|
|
||||||
|
|
||||||
- name: Copy evolinux PHP 5.6 configuration
|
|
||||||
template:
|
|
||||||
src: z-evolinux-defaults.ini.j2
|
|
||||||
dest: "{{ line_item }}"
|
|
||||||
mode: "0644"
|
|
||||||
notify: "Reload {{name}}-fpm"
|
|
||||||
when: name == 'php56'
|
|
||||||
with_items:
|
|
||||||
- "/var/lib/lxc/{{name}}/rootfs/etc/php5/fpm/conf.d/z-evolinux-defaults.ini"
|
|
||||||
- "/var/lib/lxc/{{name}}/rootfs/etc/php5/cli/conf.d/z-evolinux-defaults.ini"
|
|
||||||
loop_control:
|
|
||||||
loop_var: line_item
|
|
||||||
|
|
||||||
- name: Copy evolinux PHP 7.0 configuration
|
|
||||||
template:
|
|
||||||
src: z-evolinux-defaults.ini.j2
|
|
||||||
dest: "{{ line_item }}"
|
|
||||||
mode: "0644"
|
|
||||||
notify: "Reload {{name}}-fpm"
|
|
||||||
when: name == 'php70'
|
|
||||||
with_items:
|
|
||||||
- "/var/lib/lxc/{{name}}/rootfs/etc/php/7.0/fpm/conf.d/z-evolinux-defaults.ini"
|
|
||||||
- "/var/lib/lxc/{{name}}/rootfs/etc/php/7.0/cli/conf.d/z-evolinux-defaults.ini"
|
|
||||||
loop_control:
|
|
||||||
loop_var: line_item
|
|
||||||
|
|
||||||
- name: Copy evolinux PHP 7.3 configuration
|
|
||||||
template:
|
|
||||||
src: z-evolinux-defaults.ini.j2
|
|
||||||
dest: "{{ line_item }}"
|
|
||||||
mode: "0644"
|
|
||||||
notify: "Reload {{name}}-fpm"
|
|
||||||
when: name == 'php73'
|
|
||||||
with_items:
|
|
||||||
- "/var/lib/lxc/{{name}}/rootfs/etc/php/7.3/fpm/conf.d/z-evolinux-defaults.ini"
|
|
||||||
- "/var/lib/lxc/{{name}}/rootfs/etc/php/7.3/cli/conf.d/z-evolinux-defaults.ini"
|
|
||||||
loop_control:
|
|
||||||
loop_var: line_item
|
|
||||||
|
|
||||||
- name: Configure ssmtp
|
|
||||||
replace:
|
|
||||||
name: "/var/lib/lxc/{{name}}/rootfs/etc/ssmtp/ssmtp.conf"
|
|
||||||
regexp: "^mailhub=.*$"
|
|
||||||
replace: "mailhub=127.0.0.1"
|
|
||||||
|
|
||||||
- name: Configure ssmtp
|
|
||||||
replace:
|
|
||||||
name: "/var/lib/lxc/{{name}}/rootfs/etc/ssmtp/ssmtp.conf"
|
|
||||||
regexp: "^#FromLineOverride=.*$"
|
|
||||||
replace: "FromLineOverride=YES"
|
|
||||||
|
|
||||||
- name: Configure ssmtp
|
|
||||||
replace:
|
|
||||||
name: "/var/lib/lxc/{{name}}/rootfs/etc/ssmtp/ssmtp.conf"
|
|
||||||
regexp: "^hostname=.*"
|
|
||||||
replace: "hostname={{ansible_fqdn}}"
|
|
||||||
|
|
||||||
- name: Configure timezone
|
|
||||||
copy:
|
|
||||||
dest: "/var/lib/lxc/{{name}}/rootfs/etc/timezone"
|
|
||||||
content: "Europe/Paris\n"
|
|
16
lxc-php/tasks/php56.yml
Normal file
16
lxc-php/tasks/php56.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Install PHP packages
|
||||||
|
command: "lxc-attach -n {{name}} -- apt-get install -y php5-fpm php5-cli php5-gd php5-imap php5-ldap php5-mcrypt php5-mysql php5-pgsql php-gettext php5-intl php5-curl php5-ssh2 libphp-phpmailer ssmtp git zip unzip"
|
||||||
|
|
||||||
|
- name: Copy evolinux PHP 5.6 configuration
|
||||||
|
template:
|
||||||
|
src: z-evolinux-defaults.ini.j2
|
||||||
|
dest: "{{ line_item }}"
|
||||||
|
mode: "0644"
|
||||||
|
notify: "Reload {{name}}-fpm"
|
||||||
|
with_items:
|
||||||
|
- "/var/lib/lxc/{{name}}/rootfs/etc/php5/fpm/conf.d/z-evolinux-defaults.ini"
|
||||||
|
- "/var/lib/lxc/{{name}}/rootfs/etc/php5/cli/conf.d/z-evolinux-defaults.ini"
|
||||||
|
loop_control:
|
||||||
|
loop_var: line_item
|
16
lxc-php/tasks/php70.yml
Normal file
16
lxc-php/tasks/php70.yml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Install PHP packages
|
||||||
|
command: "lxc-attach -n {{name}} -- apt-get install -y php-fpm php-cli php-gd php-intl php-imap php-ldap php-mcrypt php-mysql php-pgsql php-gettext php-curl php-ssh2 composer libphp-phpmailer ssmtp git zip unzip php-zip"
|
||||||
|
|
||||||
|
- name: Copy evolinux PHP 7.0 configuration
|
||||||
|
template:
|
||||||
|
src: z-evolinux-defaults.ini.j2
|
||||||
|
dest: "{{ line_item }}"
|
||||||
|
mode: "0644"
|
||||||
|
notify: "Reload {{name}}-fpm"
|
||||||
|
with_items:
|
||||||
|
- "/var/lib/lxc/{{name}}/rootfs/etc/php/7.0/fpm/conf.d/z-evolinux-defaults.ini"
|
||||||
|
- "/var/lib/lxc/{{name}}/rootfs/etc/php/7.0/cli/conf.d/z-evolinux-defaults.ini"
|
||||||
|
loop_control:
|
||||||
|
loop_var: line_item
|
31
lxc-php/tasks/php73.yml
Normal file
31
lxc-php/tasks/php73.yml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
- name: Install requirements for sury repository
|
||||||
|
command: "lxc-attach -n {{name}} -- apt-get install -y --no-install-recommends wget apt-transport-https ca-certificates gnupg"
|
||||||
|
|
||||||
|
- name: Add sury APT repository
|
||||||
|
copy:
|
||||||
|
content: "deb https://packages.sury.org/php/ stretch main"
|
||||||
|
dest: "/var/lib/lxc/{{name}}/rootfs/etc/apt/sources.list.d/sury.list"
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: Add sury GPG key
|
||||||
|
shell: "wget -O- https://packages.sury.org/php/apt.gpg |lxc-attach -n {{name}} -- apt-key add -"
|
||||||
|
|
||||||
|
- name: Update APT cache
|
||||||
|
command: "lxc-attach -n {{name}} -- apt-get update"
|
||||||
|
|
||||||
|
- name: Install PHP packages
|
||||||
|
command: "lxc-attach -n {{name}} -- apt-get install -y php7.3 php7.3-fpm php7.3-cli php7.3-curl php7.3-mysql php7.3-pgsql php7.3-ldap php7.3-imap php7.3-gd php-ssh2 php-gettext composer libphp-phpmailer ssmtp git zip unzip php7.3-zip"
|
||||||
|
|
||||||
|
- name: Copy evolinux PHP 7.3 configuration
|
||||||
|
template:
|
||||||
|
src: z-evolinux-defaults.ini.j2
|
||||||
|
dest: "{{ line_item }}"
|
||||||
|
mode: "0644"
|
||||||
|
notify: "Reload {{name}}-fpm"
|
||||||
|
with_items:
|
||||||
|
- "/var/lib/lxc/{{name}}/rootfs/etc/php/7.3/fpm/conf.d/z-evolinux-defaults.ini"
|
||||||
|
- "/var/lib/lxc/{{name}}/rootfs/etc/php/7.3/cli/conf.d/z-evolinux-defaults.ini"
|
||||||
|
loop_control:
|
||||||
|
loop_var: line_item
|
Loading…
Reference in a new issue