Commit a7bb4fa9 authored by mh's avatar mh
Browse files

modernize + linting

parent 9d110ace
# manage apc package
class php::apc {
if versioncmp($::operatingsystemmajrelease,'5') > 0 {
package{'php-pecl-apcu':
ensure => installed,
}
$settings_path = '/etc/php.d/apcu.ini'
} else {
package{'php-pecl-apc':
ensure => installed,
}
$settings_path = '/etc/php.d/apc.ini'
package { 'php-pecl-apcu':
ensure => installed,
}
php::apc::settings{$settings_path: }
$settings_path = '/etc/php.d/apcu.ini'
php::apc::settings { $settings_path: }
}
# setup php
class php::base {
package{['php','php-fpm']:
package { ['php','php-fpm']:
ensure => present,
require => Package['apache'],
} -> file{
} -> file {
'/etc/php.d/timezone.ini':
content => "date.timezone = '${php::timezone}'\n",
notify => Service['apache'],
......@@ -21,7 +21,7 @@ class php::base {
}
$php_settings = deep_merge($php::security_settings,deep_merge($php::settings,
$php::params::global_settings))
$php::params::global_settings))
$defaults = {
path => '/etc/php.ini',
require => Package['php'],
......@@ -29,7 +29,7 @@ class php::base {
}
create_ini_settings($php_settings,$defaults)
package{'php-suhosin':
package { 'php-suhosin':
ensure => installed,
require => Package['php'],
}
......@@ -42,19 +42,17 @@ class php::base {
$default_suhosin_settings = {}
}
$suhosin_settings = merge(merge($php::suhosin_settings,
$php::suhosin_default_settings),
$default_suhosin_settings)
$php::suhosin_default_settings),
$default_suhosin_settings)
$suhosin_defaults = {
path => '/etc/php.d/suhosin.ini',
require => Package['php-suhosin'],
notify => Service['apache'],
}
create_ini_settings({'' => $suhosin_settings},$suhosin_defaults)
create_ini_settings( { '' => $suhosin_settings },$suhosin_defaults)
include ::php::extensions::common
include php::extensions::common
if versioncmp($::operatingsystemmajrelease,'6') > 0 {
include ::php::extensions::pecl::opcache
}
include ::php::apc
include php::extensions::pecl::opcache
include php::apc
}
# manage cli package
class php::cli {
php::package{'cli':
mode => 'direct',
php::package { 'cli':
ensure => present,
mode => 'direct',
}
}
# install composer
class php::composer {
package{'composer':
package { 'composer':
ensure => installed,
}
}
......@@ -2,7 +2,7 @@
# we want it especially tight to the current
# architecture
class php::devel {
package{"php-devel.${::architecture}":
package { "php-devel.${facts['os']['architecture']}":
ensure => installed,
require => Package['php'],
}
......
......@@ -4,7 +4,7 @@ class php::disable_mod_php {
# which is obsolete here, but we want
# to keep the file so an update of the
# php rpm would not place it there again.
file{'/etc/httpd/conf.d/php.conf':
file { '/etc/httpd/conf.d/php.conf':
content => "# empty by intend as we are using mod_fcgid\n",
require => Package['php'],
notify => Service['apache'],
......
# manage a php fpm instance
define php::fpm(
define php::fpm (
Optional[Pattern[/\Aphp\d+\Z/]] $php_inst_class = undef,
Enum['present','absent'] $ensure = 'present',
Stdlib::Compat::Absolute_Path $workdir = "/var/www/vhosts/${name}",
......@@ -12,9 +12,8 @@ define php::fpm(
String $run_user = "${name}_run",
String $run_group = $name,
Array[Stdlib::Compat::Absolute_Path]
$writable_dirs = [],
){
$writable_dirs = [],
) {
include systemd::systemctl::daemon_reload
include php::disable_mod_php
if $php_inst_class {
......@@ -31,10 +30,10 @@ define php::fpm(
$php_name = 'php'
$binary = '/usr/sbin/php-fpm'
}
service{
[ "fpm-${name}.socket",
"fpm-${name}" ]:;
} -> logrotate::rule{
service {
["fpm-${name}.socket",
"fpm-${name}"]:;
} -> logrotate::rule {
"fpm-error-logs-${name}":
path => "${logdir}/fpm-error.log",
missingok => true,
......@@ -45,8 +44,8 @@ define php::fpm(
su_user => $run_user,
su_group => $run_group,
}
file{
[ "${etcdir}/php-fpm.d/${name}.conf",
file {
["${etcdir}/php-fpm.d/${name}.conf",
"/etc/systemd/system/fpm-${name}.socket",
"/etc/systemd/system/fpm-${name}.service",
]:
......@@ -56,17 +55,17 @@ define php::fpm(
if $ensure == 'present' {
include php::fpm::base
$real_fpm_settings = $php::fpm::base::settings + $fpm_settings
File[ "${etcdir}/php-fpm.d/${name}.conf"]{
File["${etcdir}/php-fpm.d/${name}.conf"] {
content => template('php/fpm/conf.erb'),
group => $run_group,
mode => '0640',
}
File["/etc/systemd/system/fpm-${name}.socket",
"/etc/systemd/system/fpm-${name}.service"]{
group => 0,
mode => '0644',
"/etc/systemd/system/fpm-${name}.service"] {
group => 0,
mode => '0644',
}
File["/etc/systemd/system/fpm-${name}.socket"]{
File["/etc/systemd/system/fpm-${name}.socket"] {
content => template('php/fpm/systemd-socket.erb'),
notify => Service["fpm-${name}.socket"],
}
......@@ -74,27 +73,27 @@ define php::fpm(
content => template('php/fpm/systemd-service.erb'),
notify => Service["fpm-${name}"],
}
Exec['systemctl-daemon-reload'] -> Service["fpm-${name}.socket"]{
Exec['systemctl-daemon-reload'] -> Service["fpm-${name}.socket"] {
ensure => 'running',
enable => true,
} ~> Service["fpm-${name}"]{
} ~> Service["fpm-${name}"] {
tag => "systemd-${php_name}-fpm"
} -> Service<| title == 'apache' |>
User<| title == $run_user |> -> Service["fpm-${name}.socket"]
Group<| title == $run_group |> -> Service["fpm-${name}.socket"]
} else {
Logrotate::Rule["fpm-error-logs-${name}"]{
Logrotate::Rule["fpm-error-logs-${name}"] {
ensure => absent,
}
Service["fpm-${name}"]{
Service["fpm-${name}"] {
ensure => stopped,
enable => false,
} -> Service["fpm-${name}.socket"]{
} -> Service["fpm-${name}.socket"] {
ensure => stopped,
enable => false
} -> File[ "${etcdir}/php-fpm.d/${name}.conf",
} -> File["${etcdir}/php-fpm.d/${name}.conf",
"/etc/systemd/system/fpm-${name}.socket",
"/etc/systemd/system/fpm-${name}.service"] {
"/etc/systemd/system/fpm-${name}.service"] {
ensure => absent,
}
......
......@@ -5,7 +5,7 @@
# Marcel Haerry haerry+puppet(at)puzzle.ch
# Simon Josi josi+puppet(at)puzzle.ch
# See LICENSE for the full license granted to you.
class php(
class php (
$settings = {},
$timezone = $php::params::timezone,
$security_settings = $php::params::security_settings,
......@@ -13,5 +13,5 @@ class php(
$suhosin_default_settings = $php::params::suhosin_default_settings,
$suhosin_cryptkey = $php::params::suhosin_cryptkey,
) inherits php::params {
include ::php::base
include php::base
}
......@@ -3,28 +3,19 @@
# This is here for legacy reasons and our
# main way of installing extensions should be
# through packages.
define php::install(
define php::install (
$ensure = 'installed',
$mode = 'pecl',
$state = 'stable',
$target_mode = 'absent'
){
require ::php::pear::common::cli
case $facts['os']['family'] {
'RedHat': {
# this is here as a blocker to enforce common best practices
if versioncmp($::operatingsystemmajrelease,'6') > 0 {
fail("The direct install method for php package ${name} is not anymore supported on versions higher than EL6! Use packages instead!")
}
require ::php::devel
}
}
) {
require php::pear::common::cli
case $ensure {
'installed','present': {
$ensure_str = 'install -a'
case $state {
beta: { $post_cli_str = "-beta" }
'beta': { $post_cli_str = '-beta' }
}
}
'absent': { $ensure_str = 'uninstall' }
......@@ -48,18 +39,18 @@ define php::install(
default: { fail("no such method: ${method} for php::install") }
}
exec{"php_${mode}_${name}":
exec { "php_${mode}_${name}":
command => "${cli_str}${post_cli_str}",
notify => Service['apache'],
}
case $ensure {
'installed','present': {
Exec["php_${mode}_${name}"]{
Exec["php_${mode}_${name}"] {
unless => "${real_target_mode} list | egrep -qi \"^${name} \""
}
}
'absent': {
Exec["php_${mode}_${name}"]{
Exec["php_${mode}_${name}"] {
onlyif => "${real_target_mode} list | egrep -qi \"^${name} \""
}
}
......@@ -67,13 +58,13 @@ define php::install(
}
case $facts['os']['family'] {
'RedHat': {
Exec["php_${mode}_${name}"]{
require => [ Package['php'], Package['php-common'] ],
Exec["php_${mode}_${name}"] {
require => [Package['php'], Package['php-common']],
}
}
default: {
Exec["php_${mode}_${name}"]{
require => [ Package['php'], Package['php-common'] ],
Exec["php_${mode}_${name}"] {
require => [Package['php'], Package['php-common']],
}
}
}
......
# things we need for mod_fcgid & php
class php::mod_fcgid inherits php {
require ::php::cli
include ::php::disable_mod_php
require php::cli
include php::disable_mod_php
}
# a wrapper to make installing
# php packages more convenient
define php::package(
$phpversion = '',
define php::package (
$phpversion = undef,
$ensure = 'installed',
$mode = 'pear',
){
package{"php${phpversion}-${name}":
) {
package { "php${phpversion}-${name}":
ensure => $ensure,
require => Package['php'],
}
if $facts['os']['family'] == 'RedHat' {
if $mode == 'direct' {
Package["php${phpversion}-${name}"]{
Package["php${phpversion}-${name}"] {
name => "php${phpversion}-${name}",
}
} else {
Package["php${phpversion}-${name}"]{
Package["php${phpversion}-${name}"] {
name => "php${phpversion}-${mode}-${name}",
}
}
......
# some default params for php
class php::params(
class php::params (
$global_settings = {
'PHP' => {
upload_max_filesize => '20M',
......
# manage pear installations
define php::pear (
$phpversion = '',
$phpversion = undef,
$ensure = 'installed',
$mode = 'package',
$state = 'stable',
......@@ -9,14 +9,14 @@ define php::pear (
require php::pear::common
case $mode {
'package': {
php::package{$name:
phpversion => $phpversion,
ensure => $ensure,
mode => 'pear',
php::package { $name:
ensure => $ensure,
phpversion => $phpversion,
mode => 'pear',
}
}
'cli': {
php::install{$name:
php::install { $name:
ensure => $ensure,
mode => 'pear',
state => $state,
......
# manage pecl installations
define php::pecl(
$phpversion = '',
define php::pecl (
$phpversion = undef,
$ensure = 'installed',
$mode = 'package',
$state = 'stable',
$target_mode = 'absent',
$package_name = $name
) {
require ::php::pear::common
require ::php::pecl::common
require php::pear::common
require php::pecl::common
case $mode {
'package': {
php::package{$package_name:
phpversion => $phpversion,
php::package { $package_name:
ensure => $ensure,
phpversion => $phpversion,
mode => 'pecl',
}
}
'cli': {
php::install{$name:
php::install { $name:
ensure => $ensure,
mode => 'pecl',
state => $state,
target_mode => $target_mode,
}
file{"/etc/php.d/${name}.ini":
file { "/etc/php.d/${name}.ini":
content => "; File manged by puppet!\nextension=${name}.so",
notify => Service['apache'],
owner => root,
......
# manage a snuffleupagus
define php::snuffleupagus(
define php::snuffleupagus (
String $group,
Stdlib::Compat::Absolute_Path $etcdir,
Hash[
......@@ -9,7 +9,7 @@ define php::snuffleupagus(
) {
include php::snuffleupagus::global
$target_rules = $php::snuffleupagus::global::rules + $rules
file{
file {
"${etcdir}/snuffleupagus.d/${name}.rules":
content => template('php/snuffleupagus.erb'),
owner => root,
......
# manage suhosin package
class php::suhosin(
class php::suhosin (
) {
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment