Fix for use of PHP-FPM instead of mod_php
Change-Id: Id9112adee54d093a36ebdcbe04cefcb32cbe0034
(cherry picked from commit 72a190d1d7
)
This commit is contained in:
parent
4cb25e1d4b
commit
2e67aed3e1
@ -4,6 +4,7 @@ require 'puppet-syntax/tasks/puppet-syntax'
|
||||
|
||||
PuppetLint.configuration.fail_on_warnings = true
|
||||
PuppetLint.configuration.send('disable_80chars')
|
||||
PuppetLint.configuration.send('disable_140chars')
|
||||
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
|
||||
PuppetLint.configuration.send('disable_class_parameter_defaults')
|
||||
PuppetLint.configuration.send('disable_autoloader_layout')
|
||||
|
@ -15,6 +15,7 @@
|
||||
#
|
||||
class plugin_zabbix::frontend {
|
||||
|
||||
include phpfpm
|
||||
include plugin_zabbix::params
|
||||
|
||||
service { $plugin_zabbix::params::frontend_service:
|
||||
@ -28,10 +29,20 @@ class plugin_zabbix::frontend {
|
||||
ensure => present,
|
||||
require => [
|
||||
File['/etc/dbconfig-common/zabbix-server-mysql.conf'],
|
||||
Package[$plugin_zabbix::params::php_mysql_pkg]
|
||||
Package[$plugin_zabbix::params::php_fpm_pkg],
|
||||
Package[$plugin_zabbix::params::php_mysql_pkg],
|
||||
Package[$plugin_zabbix::params::apache_fcgi_pkg]
|
||||
],
|
||||
}
|
||||
|
||||
package { $plugin_zabbix::params::php_common_pkg:
|
||||
ensure => present
|
||||
}
|
||||
|
||||
package { $plugin_zabbix::params::apache_fcgi_pkg:
|
||||
ensure => present
|
||||
}
|
||||
|
||||
package { $plugin_zabbix::params::php_mysql_pkg:
|
||||
ensure => present
|
||||
}
|
||||
@ -43,31 +54,9 @@ class plugin_zabbix::frontend {
|
||||
require => Package[$plugin_zabbix::params::frontend_pkg],
|
||||
}
|
||||
|
||||
file_line { 'php timezone':
|
||||
path => $plugin_zabbix::params::frontend_service_config,
|
||||
line => ' php_value date.timezone UTC',
|
||||
match => 'php_value date.timezone',
|
||||
notify => Service[$plugin_zabbix::params::frontend_service],
|
||||
require => Package[$plugin_zabbix::params::frontend_pkg],
|
||||
}
|
||||
|
||||
file_line { 'php memory_limit':
|
||||
path => $plugin_zabbix::params::frontend_service_config,
|
||||
line => ' php_value memory_limit 256M',
|
||||
match => 'php_value memory_limit',
|
||||
notify => Service[$plugin_zabbix::params::frontend_service],
|
||||
require => Package[$plugin_zabbix::params::frontend_pkg],
|
||||
}
|
||||
|
||||
file_line { 'set expose_php to off':
|
||||
path => $plugin_zabbix::params::php_config,
|
||||
match => 'expose_php =',
|
||||
line => 'expose_php = Off',
|
||||
notify => Service[$plugin_zabbix::params::frontend_service],
|
||||
require => Package[$plugin_zabbix::params::frontend_pkg],
|
||||
}
|
||||
|
||||
# disable worker MPM, use prefork MPM which is required by mod_php:
|
||||
# do not use prefork as it is incompatible with MOS 8.0 / Liberty
|
||||
# So need to enable a few more Apache modules to work with PHP-FPM
|
||||
# and mod worker
|
||||
case $::osfamily {
|
||||
'RedHat': {
|
||||
# default line: "HTTPD=/usr/sbin/httpd.worker"
|
||||
@ -83,27 +72,61 @@ class plugin_zabbix::frontend {
|
||||
}
|
||||
}
|
||||
'Debian': {
|
||||
|
||||
exec { 'disable-apache-worker':
|
||||
command => 'a2dismod worker',
|
||||
# Activate all modules required by $frontend_service_template
|
||||
exec { 'enable-apache-actions':
|
||||
command => 'a2enmod actions',
|
||||
path => ['/usr/sbin', '/usr/bin', '/sbin', '/bin'],
|
||||
notify => Service[$plugin_zabbix::params::frontend_service],
|
||||
require => Package[$plugin_zabbix::params::frontend_pkg],
|
||||
}
|
||||
|
||||
exec { 'enable-apache-prefork':
|
||||
command => 'a2enmod mpm_prefork',
|
||||
exec { 'enable-apache-rewrite':
|
||||
command => 'a2enmod rewrite',
|
||||
path => ['/usr/sbin', '/usr/bin', '/sbin', '/bin'],
|
||||
notify => Service[$plugin_zabbix::params::frontend_service],
|
||||
require => Package[$plugin_zabbix::params::frontend_pkg],
|
||||
}
|
||||
|
||||
exec { 'enable-apache-php5':
|
||||
command => 'a2enmod php5',
|
||||
exec { 'enable-apache-expires':
|
||||
command => 'a2enmod expires',
|
||||
path => ['/usr/sbin', '/usr/bin', '/sbin', '/bin'],
|
||||
notify => Service[$plugin_zabbix::params::frontend_service],
|
||||
require => Package[$plugin_zabbix::params::frontend_pkg],
|
||||
}
|
||||
|
||||
exec { 'enable-apache-fastcgi':
|
||||
command => 'a2enmod fastcgi',
|
||||
path => ['/usr/sbin', '/usr/bin', '/sbin', '/bin'],
|
||||
notify => Service[$plugin_zabbix::params::frontend_service],
|
||||
require => Package[$plugin_zabbix::params::frontend_pkg],
|
||||
}
|
||||
|
||||
# Cleanup existing default pools
|
||||
phpfpm::pool { 'www':
|
||||
ensure => 'absent',
|
||||
}
|
||||
|
||||
# Create Zabbix TCP pool using 127.0.0.1, port 9000, upstream defaults
|
||||
phpfpm::pool { 'zabbix':
|
||||
listen => '127.0.0.1:9000',
|
||||
require => Package[$plugin_zabbix::params::php_fpm_pkg],
|
||||
notify => Service[$plugin_zabbix::params::php_fpm_service],
|
||||
php_value => {
|
||||
'date.timezone' => 'UTC',
|
||||
'memory_limit' => '256M',
|
||||
'max_execution_time' => '300',
|
||||
'post_max_size' => '16M',
|
||||
'upload_max_filesize' => '2M',
|
||||
'max_input_time' => '300',
|
||||
},
|
||||
}
|
||||
|
||||
file_line { 'set expose_php to off':
|
||||
path => $plugin_zabbix::params::php_config,
|
||||
match => 'expose_php =',
|
||||
line => 'expose_php = Off',
|
||||
require => Package[$plugin_zabbix::params::frontend_pkg],
|
||||
}
|
||||
}
|
||||
default: {}
|
||||
}
|
||||
@ -118,13 +141,17 @@ class plugin_zabbix::frontend {
|
||||
provider => 'shell',
|
||||
before => Package[$plugin_zabbix::params::frontend_pkg],
|
||||
}
|
||||
file { '/etc/apache2/conf.d/zabbix.conf':
|
||||
ensure => link,
|
||||
target => $plugin_zabbix::params::frontend_service_config,
|
||||
|
||||
# Apache configuration from template
|
||||
file { $plugin_zabbix::params::frontend_service_config:
|
||||
ensure => present,
|
||||
content => template($plugin_zabbix::params::frontend_service_template),
|
||||
notify => Service[$plugin_zabbix::params::frontend_service],
|
||||
require => Package[$plugin_zabbix::params::frontend_pkg],
|
||||
}
|
||||
}
|
||||
default: {}
|
||||
default: {
|
||||
fail("unsuported osfamily ${::osfamily}, currently Debian is the only supported platform")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,11 @@ class plugin_zabbix::params {
|
||||
|
||||
case $::operatingsystem {
|
||||
'Ubuntu', 'Debian': {
|
||||
$php_fpm_pkg = 'php5-fpm'
|
||||
$php_fpm_config = '/etc/php5/fpm/pool.d/www.conf'
|
||||
$php_fpm_service = 'php5-fpm'
|
||||
$php_common_pkg = 'php5-common'
|
||||
$apache_fcgi_pkg = 'libapache2-mod-fastcgi'
|
||||
$agent_pkg = 'zabbix-agent'
|
||||
$server_pkg = 'zabbix-server-mysql'
|
||||
$frontend_pkg = 'zabbix-frontend-php'
|
||||
@ -49,13 +54,17 @@ class plugin_zabbix::params {
|
||||
$prepare_schema_cmd = 'cat /usr/share/zabbix-server-mysql/schema.sql /usr/share/zabbix-server-mysql/images.sql > /tmp/zabbix/schema.sql'
|
||||
|
||||
$frontend_service = 'apache2'
|
||||
$frontend_service_config = "${zabbix_base_conf_dir}/apache.conf"
|
||||
$frontend_service_template = 'plugin_zabbix/zabbix_apache.conf.erb'
|
||||
# For some unknown reason putting the file in conf-available
|
||||
# and running 'a2enconf zabbix' does not work, so keeping conf file
|
||||
# in conf.d for now
|
||||
$frontend_service_config = '/etc/apache2/conf.d/zabbix.conf'
|
||||
$frontend_config = "${zabbix_base_conf_dir}/web/zabbix.conf.php"
|
||||
$php_config = '/etc/php5/apache2/php.ini'
|
||||
$php_config = '/etc/php5/fpm/php.ini'
|
||||
$php_mysql_pkg = 'php5-mysql'
|
||||
$zabbix_document_root = '/usr/share/zabbix'
|
||||
}
|
||||
'CentOS', 'RedHat': {
|
||||
|
||||
$agent_pkg = 'zabbix-agent'
|
||||
$server_pkg = 'zabbix-server-mysql'
|
||||
$frontend_pkg = 'zabbix-web-mysql'
|
||||
@ -164,5 +173,4 @@ class plugin_zabbix::params {
|
||||
$api_hash = { endpoint => $api_url,
|
||||
username => $zabbix_admin_username,
|
||||
password => $zabbix_admin_password, }
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
### Managed by Puppet ###
|
||||
|
||||
# Define /zabbix alias, this is the default
|
||||
<IfModule mod_alias.c>
|
||||
Alias /zabbix <%= scope.lookupvar('plugin_zabbix::params::zabbix_document_root') %>
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_fastcgi.c>
|
||||
AddHandler fastcgi-php5-fpm .php php phar
|
||||
Action fastcgi-php5-fpm /fastcgi-php5-fpm virtual
|
||||
Alias /fastcgi-php5-fpm <%= scope.lookupvar('plugin_zabbix::params::zabbix_document_root') %>/fastcgi-php5-fpm
|
||||
FastCgiExternalServer <%= scope.lookupvar('plugin_zabbix::params::zabbix_document_root') %>/fastcgi-php5-fpm -host 127.0.0.1:9000 -idle-timeout 900 -pass-header Authorization -pass-header Range
|
||||
</IfModule>
|
||||
|
||||
<Directory "<%= scope.lookupvar('plugin_zabbix::params::zabbix_document_root') %>">
|
||||
<IfModule authz_core_module>
|
||||
# Only when redirected internally by FastCGI.
|
||||
Require env REDIRECT_STATUS
|
||||
Options +ExecCGI
|
||||
</IfModule>
|
||||
Require all granted
|
||||
Options FollowSymLinks
|
||||
AllowOverride None
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</Directory>
|
||||
|
||||
<Directory "<%= scope.lookupvar('plugin_zabbix::params::zabbix_document_root') %>/conf">
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "<%= scope.lookupvar('plugin_zabbix::params::zabbix_document_root') %>/api">
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "<%= scope.lookupvar('plugin_zabbix::params::zabbix_document_root') %>/include">
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
||||
|
||||
<Directory "<%= scope.lookupvar('plugin_zabbix::params::zabbix_document_root') %>/include/classes">
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
<files *.php>
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
</files>
|
||||
</Directory>
|
46
functions.sh
Normal file
46
functions.sh
Normal file
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2015 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -eux
|
||||
|
||||
ROOT="$(dirname "$(readlink -f "$0")")"
|
||||
MODULES_DIR="${ROOT}"/deployment_scripts/puppet/modules
|
||||
RPM_REPO="${ROOT}"/repositories/centos/
|
||||
DEB_REPO="${ROOT}"/repositories/ubuntu/
|
||||
|
||||
# Download RPM or DEB packages and store them in the local repository directory
|
||||
function download_package {
|
||||
while [ $# -gt 0 ]; do
|
||||
if [[ "$1" == *.deb ]]; then
|
||||
REPO=$DEB_REPO
|
||||
elif [[ "$1" == *.rpm ]]; then
|
||||
REPO=$RPM_REPO
|
||||
else
|
||||
echo "Invalid URL for download_package(): $1"
|
||||
fi
|
||||
|
||||
FILE=$(basename "$1")
|
||||
wget -qO - "$1" > "$REPO"/"$FILE"
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
# Download official Puppet module and store it in the local directory
|
||||
function download_puppet_module {
|
||||
rm -rf "${MODULES_DIR:?}"/"$1"
|
||||
mkdir -p "${MODULES_DIR}"/"$1"
|
||||
wget -qO- "$2" | tar -C "${MODULES_DIR}/$1" --strip-components=1 -xz
|
||||
}
|
||||
|
@ -2,6 +2,13 @@
|
||||
set -eux
|
||||
|
||||
ROOT="$(dirname `readlink -f $0`)"
|
||||
|
||||
. "${ROOT}"/functions.sh
|
||||
|
||||
# Puppet manifests
|
||||
# Dependency for PHP-FPM
|
||||
PHPFPM_TARBALL_URL="https://forgeapi.puppetlabs.com/v3/files/Slashbunny-phpfpm-0.0.8.tar.gz"
|
||||
|
||||
RPM_REPO="${ROOT}"/repositories/centos/
|
||||
DEB_REPO="${ROOT}"/repositories/ubuntu/
|
||||
mkdir -p $RPM_REPO
|
||||
@ -28,6 +35,8 @@ download deb http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix/zabbix-
|
||||
http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix/zabbix-sender_2.4.4-1+trusty_amd64.deb \
|
||||
http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix/zabbix-get_2.4.4-1+trusty_amd64.deb \
|
||||
http://archive.ubuntu.com/ubuntu/pool/main/p/php5/php5-mysql_5.5.9+dfsg-1ubuntu4.14_amd64.deb \
|
||||
http://archive.ubuntu.com/ubuntu/pool/main/p/php5/php5-common_5.5.9+dfsg-1ubuntu4.14_amd64.deb \
|
||||
http://archive.ubuntu.com/ubuntu/pool/universe/p/php5/php5-fpm_5.5.9+dfsg-1ubuntu4.14_amd64.deb \
|
||||
http://archive.ubuntu.com/ubuntu/pool/universe/n/net-snmp/libsnmp-perl_5.7.2~dfsg-8.1ubuntu3.1_amd64.deb \
|
||||
http://archive.ubuntu.com/ubuntu/pool/universe/s/snmptt/snmptt_1.4-1_all.deb \
|
||||
http://archive.ubuntu.com/ubuntu/pool/universe/libs/libsmi/smistrip_0.4.8+dfsg2-8ubuntu2_all.deb \
|
||||
@ -43,3 +52,6 @@ download rpm http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-agent-2.4.4-
|
||||
http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-sender-2.4.4-1.el6.x86_64.rpm \
|
||||
http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-get-2.4.4-1.el6.x86_64.rpm \
|
||||
http://mirror.centos.org/centos/6/os/x86_64/Packages/iptstate-2.2.2-4.el6.x86_64.rpm
|
||||
|
||||
# Install puppet manifests
|
||||
download_puppet_module "phpfpm" "$PHPFPM_TARBALL_URL"
|
||||
|
Loading…
Reference in New Issue
Block a user