src.dualinventive.com/devops/ansible/rootnet-roles/php5_3/tasks/main.yml

210 lines
5.2 KiB
YAML

---
- name: Check if PHP 5.3-FPM is installed
stat:
path: "{{ php_fpm_binary_path }}"
register: php_fpm_binary_path_stat
- name: Get current PHP 5.3-FPM version
shell: "{{ php_fpm_binary_path }} -v | head -n 1 | awk '{print $2}'"
register: php_fpm_installed_version
check_mode: no
changed_when: False
when: php_fpm_binary_path_stat.stat.exists
- name: Install required packages to compile PHP 5.3
apt:
name: "{{ item }}"
state: latest
update_cache: true
cache_valid_time: 3600
with_items:
- build-essential
- pkg-config
- bison
- libxml2-dev
- libbz2-dev
- libmcrypt-dev
- libicu-dev
- libssl-dev
- libcurl4-openssl-dev
- libltdl-dev
- libjpeg-dev
- libpng-dev
- libpspell-dev
- libsystemd-daemon-dev
- libreadline-dev
- libxpm-dev
- libfreetype6-dev
- libmariadbclient-dev
- libxslt-dev
- "{{ php_packages | default([]) }}"
when: >
(php_fpm_binary_path_stat.stat.exists == False) or
(php_fpm_binary_path_stat.stat.exists == True and
php_fpm_installed_version.stdout != php_version)
tags:
- install
- apt
- name: Create required directories for PHP 5.3 compiling
file:
path: "{{ item }}"
state: directory
owner: root
group: root
mode: "0755"
with_items:
- "/usr/include/freetype2/freetype"
- name: Create required symlinks for PHP 5.3 compiling
file:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: root
group: root
state: link
with_items:
- { src: "/usr/lib/x86_64-linux-gnu/libXpm.so", dest: "/usr/local/lib/libXpm.so" }
- { src: "/usr/lib/x86_64-linux-gnu/libXpm.a", dest: "/usr/local/lib/libXpm.a" }
- { src: "/usr/include/X11/xpm.h", dest: "/usr/local/include/xpm.h" }
- { src: "/usr/include/freetype2/freetype.h", dest: "/usr/include/freetype2/freetype/freetype.h" }
- name: Download PHP 5.3 source package
unarchive:
src: "{{ php_source_download_url }}"
dest: "{{ php_source_destination_basedir }}"
creates: "{{ php_source_destination_path }}"
owner: root
group: root
mode: "0755"
copy: no
- name: Compile PHP 5.3-FPM
command: "{{ item }}"
args:
chdir: "{{ php_source_destination_path }}"
failed_when: >
(item == "make clean" and php_compile_results.rc not in [0, 2]) or
(item != "make clean" and php_compile_results.rc != 0)
register: php_compile_results
with_items:
- "make clean"
- "./configure {{ php_fpm_configure_params }}"
- "make -j {{ ansible_processor_cores }}"
- "make install"
environment:
LDFLAGS: "-lssl -lcrypto -lpthread"
when: >
(php_fpm_binary_path_stat.stat.exists == False) or
(php_fpm_binary_path_stat.stat.exists == True and
php_fpm_installed_version.stdout != php_version)
notify:
- restart php53-fpm
- name: Restrict permissions of php vhost directory
file:
path: "{{ php_vhost_path }}"
owner: root
group: root
mode: 0750
state: directory
notify:
- restart php53-fpm
- name: Ensure default php53-fpm pool is absent
file:
path: "{{ php_vhost_path }}/www.conf.default"
state: absent
when: php_vhosts is defined
notify:
- restart php53-fpm
- name: Ensure main php53-fpm configuration is up-to-date
template:
src: php-fpm.conf.j2
dest: "{{ php_fpm_primary_config_path }}"
owner: root
group: root
mode: 0644
notify:
- restart php53-fpm
- name: Add php53-fpm vhost configuration
template:
src: vhosts.j2
dest: "{{ php_vhost_path }}/{{ item.key }}.conf"
mode: 0644
with_dict: "{{ php_vhosts | default ({}) }}"
when: php_vhosts
notify:
- restart php53-fpm
- name: Remove php53-fpm vhost configuration
file:
path: "{{ php_vhost_path }}/{{ item.key }}.conf"
state: "{{ item.value.state }}"
with_dict: "{{ php_vhosts | default ({}) }}"
when: php_vhosts and item.value.state is defined and item.value.state == 'absent'
notify:
- restart php53-fpm
- name: Ensure php.ini is present
template:
src: php.ini.j2
dest: "{{ php_ini_path }}"
owner: root
group: root
mode: 0644
notify:
- restart php53-fpm
- name: Ensure directory for additional PHP 5.3 config files is present
file:
path: "{{ php_additional_config_path }}"
owner: root
group: root
mode: 0755
state: directory
notify:
- restart php53-fpm
- name: Template dynamic extensions
template:
src: extensions.ini.j2
dest: "{{ php_additional_config_path }}/extensions.ini"
owner: root
group: root
mode: 0644
notify:
- restart php53-fpm
- name: Ensure init script is present
template:
src: php-fpm-init.j2
dest: "{{ php_fpm_init_path }}"
owner: root
group: root
mode: 0755
notify:
- restart php53-fpm
- name: Ensure PHP 5.3 starts at boot
service:
name: "{{ php_fpm_init_daemon }}"
enabled: yes
- name: Ensure vhost tmp directories are present
file:
dest:
"{{ item.value.tmp | default(php_tmp_dir_prefix + '/' +
item.value.user | default(item.key) + '/tmp') }}"
owner: root
group: "{{ item.value.user | default(item.key) }}"
mode: 0775
state: directory
with_dict: "{{ php_vhosts | default({}) }}"
notify:
- restart php53-fpm