123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- - name: 'Install common PHP dependencies (Debian <= 8)'
- apt:
- pkg:
- - 'php5-cli'
- - 'php5-curl'
- - 'php5-gd'
- - 'php5-intl'
- - 'php5-mcrypt'
- - 'php-mime-type'
- - 'php5-pgsql'
- - 'php5-sqlite'
- state: 'present'
- when: with_php|bool and ansible_lsb.major_release|int <= 8
- tags:
- - 'web'
- - 'php'
- - name: 'Install common PHP dependencies (Debian >= 9, PHP version {{ php_version }})'
- apt:
- pkg:
- - 'php{{ php_version }}-cli'
- - 'php{{ php_version }}-curl'
- - 'php{{ php_version }}-gd'
- - 'php{{ php_version }}-intl'
- - 'php{{ php_version }}-mysql'
- - 'php{{ php_version }}-pgsql'
- - 'php{{ php_version }}-sqlite3'
- - 'php{{ php_version }}-zip'
- state: 'present'
- when: with_php|bool and ansible_lsb.major_release|int >= 9
- tags:
- - 'web'
- - 'php'
- - name: 'Install common PHP dependencies (Debian >= 9, PHP < 7.2, PHP version {{ php_version }})'
- apt:
- pkg:
- - 'php{{ php_version }}-mcrypt'
- state: 'present'
- when: with_php|bool and ansible_lsb.major_release|int >= 9 and php_version|float < 7.2
- tags:
- - 'web'
- - 'php'
- - name: 'Create PHP log directory'
- file:
- path: '/var/log/php'
- state: directory
- owner: 'root'
- group: 'root'
- mode: '0755'
- when: with_php|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Install PHP configuration for syslog'
- template:
- src: '{{ item.src }}'
- dest: '{{ item.dest }}'
- owner: 'root'
- group: 'root'
- mode: '0644'
- with_items:
- - { src: 'rsyslog/php-errors.conf.j2', dest: '/etc/rsyslog.d/php-errors.conf' }
- - { src: 'logrotate/php-errors.j2', dest: '/etc/logrotate.d/php-errors' }
- notify:
- - 'Reload rsyslog for php'
- when: with_fpm|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Install local PHP configuration overrides for php5-cli (Debian 8)'
- template:
- src: 'php/php-config-cli.ini.j2'
- dest: '/etc/php5/cli/conf.d/99-local-config.ini'
- owner: 'root'
- group: 'root'
- mode: '0644'
- when: with_php|bool and ansible_lsb.major_release|int == 8
- tags:
- - 'web'
- - 'php'
- - name: 'Install local PHP configuration overrides for php{{ php_version }}-cli (Debian >= 9)'
- template:
- src: 'php/php-config-cli.ini.j2'
- dest: '/etc/php/{{ php_version }}/cli/conf.d/99-local-config.ini'
- owner: 'root'
- group: 'root'
- mode: '0644'
- when: with_php|bool and ansible_lsb.major_release|int >= 9
- tags:
- - 'web'
- - 'php'
- - name: 'Install Apache2 module for php5'
- apt:
- pkg:
- - 'libapache2-mod-php5'
- state: 'present'
- notify:
- - 'Reload apache2'
- when: with_modphp5|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Install Apache2 module for php{{ php_version }}'
- apt:
- pkg:
- - 'libapache2-mod-php{{ php_version }}'
- state: 'present'
- notify:
- - 'Reload apache2'
- when: with_modphp|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Configure Apache2 modules for php-fpm{{ php_version }}'
- shell: a2dismod php{{ php_version }} mpm_prefork ; a2enmod mpm_event proxy_fcgi
- changed_when: False
- when: with_fpm|bool and with_apache2|bool
- notify:
- - 'Reload apache2'
- tags:
- - 'web'
- - 'php'
- - name: 'Configure Apache2 modules for modphp{{ php_version }}'
- shell: a2dismod mpm_event ; a2enmod mpm_prefork php{{ php_version }}
- changed_when: False
- when: with_modphp|bool
- notify:
- - 'Reload apache2'
- tags:
- - 'web'
- - 'php'
- - name: 'Install local PHP configuration (Debian < 8)'
- template:
- src: 'php/php-config-web.ini.j2'
- dest: '/etc/php5/conf.d/99-local-config.ini'
- owner: 'root'
- group: 'root'
- mode: '0644'
- notify:
- - 'Reload apache2'
- when: with_modphp5|bool and ansible_lsb.major_release|int < 8
- tags:
- - 'web'
- - 'php'
- - name: 'Install local PHP configuration for Apache 2 (Debian 8)'
- template:
- src: 'php/php-config-web.ini.j2'
- dest: '/etc/php5/apache2/conf.d/99-local-config.ini'
- owner: 'root'
- group: 'root'
- mode: '0644'
- notify:
- - 'Reload apache2'
- when: with_modphp5|bool and ansible_lsb.major_release|int == 8
- tags:
- - 'web'
- - 'php'
- - name: 'Install local PHP configuration for Apache 2 (Debian >= 9)'
- template:
- src: 'php/php-config-web.ini.j2'
- dest: '/etc/php/{{ php_version }}/apache2/conf.d/99-local-config.ini'
- owner: 'root'
- group: 'root'
- mode: '0644'
- notify:
- - 'Reload apache2'
- when: with_modphp|bool and ansible_lsb.major_release|int >= 9
- tags:
- - 'web'
- - 'php'
- - name: 'Create system checks directory /etc/phpsyscheck'
- file:
- path: '/etc/phpsyscheck'
- state: 'directory'
- owner: 'root'
- group: 'root'
- mode: '0755'
- when: with_phpsyscheck|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Install phpinfo system check'
- template:
- src: 'php/phpinfo.php'
- dest: '/etc/phpsyscheck/index.php'
- owner: 'root'
- group: 'root'
- mode: '0644'
- when: with_phpsyscheck|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Install PHP APC extension (Debian <= 8)'
- apt:
- pkg:
- - 'php-apc'
- state: 'present'
- when: with_php_apc|bool and ansible_lsb.major_release|int <= 8
- tags:
- - 'web'
- - 'php'
- - name: 'Install PHP APC extension (Debian >= 9)'
- apt:
- pkg:
- - 'php-apcu'
- state: 'present'
- when: with_php_apc|bool and ansible_lsb.major_release|int >= 9
- tags:
- - 'web'
- - 'php'
- - name: 'Install php-apc system check'
- template:
- src: 'php/apc.php'
- dest: '/etc/phpsyscheck/apc.php'
- owner: 'root'
- group: 'root'
- mode: '0644'
- when: with_phpsyscheck|bool and with_php_apc|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Install MySQL extension for PHP - native driver (Debian 8)'
- apt:
- pkg:
- - 'php5-mysqlnd'
- state: 'present'
- when: not with_php_mysql_legacy|bool and ansible_lsb.major_release|int == 8
- tags:
- - 'web'
- - 'php'
- - name: 'Install MySQL extension for PHP (old driver)'
- apt:
- pkg: 'php5-mysql'
- state: 'present'
- when: with_php_mysql_legacy|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Install PHPMyAdmin'
- apt:
- pkg:
- - 'phpmyadmin'
- state: 'present'
- when: with_phpmyadmin|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Install PHPPgAdmin'
- apt:
- pkg:
- - 'phppgadmin'
- state: 'present'
- when: with_phppgadmin|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Install FPM for PHP 5 (Debian <= 8)'
- apt:
- pkg:
- - 'php5-fpm'
- state: 'present'
- when: with_fpm|bool and ansible_lsb.major_release|int <= 8
- tags:
- - 'web'
- - 'php'
- - name: 'Install FPM for PHP {{ php_version }} (Debian >= 9)'
- apt:
- pkg:
- - 'php{{ php_version }}-fpm'
- state: 'present'
- when: with_fpm|bool and ansible_lsb.major_release|int >= 9
- tags:
- - 'web'
- - 'php'
- - name: 'Configure FPM for PHP 5 (Debian <= 8)'
- lineinfile:
- dest: '/etc/php5/fpm/php-fpm.conf'
- regexp: '^{{ item.key }}\s*=.*$'
- line: '{{ item.key }} = {{ item.value }}'
- insertafter: '^;{{ item.key }}'
- with_items:
- - { key: 'error_log', value: 'syslog' }
- - { key: 'log_level', value: 'warning' }
- - { key: 'emergency_restart_threshold', value: '100' }
- - { key: 'emergency_restart_interval', value: '5s' }
- - { key: 'rlimit_files', value: '262144' }
- - { key: 'events.mechanism', value: 'epoll' }
- - { key: 'include', value: '/etc/php5/fpm/pool.d/local-pool.cnf' }
- notify:
- - 'Reload FPM for PHP 5'
- when: with_fpm|bool and ansible_lsb.major_release|int <= 8
- tags:
- - 'web'
- - 'php'
- - name: 'Configure FPM for PHP {{ php_version }} (Debian >= 9)'
- lineinfile:
- dest: '/etc/php/{{ php_version }}/fpm/php-fpm.conf'
- regexp: '^{{ item.key }}\s*=.*$'
- line: '{{ item.key }} = {{ item.value }}'
- insertafter: '^;{{ item.key }}'
- with_items:
- - { key: 'error_log', value: 'syslog' }
- - { key: 'log_level', value: 'warning' }
- - { key: 'emergency_restart_threshold', value: '100' }
- - { key: 'emergency_restart_interval', value: '5s' }
- - { key: 'rlimit_files', value: '262144' }
- - { key: 'events.mechanism', value: 'epoll' }
- - { key: 'include', value: '/etc/php/{{ php_version }}/fpm/pool.d/local-pool.cnf' }
- notify:
- - 'Reload FPM for PHP'
- when: with_fpm|bool and ansible_lsb.major_release|int >= 9
- tags:
- - 'web'
- - 'php'
- - name: 'Install FPM pools configuration for PHP 5 (Debian <= 8)'
- template:
- src: 'fpm/php5-fpm-pools.conf.j2'
- dest: '/etc/php5/fpm/pool.d/local-pool.cnf'
- owner: 'root'
- group: 'root'
- mode: '0644'
- notify:
- - 'Reload FPM for PHP 5'
- when: with_fpm|bool and ansible_lsb.major_release|int <= 8
- tags:
- - 'web'
- - 'php'
- - name: 'Install FPM pools configuration for PHP {{ php_version }} (Debian > 9)'
- template:
- src: 'fpm/php-fpm-pools.conf.j2'
- dest: '/etc/php/{{ php_version }}/fpm/pool.d/local-pool.cnf'
- owner: 'root'
- group: 'root'
- mode: '0644'
- notify:
- - 'Reload FPM for PHP'
- when: with_fpm|bool and ansible_lsb.major_release|int >= 9
- tags:
- - 'web'
- - 'php'
- - name: 'Install local PHP configuration overrides for php5-fpm (Debian 8)'
- template:
- src: 'php/php-config-web.ini.j2'
- dest: '/etc/php5/fpm/conf.d/99-local-config.ini'
- owner: 'root'
- group: 'root'
- mode: '0644'
- when: with_fpm|bool and ansible_lsb.major_release|int == 8
- tags:
- - 'web'
- - 'php'
- - name: 'Install local PHP configuration overrides for php{{ php_version }}-fpm (Debian >= 9)'
- template:
- src: 'php/php-config-web.ini.j2'
- dest: '/etc/php/{{ php_version }}/fpm/conf.d/99-local-config.ini'
- owner: 'root'
- group: 'root'
- mode: '0644'
- when: with_fpm|bool and ansible_lsb.major_release|int >= 9
- tags:
- - 'web'
- - 'php'
- - name: 'Install Apache2 config files for PHP FPM'
- template:
- src: 'fpm/apache2/fpm-pool.conf.j2'
- dest: '/etc/apache2/conf-available/fpm-pool.conf'
- owner: 'root'
- group: 'root'
- mode: '0644'
- when: with_fpm|bool and with_apache2|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Install Nginx config files for PHP FPM (fpm servers pool)'
- template:
- src: 'fpm/nginx/fpm-pool.conf.j2'
- dest: '/etc/nginx/conf.d/fpm-pool.conf'
- owner: 'root'
- group: 'root'
- mode: '0644'
- notify:
- - 'Reload nginx'
- when: with_fpm|bool and with_nginx|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Install Nginx config files for PHP FPM (fpm fastcgi config)'
- template:
- src: 'fpm/nginx/fastcgi_pass_fpm.j2'
- dest: '/etc/nginx/fastcgi_pass_fpm'
- owner: 'root'
- group: 'root'
- mode: '0644'
- notify:
- - 'Reload nginx'
- when: with_fpm|bool and with_nginx|bool
- tags:
- - 'web'
- - 'php'
- - name: 'Ensure FPM for PHP 5 is running (Debian <= 8)'
- service:
- name: 'php5-fpm'
- state: 'started'
- when: with_fpm|bool and ansible_lsb.major_release|int <= 8
- tags:
- - 'web'
- - 'php'
- - name: 'Ensure FPM for PHP {{ php_version }} is running (Debian >= 9)'
- service:
- name: 'php{{ php_version }}-fpm'
- state: 'started'
- when: with_fpm|bool and ansible_lsb.major_release|int >= 9
- tags:
- - 'web'
- - 'php'
- # vim: ft=yaml.ansible
|