first version

This commit is contained in:
Adrien Waksberg 2018-08-07 22:53:28 +02:00
parent 5f33777b80
commit 8e9af2f3e5
20 changed files with 2740 additions and 0 deletions

54
tasks/base.yml Normal file
View file

@ -0,0 +1,54 @@
- name: install php-fpm package
package:
name: 'php{{ phpfpm_version }}-fpm'
tags: phpfpm
- name: install additionnal packages
package:
name: '{{ item }}'
with_items: '{{ phpfpm_packages }}'
tags: phpfpm
- name: create log directory
file:
path: '{{ phpfpm_dir_log }}'
owner: root
group: root
mode: 0755
state: directory
tags: phpfpm
- name: check if log file exist
stat:
path: '{{ phpfpm_dir_log }}/php-fpm.log'
register: st
tags: phpfpm
- name: create log file
file:
path: '{{ phpfpm_dir_log }}/php-fpm.log'
owner: root
group: root
mode: 0640
state: touch
when: not st.stat.exists
tags: phpfpm
- name: copy logrotate configuration
template:
src: logrotate.j2
dest: '/etc/logrotate.d/php{{ phpfpm_version }}-fpm'
owner: root
group: root
mode: 0644
tags: phpfpm
- name: copy global php-fpm configuration file
template:
src: php-fpm.conf.j2
dest: '{{ phpfpm_dir }}/php-fpm.conf'
owner: root
group: root
mode: 0644
notify: reload php-fpm
tags: phpfpm

10
tasks/main.yml Normal file
View file

@ -0,0 +1,10 @@
- include_tasks: base.yml
- include_tasks: pools.yml
- name: enable and start php-fpm
systemd:
name: php{{ phpfpm_version }}-fpm
state: started
enabled: yes
tags: phpfpm

58
tasks/pools.yml Normal file
View file

@ -0,0 +1,58 @@
- name: create user for php-fpm with a specify uid
user:
name: '{{ item.user }}'
group: '{{ item.group|default(phpfpm_group) }}'
uid: '{{ item.uid }}'
home: '{{ item.home }}'
with_items: '{{ phpfpm_pools }}'
when: item.uid is defined
tags: phpfpm
- name: create user for php-fpm without a specify uid
user:
name: '{{ item.user }}'
group: '{{ item.group|default(phpfpm_group) }}'
home: '{{ item.home }}'
with_items: '{{ phpfpm_pools }}'
when: not item.uid is defined
tags: phpfpm
- name: set attributes on homes directories
file:
path: '{{ item.home }}'
owner: '{{ item.user }}'
group: www-data
mode: 0750
state: directory
with_items: '{{ phpfpm_pools }}'
tags: phpfpm
- name: check if pools log files exist
stat:
path: '{{ phpfpm_dir_log }}/{{ item[0].name }}.{{ item[1] }}'
with_nested:
- '{{ phpfpm_pools }}'
- ['slow.log', 'access.log', 'log']
register: st
tags: phpfpm
- name: create log files
file:
path: '{{ phpfpm_dir_log }}/{{ item.item[0].name }}.{{ item.item[1] }}'
owner: root
group: www-data
mode: 0640
state: touch
with_items: '{{ st.results }}'
when: not item.stat.exists
tags: phpfpm
- name: copy pools php-fpm configuration file
template:
src: pools.conf.j2
dest: '{{ phpfpm_dir }}/pools.conf'
owner: root
group: root
mode: 0644
notify: reload php-fpm
tags: phpfpm