Compare commits
17 commits
first-vers
...
master
Author | SHA1 | Date | |
---|---|---|---|
4cfdab95ec | |||
22dd6dd8cd | |||
3b682bee44 | |||
93a231147e | |||
1f272190fb | |||
a51e3ece2d | |||
f67c18d321 | |||
fc7dff0cf6 | |||
9f274b2565 | |||
8988e92092 | |||
c9b88165a8 | |||
ebc0ecbee4 | |||
cd0e8312b4 | |||
67d1daf744 | |||
1735ff1ffd | |||
b3fd17bdf8 | |||
8e9af2f3e5 |
15 changed files with 110 additions and 56 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
driver:
|
driver:
|
||||||
name: docker_cli
|
name: docker_cli
|
||||||
|
|
||||||
|
@ -8,16 +9,15 @@ provisioner:
|
||||||
name: ansible_playbook
|
name: ansible_playbook
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
require_ansible_repo: false
|
require_ansible_repo: false
|
||||||
require_ansible_omnibus: true
|
require_ansible_omnibus: false
|
||||||
require_chef_for_busser: true
|
require_chef_for_busser: true
|
||||||
ansible_verbose: false
|
ansible_verbose: false
|
||||||
ansible_version: <% if ENV['ANSIBLE_VERSION'] %><%= ENV['ANSIBLE_VERSION'] %><% else %><%= '2.4.6.0' %><% end %>
|
|
||||||
ansible_inventory: ./test/integration/inventory
|
ansible_inventory: ./test/integration/inventory
|
||||||
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: debian-9
|
- name: debian-9
|
||||||
driver_config:
|
driver_config:
|
||||||
image: nishiki/ansible:stretch
|
image: "nishiki/debian9:ansible-<%= ENV['ANSIBLE_VERSION'] ? ENV['ANSIBLE_VERSION'] : '2.7' %>"
|
||||||
command: /bin/systemd
|
command: /bin/systemd
|
||||||
volume:
|
volume:
|
||||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
---
|
||||||
AllCops:
|
AllCops:
|
||||||
Exclude:
|
Exclude:
|
||||||
- db/**/*
|
- db/**/*
|
||||||
|
|
16
.travis.yml
16
.travis.yml
|
@ -1,18 +1,28 @@
|
||||||
|
---
|
||||||
sudo: required
|
sudo: required
|
||||||
language: ruby
|
language: ruby
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- ANSIBLE_VERSION=2.4.6.0
|
- ANSIBLE_VERSION=2.5
|
||||||
- ANSIBLE_VERSION=2.5.7.0
|
- ANSIBLE_VERSION=2.6
|
||||||
- ANSIBLE_VERSION=2.6.2.0
|
- ANSIBLE_VERSION=2.7
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- bundle install
|
- bundle install
|
||||||
|
- sudo pip install --upgrade pip
|
||||||
|
- sudo pip install yamllint
|
||||||
|
- sudo pip install ansible-lint
|
||||||
|
- git clone https://github.com/ansible/galaxy-lint-rules.git
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- kitchen conv phpfpm-debian-9
|
- kitchen conv phpfpm-debian-9
|
||||||
- kitchen conv phpfpm-debian-9 | grep changed=0
|
- kitchen conv phpfpm-debian-9 | grep changed=0
|
||||||
- kitchen verify phpfpm-debian-9
|
- kitchen verify phpfpm-debian-9
|
||||||
|
- ansible-lint -r galaxy-lint-rules/rules .
|
||||||
|
- yamllint .
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||||
|
|
12
.yamllint
Normal file
12
.yamllint
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
extends: default
|
||||||
|
|
||||||
|
ignore: |
|
||||||
|
.kitchen/*
|
||||||
|
vendor/
|
||||||
|
|
||||||
|
rules:
|
||||||
|
line-length:
|
||||||
|
max: 120
|
||||||
|
level: warning
|
||||||
|
truthy: false
|
21
CHANGELOG.md
21
CHANGELOG.md
|
@ -1,4 +1,21 @@
|
||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
## v1.0.0 (2018-08-11)
|
|
||||||
|
|
||||||
* first version
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
Which is based on [Keep A Changelog](http://keepachangelog.com/)
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
## v1.2.0 (2018-12-01)
|
||||||
|
- BREAKING CHANGE: change with_items to loop
|
||||||
|
- test: add test with ansible 2.7
|
||||||
|
- test: add ansible-lint
|
||||||
|
- test: add yamllint
|
||||||
|
|
||||||
|
## v1.1.0 (2018-09-30)
|
||||||
|
- feat: set attributes on homes directories
|
||||||
|
- feat: remove phpfpm_group var
|
||||||
|
- style: replace include_tasks to import_tasks
|
||||||
|
- fix: group permission in pools template
|
||||||
|
|
||||||
|
## v1.0.0 (2018-08-15)
|
||||||
|
- first version
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Ansible role: PHP FPM
|
# Ansible role: PHP FPM
|
||||||
[](https://git.yaegashi.fr/nishiki/ansible-role-phpfpm/releases)
|
[](https://git.yaegashi.fr/nishiki/ansible-role-phpfpm/releases)
|
||||||
[](https://travis-ci.org/nishiki/ansible-role-phpfpm)
|
[](https://travis-ci.org/nishiki/ansible-role-phpfpm)
|
||||||
[](https://git.yaegashi.fr/nishiki/ansible-role-phpfpm/src/branch/master/LICENSE)
|
[](https://git.yaegashi.fr/nishiki/ansible-role-phpfpm/src/branch/master/LICENSE)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ Install and configure PHP FPM
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
* Ansible >= 2.4
|
* Ansible >= 2.5
|
||||||
* Debian Stretch
|
* Debian Stretch
|
||||||
|
|
||||||
## Role variables
|
## Role variables
|
||||||
|
@ -33,7 +33,6 @@ Install and configure PHP FPM
|
||||||
|
|
||||||
See [php pool directives documentation](http://php.net/manual/en/install.fpm.configuration.php)
|
See [php pool directives documentation](http://php.net/manual/en/install.fpm.configuration.php)
|
||||||
|
|
||||||
* `phpfpm_group` - (default: `www-data`)
|
|
||||||
* `phpfpm_ping_path` - (default: `/ping`)
|
* `phpfpm_ping_path` - (default: `/ping`)
|
||||||
* `phpfpm_ping_response` - (default: `pong`)
|
* `phpfpm_ping_response` - (default: `pong`)
|
||||||
* `phpfpm_pm` - (default: `ondemand`)
|
* `phpfpm_pm` - (default: `ondemand`)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
---
|
||||||
phpfpm_version: 7.0
|
phpfpm_version: 7.0
|
||||||
phpfpm_group: www-data
|
|
||||||
phpfpm_dir: /etc/php/{{ phpfpm_version }}/fpm
|
phpfpm_dir: /etc/php/{{ phpfpm_version }}/fpm
|
||||||
phpfpm_dir_log: /var/log/phpfpm
|
phpfpm_dir_log: /var/log/phpfpm
|
||||||
phpfpm_packages:
|
phpfpm_packages:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- name: reload php-fpm
|
- name: reload php-fpm
|
||||||
systemd:
|
systemd:
|
||||||
name: 'php{{ phpfpm_version }}-fpm'
|
name: 'php{{ phpfpm_version }}-fpm'
|
||||||
|
|
20
meta/main.yml
Normal file
20
meta/main.yml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
role_name: phpfpm
|
||||||
|
author: Adrien Waksberg
|
||||||
|
company: Adrien Waksberg
|
||||||
|
description: Install and configure PHP-FPM
|
||||||
|
license: Apache2
|
||||||
|
min_ansible_version: 2.5
|
||||||
|
|
||||||
|
platforms:
|
||||||
|
- name: Debian
|
||||||
|
versions:
|
||||||
|
- stretch
|
||||||
|
|
||||||
|
galaxy_tags:
|
||||||
|
- php
|
||||||
|
- fpm
|
||||||
|
- web
|
||||||
|
|
||||||
|
dependencies: []
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
- name: install php-fpm package
|
- name: install php-fpm package
|
||||||
package:
|
package:
|
||||||
name: 'php{{ phpfpm_version }}-fpm'
|
name: 'php{{ phpfpm_version }}-fpm'
|
||||||
|
@ -5,8 +6,7 @@
|
||||||
|
|
||||||
- name: install additionnal packages
|
- name: install additionnal packages
|
||||||
package:
|
package:
|
||||||
name: '{{ item }}'
|
name: '{{ phpfpm_packages }}'
|
||||||
with_items: '{{ phpfpm_packages }}'
|
|
||||||
tags: phpfpm
|
tags: phpfpm
|
||||||
|
|
||||||
- name: create log directory
|
- name: create log directory
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
- include_tasks: base.yml
|
---
|
||||||
|
- import_tasks: base.yml
|
||||||
|
tags: phpfpm
|
||||||
|
|
||||||
- include_tasks: pools.yml
|
- import_tasks: pools.yml
|
||||||
|
tags: phpfpm
|
||||||
|
|
||||||
- name: enable and start php-fpm
|
- name: enable and start php-fpm
|
||||||
systemd:
|
systemd:
|
||||||
|
|
|
@ -1,38 +1,13 @@
|
||||||
- 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
|
- name: check if pools log files exist
|
||||||
stat:
|
stat:
|
||||||
path: '{{ phpfpm_dir_log }}/{{ item[0].name }}.{{ item[1] }}'
|
path: '{{ phpfpm_dir_log }}/{{ item[0].name }}.{{ item[1] }}'
|
||||||
with_nested:
|
loop: '{{ phpfpm_pools|product(log_files)|list }}'
|
||||||
- '{{ phpfpm_pools }}'
|
vars:
|
||||||
- ['slow.log', 'access.log', 'log']
|
log_files:
|
||||||
|
- slow.log
|
||||||
|
- access.log
|
||||||
|
- log
|
||||||
register: st
|
register: st
|
||||||
tags: phpfpm
|
tags: phpfpm
|
||||||
|
|
||||||
|
@ -43,7 +18,7 @@
|
||||||
group: www-data
|
group: www-data
|
||||||
mode: 0640
|
mode: 0640
|
||||||
state: touch
|
state: touch
|
||||||
with_items: '{{ st.results }}'
|
loop: '{{ st.results }}'
|
||||||
when: not item.stat.exists
|
when: not item.stat.exists
|
||||||
tags: phpfpm
|
tags: phpfpm
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
[{{ pool.name }}]
|
[{{ pool.name }}]
|
||||||
|
|
||||||
user = {{ pool.user }}
|
user = {{ pool.user }}
|
||||||
group = {{ pool.group|default(phpfpm_group) }}
|
group = {{ pool.group|default(pool.user) }}
|
||||||
|
|
||||||
listen = /var/run/php{{ phpfpm_version }}-fpm-{{ pool.name }}.sock
|
listen = /var/run/php{{ phpfpm_version }}-fpm-{{ pool.name }}.sock
|
||||||
listen.owner = {{ pool.user }}
|
listen.owner = {{ pool.user }}
|
||||||
listen.group = {{ pool.group|default(phpfpm_group) }}
|
listen.group = www-data
|
||||||
|
|
||||||
pm = {{ pool.pm|default(phpfpm_pm) }}
|
pm = {{ pool.pm|default(phpfpm_pm) }}
|
||||||
pm.max_children = {{ pool.pm_max_children|default(phpfpm_pm_max_children) }}
|
pm.max_children = {{ pool.pm_max_children|default(phpfpm_pm_max_children) }}
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
|
---
|
||||||
- hosts: localhost
|
- hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
vars:
|
vars:
|
||||||
phpfpm_pools:
|
phpfpm_pools:
|
||||||
- name: www
|
- name: website1
|
||||||
user: www
|
user: www
|
||||||
home: /opt/www
|
- name: website2
|
||||||
uid: 1001
|
user: www
|
||||||
|
pm: static
|
||||||
|
pm_max_children: 4
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- user:
|
||||||
|
name: www
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- ansible-role-phpfpm
|
- ansible-role-phpfpm
|
||||||
|
|
|
@ -40,10 +40,11 @@ describe file('/etc/php/7.0/fpm/pools.conf') do
|
||||||
it { should be_owned_by 'root' }
|
it { should be_owned_by 'root' }
|
||||||
it { should be_grouped_into 'root' }
|
it { should be_grouped_into 'root' }
|
||||||
its(:content) { should match(/pm\s+= ondemand/) }
|
its(:content) { should match(/pm\s+= ondemand/) }
|
||||||
|
its(:content) { should match(/pm\s+= static/) }
|
||||||
end
|
end
|
||||||
|
|
||||||
%w[slow.log access.log log].each do |ext|
|
%w[slow.log access.log log].each do |ext|
|
||||||
describe file("/var/log/phpfpm/www.#{ext}") do
|
describe file("/var/log/phpfpm/website1.#{ext}") do
|
||||||
it { should be_file }
|
it { should be_file }
|
||||||
it { should be_mode 640 }
|
it { should be_mode 640 }
|
||||||
it { should be_owned_by 'root' }
|
it { should be_owned_by 'root' }
|
||||||
|
@ -55,3 +56,12 @@ describe service('php7.0-fpm') do
|
||||||
it { should be_enabled }
|
it { should be_enabled }
|
||||||
it { should be_running.under('systemd') }
|
it { should be_running.under('systemd') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
describe process('php-fpm: pool website1') do
|
||||||
|
its(:count) { should eq 0 }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe process('php-fpm: pool website2') do
|
||||||
|
its(:count) { should eq 4 }
|
||||||
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue