Permalink
Browse files

Fix up the CS issues in php.pp

  • Loading branch information...
BronsonQuick committed Jul 14, 2017
1 parent fa0af61 commit 747eb83e619b9fe3f3244f8dd328935a4f0cb689
Showing with 56 additions and 47 deletions.
  1. +1 −1 .travis.yml
  2. +55 −46 puppet/modules/chassis/manifests/php.pp
View
@@ -4,7 +4,7 @@ install:
- gem install puppet-lint
script:
- puppet-lint --fail-on-warnings --no-2sp_soft_tabs-check --no-hard_tabs-check --no-names_containing_dash-check puppet/modules/chassis puppet/modules/wp
- puppet-lint --fail-on-warnings --no-2sp_soft_tabs-check --no-hard_tabs-check --no-names_containing_dash-check --no-autoloader_layout-check --no-nested_classes_or_defines-check puppet/modules/chassis puppet/modules/wp
notifications:
slack:
@@ -1,6 +1,7 @@
# Setup up everything that relates to PHP
class chassis::php (
$extensions = [],
$version = "5.6",
$version = '5.6',
) {
# Ensure add-apt-repository is actually available.
if !defined(Package[$::apt::ppa_package]) {
@@ -9,7 +10,7 @@
}
}
apt::ppa { "ppa:ondrej/php":
apt::ppa { 'ppa:ondrej/php':
require => [ Package[ $::apt::ppa_package ] ],
}
@@ -22,7 +23,7 @@
$short_ver = regsubst($version, '^(\d+\.\d+)\.\d+$', '\1')
}
if versioncmp( "${version}", '5.4') <= 0 {
if versioncmp( $version, '5.4') <= 0 {
$php_package = 'php5'
$php_dir = 'php5'
}
@@ -31,7 +32,7 @@
$php_dir = "php/${short_ver}"
}
if versioncmp( "${version}", '5.5') < 0 {
if versioncmp( $version, '5.5') < 0 {
file { "/etc/init/${php_package}-fpm.conf":
ensure => absent
}
@@ -46,54 +47,61 @@
####
exec { "rm init.d/${php_package}-fpm":
command => "/bin/rm /etc/init.d/${php_package}-fpm",
onlyif => "/bin/grep -q 'converted to Upstart' /etc/init.d/${php_package}-fpm",
before => [
onlyif => "/bin/grep -q 'converted to Upstart' /etc/init.d/${php_package}-fpm",
before => [
Package["${php_package}-fpm"],
Service["${php_package}-fpm"]
]
}
file { "/etc/init.d/${php_package}-fpm":
# Set up the 5.3 init script, but only if one doesn't exist already
replace => "no",
source => "puppet:///modules/chassis/php-5.3.init",
replace => 'no',
source => 'puppet:///modules/chassis/php-5.3.init',
require => Exec["rm init.d/${php_package}-fpm"],
before => [
before => [
Package["${php_package}-fpm"],
Service["${php_package}-fpm"],
]
}
}
# Add mbstring to all versions of php
if versioncmp( "${version}", '5.5') < 0 {
if versioncmp( $version, '5.5') < 0 {
$packages = [ "${php_package}-fpm", "${php_package}-cli", "${php_package}-common", 'php-xml', 'php-mbstring' ]
} else {
$packages = [ "${php_package}-fpm", "${php_package}-cli", "${php_package}-common", "${php_package}-xml", "${php_package}-mbstring", "${php_package}-zip" ]
$packages = [
"${php_package}-fpm",
"${php_package}-cli",
"${php_package}-common",
"${php_package}-xml",
"${php_package}-mbstring",
"${php_package}-zip"
]
}
$prefixed_extensions = prefix($extensions, "${php_package}-")
# Hold the packages at the necessary version
apt::pin { $packages:
packages => $packages,
version => $package_version,
version => $package_version,
priority => 1001,
}
apt::pin { $prefixed_extensions:
packages => $prefixed_extensions,
version => $package_version,
version => $package_version,
priority => 1001,
}
# Grab the packages at the given versions
package { $packages:
# Hold at the given version
ensure => 'latest',
install_options => "--force-yes",
ensure => 'latest',
install_options => '--force-yes',
notify => Service["${php_package}-fpm"],
require => [
notify => Service["${php_package}-fpm"],
require => [
Apt::Pin[$packages],
Apt::Ppa["ppa:ondrej/php"],
Apt::Ppa['ppa:ondrej/php'],
],
}
@@ -107,63 +115,64 @@
Package["${php_package}-common"] -> Package["${php_package}-cli"]
service { "${php_package}-fpm":
ensure => running,
ensure => running,
require => Package["${php_package}-fpm"]
}
# Add a type we can use to remove old php versions.
define remove_php_fpm {
case $name {
"5.5",
"5.6",
"7.0",
"7.1": {
'5.5',
'5.6',
'7.0',
'7.1': {
package { [ "php${name}-fpm", "php${name}-cli", "php${name}-common" ]:
ensure => absent,
}
}
# "5.3",
# "5.4",
default: {
package { [ "php5-fpm", "php5-cli", "php5-common" ]:
package { [ 'php5-fpm', 'php5-cli', 'php5-common' ]:
ensure => absent,
}
}
}
}
case $short_ver {
"5.3": {
remove_php_fpm { [ "5.5", "5.6", "7.0", "7.1" ]:
'5.3': {
remove_php_fpm { [ '5.5', '5.6', '7.0', '7.1' ]:
notify => Service["${php_package}-fpm"],
}
}
"5.4": {
remove_php_fpm { [ "5.5", "5.6", "7.0", "7.1" ]:
'5.4': {
remove_php_fpm { [ '5.5', '5.6', '7.0', '7.1' ]:
notify => Service["${php_package}-fpm"],
}
}
"5.5": {
remove_php_fpm { [ "old", "5.6", "7.0", "7.1" ]:
'5.5': {
remove_php_fpm { [ 'old', '5.6', '7.0', '7.1' ]:
notify => Service["${php_package}-fpm"],
}
}
"5.6": {
remove_php_fpm { [ "old", "5.5", "7.0", "7.1" ]:
'5.6': {
remove_php_fpm { [ 'old', '5.5', '7.0', '7.1' ]:
notify => Service["${php_package}-fpm"],
}
}
"7.0": {
remove_php_fpm { [ "old", "5.5", "5.6", "7.1" ]:
'7.0': {
remove_php_fpm { [ 'old', '5.5', '5.6', '7.1' ]:
notify => Service["${php_package}-fpm"],
}
}
"7.1": {
remove_php_fpm { [ "old", "5.5", "5.6", "7.0" ]:
'7.1': {
remove_php_fpm { [ 'old', '5.5', '5.6', '7.0' ]:
notify => Service["${php_package}-fpm"],
}
}
default: {
remove_php_fpm { [ "old", "5.5", "5.6" ]:
remove_php_fpm { [ 'old', '5.5', '5.6' ]:
notify => Service["${php_package}-fpm"],
}
}
@@ -172,42 +181,42 @@
# Install the extensions we need
package { $prefixed_extensions:
# Hold at the given version
ensure => 'latest',
install_options => "--force-yes",
ensure => 'latest',
install_options => '--force-yes',
require => [
require => [
Package[ $packages ],
Apt::Pin[ $prefixed_extensions ]
]
}
file { "/etc/${php_dir}/fpm/php.ini":
ensure => 'present',
content => template('chassis/php.ini.erb'),
owner => 'root',
group => 'root',
mode => 0644,
mode => '0644',
require => Package["${php_package}-fpm"],
ensure => 'present',
notify => Service["${php_package}-fpm"]
}
file { "/etc/${php_dir}/cli/php.ini":
ensure => 'present',
content => template('chassis/php.ini.erb'),
owner => 'root',
group => 'root',
mode => 0644,
mode => '0644',
require => Package["${php_package}-fpm"],
ensure => 'present',
notify => Service["${php_package}-fpm"]
}
file { "/etc/${php_dir}/fpm/pool.d/www.conf":
ensure => 'present',
content => template('chassis/php-pool.conf.erb'),
owner => 'root',
group => 'root',
mode => 0644,
mode => '0644',
require => Package["${php_package}-fpm"],
ensure => 'present',
notify => Service["${php_package}-fpm"]
}
}

0 comments on commit 747eb83

Please sign in to comment.