[WIP] Some improvements

improve
Emilien Mantel 2019-12-24 18:34:37 +01:00
parent 9738ae9614
commit 1eea41cd39
5 changed files with 59 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,10 @@
def php_socket(php_version, pool_name):
return '/run/php/php%s-%s-fpm.sock' % (php_version, pool_name)
class FilterModule(object):
''' PHP module '''
def filters(self):
return {
'php_socket': php_socket,
}

Binary file not shown.

View File

@ -15,6 +15,45 @@
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml" - "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml" - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- name: SET_FACT | Transform data
set_fact:
__php_fpm_full_pool: |
[
{% for p in php_fpm_poold %}
{
name: "{{ p.name | default(p.pool_name) }}",
listen: "{{ item.listen | default(php_version | php_socket(p.name | default(p.pool_name))) }}",
user: "{{ item.user | default(php_default_user_group) }}",
group: "{{ item.group | default(php_default_user_group) }}",
listen_owner: "{{ item.listen_owner | default(php_default_user_group) }}",
listen_group: "{{ item.listen_owner | default(php_default_user_group) }}",
{% for k, v in p.items() %}
{% if k not in ['name', 'pool_name', 'listen', 'user', 'group', 'listen_owner'] %}
{{ k }}: "{{ v }}"{% if not loop.last %},{% endif %}
{% endif %}
{% endfor %}
}{% if not loop.last %},{% endif %}
{% endfor %}
]
- name: SET_FACT | To YAML
set_fact:
php_fpm_full_pool: "{{ __php_fpm_full_pool | from_yaml }}"
- name: FILE | Creates ansible facts.d
file:
path: /etc/ansible/facts.d
state: directory
recurse: yes
- name: COPY | Manage current repositories
copy:
content: "{ \"php_fpm_full_pool\": {{ php_fpm_full_pool | to_json }} }"
dest: /etc/ansible/facts.d/php_fpm_pool.fact
- debug: var=php_fpm_full_pool
- fail: msg='ok'
- name: APT | Install PHP packages - name: APT | Install PHP packages
apt: apt:
pkg: "{{ item }}" pkg: "{{ item }}"

View File

@ -25,6 +25,16 @@
display_errors: 'Off' display_errors: 'Off'
php_admin_flag: php_admin_flag:
memory_limit: '128M' memory_limit: '128M'
- pool_name: 'test_ansible2'
pm: 'dynamic'
pm_max_children: 250
pm_start_servers: 10
pm_min_spare_servers: 10
pm_max_spare_servers: 20
php_flag:
display_errors: 'On'
php_admin_flag:
memory_limit: '64M'
pre_tasks: pre_tasks: