env: | env: | ||||
matrix: | matrix: | ||||
- INSTANCE: debian-debian-9-develop-py3 | - INSTANCE: debian-debian-9-develop-py3 | ||||
# - INSTANCE: debian-ubuntu-1804-develop-py3 | |||||
# - INSTANCE: ubuntu-ubuntu-1804-develop-py3 | |||||
# - INSTANCE: redhat-centos-7-develop-py3 | # - INSTANCE: redhat-centos-7-develop-py3 | ||||
# - INSTANCE: redhat-fedora-29-develop-py3 | # - INSTANCE: redhat-fedora-29-develop-py3 | ||||
# - INSTANCE: suse-opensuse-leap-15-develop-py3 | # - INSTANCE: suse-opensuse-leap-15-develop-py3 | ||||
# - INSTANCE: debian-debian-9-2019-2-py3 | # - INSTANCE: debian-debian-9-2019-2-py3 | ||||
- INSTANCE: debian-ubuntu-1804-2019-2-py3 | |||||
- INSTANCE: ubuntu-ubuntu-1804-2019-2-py3 | |||||
- INSTANCE: redhat-centos-7-2019-2-py3 | - INSTANCE: redhat-centos-7-2019-2-py3 | ||||
# - INSTANCE: redhat-fedora-29-2019-2-py3 | # - INSTANCE: redhat-fedora-29-2019-2-py3 | ||||
# - INSTANCE: suse-opensuse-leap-15-2019-2-py3 | # - INSTANCE: suse-opensuse-leap-15-2019-2-py3 | ||||
# - INSTANCE: debian-debian-9-2018-3-py2 | # - INSTANCE: debian-debian-9-2018-3-py2 | ||||
# - INSTANCE: debian-ubuntu-1604-2018-3-py2 | |||||
# - INSTANCE: ubuntu-ubuntu-1604-2018-3-py2 | |||||
# - INSTANCE: redhat-centos-7-2018-3-py2 | # - INSTANCE: redhat-centos-7-2018-3-py2 | ||||
- INSTANCE: redhat-fedora-29-2018-3-py2 | - INSTANCE: redhat-fedora-29-2018-3-py2 | ||||
- INSTANCE: suse-opensuse-leap-42-2018-3-py2 | - INSTANCE: suse-opensuse-leap-42-2018-3-py2 | ||||
# - INSTANCE: debian-debian-8-2017-7-py2 | # - INSTANCE: debian-debian-8-2017-7-py2 | ||||
# - INSTANCE: debian-ubuntu-1604-2017-7-py2 | |||||
# - INSTANCE: ubuntu-ubuntu-1604-2017-7-py2 | |||||
- INSTANCE: redhat-centos-6-2017-7-py2 | - INSTANCE: redhat-centos-6-2017-7-py2 | ||||
# - INSTANCE: redhat-fedora-28-2017-7-py2 | # - INSTANCE: redhat-fedora-28-2017-7-py2 | ||||
# - INSTANCE: suse-opensuse-leap-42-2017-7-py2 | # - INSTANCE: suse-opensuse-leap-42-2017-7-py2 | ||||
# Install and run `yamllint` | # Install and run `yamllint` | ||||
- pip install --user yamllint | - pip install --user yamllint | ||||
# yamllint disable-line rule:line-length | # yamllint disable-line rule:line-length | ||||
- yamllint -s . .yamllint pillar.example test/salt/pillar/debian.sls test/salt/pillar/redhat.sls test/salt/pillar/suse.sls | |||||
- yamllint -s . .yamllint pillar.example test/salt/pillar/debian.sls test/salt/pillar/ubuntu.sls test/salt/pillar/redhat.sls test/salt/pillar/suse.sls | |||||
# Install and run `commitlint` | # Install and run `commitlint` | ||||
- npm install @commitlint/config-conventional -D | - npm install @commitlint/config-conventional -D | ||||
- npm install @commitlint/travis-cli -D | - npm install @commitlint/travis-cli -D |
- name: debian | - name: debian | ||||
includes: | includes: | ||||
- debian-9-develop-py3 | - debian-9-develop-py3 | ||||
- ubuntu-1804-develop-py3 | |||||
- debian-9-2019-2-py3 | - debian-9-2019-2-py3 | ||||
- ubuntu-1804-2019-2-py3 | |||||
- debian-9-2018-3-py2 | - debian-9-2018-3-py2 | ||||
- ubuntu-1604-2018-3-py2 | |||||
- debian-8-2017-7-py2 | - debian-8-2017-7-py2 | ||||
provisioner: | |||||
state_top: | |||||
base: | |||||
'*': | |||||
- php.repo | |||||
- php.fpm.install | |||||
- php.fpm.config | |||||
- php.fpm.pools | |||||
- php.modules | |||||
- php.fpm.service | |||||
pillars: | |||||
top.sls: | |||||
base: | |||||
'*': | |||||
- php | |||||
pillars_from_files: | |||||
php.sls: test/salt/pillar/debian.sls | |||||
verifier: | |||||
inspec_tests: | |||||
- path: test/integration/default | |||||
- name: ubuntu | |||||
includes: | |||||
- ubuntu-1804-develop-py3 | |||||
- ubuntu-1804-2019-2-py3 | |||||
- ubuntu-1604-2018-3-py2 | |||||
- ubuntu-1604-2017-7-py2 | - ubuntu-1604-2017-7-py2 | ||||
provisioner: | provisioner: | ||||
state_top: | state_top: | ||||
base: | base: | ||||
'*': | '*': | ||||
- php | |||||
- php.repo | |||||
- php.fpm.install | |||||
- php.fpm.config | |||||
- php.fpm.pools | |||||
- php.modules | |||||
- php.fpm.service | |||||
pillars: | pillars: | ||||
top.sls: | top.sls: | ||||
base: | base: | ||||
'*': | '*': | ||||
- php | - php | ||||
- ubuntu | |||||
pillars_from_files: | pillars_from_files: | ||||
php.sls: test/salt/pillar/debian.sls | php.sls: test/salt/pillar/debian.sls | ||||
ubuntu.sls: test/salt/pillar/ubuntu.sls | |||||
verifier: | verifier: | ||||
inspec_tests: | inspec_tests: | ||||
- path: test/integration/default | - path: test/integration/default |
- php.fpm.pools | - php.fpm.pools | ||||
{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} | {% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} | ||||
extend: | extend: | ||||
php_fpm_service: | |||||
{% if pillar_php_version is iterable and pillar_php_version is not string %} | |||||
{% for version in pillar_php_version %} | |||||
php_fpm_service_{{ version }}: | |||||
service: | service: | ||||
- watch: | - watch: | ||||
{% if pillar_php_version is iterable and pillar_php_version is not string %} | |||||
{% for version in pillar_php_version %} | |||||
- file: php_fpm_ini_config_{{ version }} | - file: php_fpm_ini_config_{{ version }} | ||||
- file: php_fpm_conf_config_{{ version }} | - file: php_fpm_conf_config_{{ version }} | ||||
{% endfor %} | |||||
{% else %} | |||||
- file: php_fpm_ini_config | |||||
- file: php_fpm_conf_config | |||||
{% endif %} | |||||
- require: | - require: | ||||
- sls: php.fpm.config | - sls: php.fpm.config | ||||
{% if pillar_php_version is iterable and pillar_php_version is not string %} | |||||
{% for version in pillar_php_version %} | |||||
php_fpm_ini_config_{{ version }}: | php_fpm_ini_config_{{ version }}: | ||||
file: | file: | ||||
- require: | - require: | ||||
- pkg: php_install_fpm | - pkg: php_install_fpm | ||||
php_fpm_conf_config_{{ version }}: | php_fpm_conf_config_{{ version }}: | ||||
file: | file: | ||||
- require: | - require: | ||||
- pkg: php_install_fpm | - pkg: php_install_fpm | ||||
{% endfor %} | |||||
{% else %} | |||||
{% endfor %} | |||||
{% else %} | |||||
php_fpm_service: | |||||
service: | |||||
- watch: | |||||
- file: php_fpm_ini_config | |||||
- file: php_fpm_conf_config | |||||
- require: | |||||
- sls: php.fpm.config | |||||
php_fpm_ini_config: | php_fpm_ini_config: | ||||
file: | file: | ||||
- require: | - require: | ||||
- pkg: php_install_fpm | - pkg: php_install_fpm | ||||
php_fpm_conf_config: | php_fpm_conf_config: | ||||
file: | file: | ||||
- require: | - require: | ||||
- pkg: php_install_fpm | - pkg: php_install_fpm | ||||
{% endif %} | |||||
{% endif %} |
# Manages the php-fpm pools config files | # Manages the php-fpm pools config files | ||||
{% from "php/map.jinja" import php with context %} | {% from "php/map.jinja" import php with context %} | ||||
{% from "php/macro.jinja" import sls_block %} | {% from "php/macro.jinja" import sls_block %} | ||||
{% from "php/macro.jinja" import file_requisites %} | |||||
{% from "php/fpm/pools_config.sls" import pool_states with context %} | {% from "php/fpm/pools_config.sls" import pool_states with context %} | ||||
{% macro file_requisites(states) %} | |||||
{%- for state in states %} | |||||
- file: {{ state }} | |||||
{%- endfor -%} | |||||
{% endmacro %} | |||||
include: | include: | ||||
- php.fpm.service | - php.fpm.service | ||||
- php.fpm.pools_config | - php.fpm.pools_config | ||||
{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} | |||||
{% if pool_states %} | {% if pool_states %} | ||||
extend: | extend: | ||||
{% if pillar_php_version is iterable and pillar_php_version is not string %} | |||||
{% for version in pillar_php_version %} | |||||
php_fpm_service_{{ version }}: | |||||
service: | |||||
- watch: | |||||
{{ file_requisites(pool_states) }} | |||||
- require: | |||||
{{ file_requisites(pool_states) }} | |||||
{% endfor %} | |||||
{% else %} | |||||
php_fpm_service: | php_fpm_service: | ||||
service: | service: | ||||
- watch: | - watch: | ||||
{{ file_requisites(pool_states) }} | {{ file_requisites(pool_states) }} | ||||
- require: | - require: | ||||
{{ file_requisites(pool_states) }} | {{ file_requisites(pool_states) }} | ||||
{% endif %} | |||||
{% endif %} | {% endif %} |
{% from "php/macro.jinja" import sls_block %} | {% from "php/macro.jinja" import sls_block %} | ||||
{% set service_function = {True:'running', False:'dead'}.get(php.fpm.service.enabled) %} | {% set service_function = {True:'running', False:'dead'}.get(php.fpm.service.enabled) %} | ||||
{% set pillar_php_version = salt['pillar.get']('php:version', '7.0') %} | |||||
include: | include: | ||||
- php.fpm.install | - php.fpm.install | ||||
{% if pillar_php_version is iterable and pillar_php_version is not string %} | |||||
{% for version in pillar_php_version %} | |||||
php_fpm_service_{{ version }}: | |||||
service.{{ service_function }}: | |||||
{{ sls_block(php.fpm.service.opts) }} | |||||
- name: {{ 'php' ~ version ~ '-fpm' }} | |||||
- enable: {{ php.fpm.service.enabled }} | |||||
- require: | |||||
- sls: php.fpm.install | |||||
- watch: | |||||
- pkg: php_install_fpm | |||||
{% endfor %} | |||||
{% else %} | |||||
php_fpm_service: | php_fpm_service: | ||||
service.{{ service_function }}: | service.{{ service_function }}: | ||||
{{ sls_block(php.fpm.service.opts) }} | {{ sls_block(php.fpm.service.opts) }} | ||||
- sls: php.fpm.install | - sls: php.fpm.install | ||||
- watch: | - watch: | ||||
- pkg: php_install_fpm | - pkg: php_install_fpm | ||||
{% endif %} |
{{ ret|json() }} | {{ ret|json() }} | ||||
{%- endmacro -%} | {%- endmacro -%} | ||||
{% macro file_requisites(states) %} | |||||
{%- for state in states %} | |||||
- file: {{ state }} | |||||
{%- endfor -%} | |||||
{% endmacro %} | |||||
{%- macro format_kwargs(kwarg) -%} | |||||
{%- filter indent(4) %} | |||||
{%- for k, v in kwarg|dictsort() %} | |||||
- {{ k }}: {{ v }} | |||||
{%- endfor %} | |||||
{%- endfilter %} | |||||
{%- endmacro %} |
'php': 'php' + php_version, | 'php': 'php' + php_version, | ||||
'phpenmod_command': 'phpenmod -v' + php_version, | 'phpenmod_command': 'phpenmod -v' + php_version, | ||||
'pspell': 'php' + php_version + '-pspell', | 'pspell': 'php' + php_version + '-pspell', | ||||
'redis': 'php' + php_version + '-redis', | |||||
'readline': 'php' + php_version + '-readline', | |||||
'redis': 'php-redis', | |||||
'seclib': ['php-phpseclib', 'php-seclib'], | 'seclib': ['php-phpseclib', 'php-seclib'], | ||||
'snmp': 'php' + php_version + '-snmp', | 'snmp': 'php' + php_version + '-snmp', | ||||
'soap': 'php' + php_version + '-soap', | 'soap': 'php' + php_version + '-soap', | ||||
'tcpdf': 'php-tcpdf', | 'tcpdf': 'php-tcpdf', | ||||
'temp_dir': '/tmp', | 'temp_dir': '/tmp', | ||||
'tidy': 'php' + php_version + '-tidy', | 'tidy': 'php' + php_version + '-tidy', | ||||
'xdebug': 'php' + php_version + '-xdebug', | |||||
'xdebug': 'php-xdebug', | |||||
'xml': ['php' + php_version + '-xml', 'php' + php_version + '-xmlrpc'], | 'xml': ['php' + php_version + '-xml', 'php' + php_version + '-xmlrpc'], | ||||
'xsl': 'php' + php_version + '-xsl', | 'xsl': 'php' + php_version + '-xsl', | ||||
'zip': 'php' + php_version + '-zip', | 'zip': 'php' + php_version + '-zip', | ||||
'tcpdf': 'php-tcpdf', | 'tcpdf': 'php-tcpdf', | ||||
'temp_dir': '/tmp', | 'temp_dir': '/tmp', | ||||
'tidy': 'php' + php_version + '-tidy', | 'tidy': 'php' + php_version + '-tidy', | ||||
'xdebug': 'php' + php_version + '-xdebug', | |||||
'xdebug': 'php-xdebug', | |||||
'xml': ['php' + php_version + '-xml', 'php' + php_version + '-xmlrpc'], | 'xml': ['php' + php_version + '-xml', 'php' + php_version + '-xmlrpc'], | ||||
'xsl': 'php' + php_version + '-xsl', | 'xsl': 'php' + php_version + '-xsl', | ||||
'zip': 'php' + php_version + '-zip', | 'zip': 'php' + php_version + '-zip', |
# -*- coding: utf-8 -*- | |||||
# vim: ft=sls | |||||
include: | |||||
- .install |
# -*- coding: utf-8 -*- | |||||
# vim: ft=sls | |||||
{#- Get the `tplroot` from `tpldir` #} | |||||
{%- set tplroot = tpldir.split('/')[0] %} | |||||
{%- from tplroot ~ "/map.jinja" import php with context %} | |||||
{%- from tplroot ~ "/macro.jinja" import format_kwargs with context %} | |||||
php/repo/install: | |||||
pkgrepo.managed: | |||||
{{- format_kwargs(php.repo) }} |
control 'Php configuration' do | |||||
title 'should match desired lines' | |||||
def test_debian | |||||
describe file('/etc/php/5.6/fpm/pool.d/radius-admin.conf') do | |||||
its('content') { should include '[radius-admin]' } | |||||
its('content') { should include 'php_admin_value[date.timezone] = Europe/Paris' } | |||||
end | |||||
describe file('/etc/php/7.3/fpm/pool.d/ldap-admin.conf') do | |||||
its('content') { should include '[ldap-admin]' } | |||||
its('content') { should include 'php_admin_value[date.timezone] = Europe/Paris' } | |||||
end | |||||
describe file('/etc/php/5.6/fpm/php.ini') do | |||||
its('content') { should include 'date.timezone = Europe/Paris' } | |||||
end | |||||
describe file('/etc/php/7.3/fpm/php.ini') do | |||||
its('content') { should include 'date.timezone = Europe/Paris' } | |||||
end | |||||
end | |||||
def test_redhat | |||||
end | |||||
def test_suse | |||||
end | |||||
case os[:family] | |||||
when 'debian' | |||||
test_debian | |||||
when 'redhat', 'fedora' | |||||
test_redhat | |||||
when 'suse' | |||||
test_suse | |||||
end | |||||
end |
control 'Php package' do | control 'Php package' do | ||||
title 'should be installed' | title 'should be installed' | ||||
pkg_name = | |||||
case os[:family] | |||||
when 'debian' | |||||
case os[:name] | |||||
when 'ubuntu' | |||||
'php' | |||||
when 'debian' | |||||
'php7.0' | |||||
def test_debian | |||||
describe package('php-imagick') do | |||||
it { should be_installed } | |||||
end | |||||
describe package('php-redis') do | |||||
it { should be_installed } | |||||
end | |||||
describe package('php-xdebug') do | |||||
it { should be_installed } | |||||
end | |||||
%w[ | |||||
bz2 cli curl fpm gd imap intl mbstring | |||||
mysql readline xml zip | |||||
].each do |pkg| | |||||
describe package("php5.6-#{pkg}") do | |||||
it { should be_installed } | |||||
end | |||||
describe package("php7.3-#{pkg}") do | |||||
it { should be_installed } | |||||
end | end | ||||
when 'redhat', 'fedora' | |||||
'php' | |||||
when 'suse' | |||||
'php5' | |||||
end | end | ||||
end | |||||
def test_redhat | |||||
describe package('php') do | |||||
it { should be_installed } | |||||
end | |||||
end | |||||
def test_suse | |||||
describe package('php5') do | |||||
it { should be_installed } | |||||
end | |||||
end | |||||
describe package(pkg_name) do | |||||
it { should be_installed } | |||||
case os[:family] | |||||
when 'debian' | |||||
test_debian | |||||
when 'redhat', 'fedora' | |||||
test_redhat | |||||
when 'suse' | |||||
test_suse | |||||
end | end | ||||
end | end |
control 'Php service' do | |||||
title 'should be running and enabled' | |||||
def test_debian | |||||
describe service('php5.6-fpm') do | |||||
it { should be_enabled } | |||||
it { should be_running } | |||||
end | |||||
describe service('php7.3-fpm') do | |||||
it { should be_enabled } | |||||
it { should be_running } | |||||
end | |||||
end | |||||
def test_redhat | |||||
end | |||||
def test_suse | |||||
end | |||||
case os[:family] | |||||
when 'debian' | |||||
test_debian | |||||
when 'redhat', 'fedora' | |||||
test_redhat | |||||
when 'suse' | |||||
test_suse | |||||
end | |||||
end |
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||
# vim: ft=yaml | # vim: ft=yaml | ||||
--- | --- | ||||
php: {} | |||||
php: | |||||
repo: | |||||
humanname: php-sury repo | |||||
# yamllint disable-line rule:line-length | |||||
name: "deb https://packages.sury.org/php/ {{ salt['grains.get']('oscodename') }} main" | |||||
file: /etc/apt/sources.list.d/php-sury.list | |||||
key_url: https://packages.sury.org/php/apt.gpg | |||||
version: | |||||
- '5.6' | |||||
- '7.3' | |||||
fpm: | |||||
config: | |||||
ini: | |||||
settings: | |||||
Assertion: | |||||
zend.assertions: -1 | |||||
PHP: | |||||
expose_php: 'Off' | |||||
default_charset: UTF-8 | |||||
cgi.fix_pathinfo: 0 | |||||
Date: | |||||
date.timezone: Europe/Paris | |||||
pools: | |||||
'radius-admin.conf': | |||||
enabled: true | |||||
phpversion: '5.6' | |||||
settings: | |||||
radius-admin: | |||||
user: www-data | |||||
group: www-data | |||||
listen: /tmp/php-fpm-radius-admin.sock | |||||
listen.mode: '0666' | |||||
pm: static | |||||
pm.max_children: 3 | |||||
pm.max_requests: 500 | |||||
pm.status_path: /php-status | |||||
ping.path: /php-ping | |||||
catch_workers_output: 'yes' | |||||
security.limit_extensions: .php | |||||
'php_admin_value[date.timezone]': Europe/Paris | |||||
'ldap-admin.conf': | |||||
enabled: true | |||||
phpversion: '7.3' | |||||
settings: | |||||
ldap-admin: | |||||
user: www-data | |||||
group: www-data | |||||
listen: /tmp/php-fpm-ldap-admin2.sock | |||||
listen.mode: '0666' | |||||
pm: static | |||||
pm.max_children: 3 | |||||
pm.max_requests: 500 | |||||
pm.status_path: /php-status | |||||
ping.path: /php-ping | |||||
catch_workers_output: 'yes' | |||||
security.limit_extensions: .php | |||||
'php_admin_value[date.timezone]': Europe/Paris | |||||
cli: | |||||
ini: | |||||
settings: | |||||
Assertion: | |||||
zend.assertions: -1 | |||||
PHP: | |||||
default_charset: UTF-8 | |||||
Date: | |||||
date.timezone: Europe/Paris | |||||
modules: | |||||
- bz2 | |||||
- cli | |||||
- curl | |||||
- gd | |||||
- imagick | |||||
- imap | |||||
- intl | |||||
- mbstring | |||||
- mysql | |||||
- readline | |||||
- redis | |||||
- xdebug | |||||
- xml | |||||
- zip |
# -*- coding: utf-8 -*- | |||||
# vim: ft=yaml | |||||
--- | |||||
php: | |||||
use_external_repo: true | |||||
repo: | |||||
humanname: php-sury ppa | |||||
# yamllint disable-line rule:line-length | |||||
name: "deb http://ppa.launchpad.net/ondrej/php/ubuntu {{ salt['grains.get']('oscodename') }} main" | |||||
file: /etc/apt/sources.list.d/php-sury.list | |||||
# yamllint disable-line rule:line-length | |||||
key_url: https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c |