# HG changeset patch # User IBBoard # Date 1650478094 -3600 # Node ID 2c6065b5be5e88f12db0743d16a69d1e57d435c7 # Parent 66c406eec60d2b91a805d50639b78094d254d88d Switch to config-based PHP extensions This makes it compatible with Ubuntu, otherwise it keeps trying to re-install the same module because the "phpX.X" package is a virtual package and the Puppet handling of Ubuntu's "is it installed" system is incapable of saying "yes" when a virtual package is installed. diff -r 66c406eec60d -r 2c6065b5be5e manifests/templates.pp --- a/manifests/templates.pp Wed Apr 20 19:04:13 2022 +0100 +++ b/manifests/templates.pp Wed Apr 20 19:08:14 2022 +0100 @@ -417,8 +417,9 @@ if $operatingsystem == 'CentOS' { $php_suffix = '' + $variant_prefix = '' $extra_prefix = 'pecl-' - $extra_extra = [ 'process' ] + $extra_extra = { 'process' => {} } if versioncmp($operatingsystemrelease, '8') >= 0 { yumrepo { 'remirepo-safe': mirrorlist => 'http://cdn.remirepo.net/enterprise/$releasever/safe/$basearch/mirror', @@ -467,15 +468,29 @@ } elsif $operatingsystem == 'Ubuntu' { $php_suffix = '' + $variant_prefix = 'php-' $extra_prefix = '' - $extra_extras = [] + $extra_extras = {} } #Configure the PHP version to use class { 'website::php': suffix => $php_suffix, module => ($operatingsystem == 'CentOS' and versioncmp($operatingsystemrelease, '8') >= 0) ? { true => 'remi-7.4', default => undef }, - extras => [ 'intl', "${extra_prefix}imagick", 'bcmath', "${extra_prefix}zip", 'json', "${extra_prefix}apcu", 'gmp', 'enchant' ] + $extra_extras, + extras => { + 'intl' => {}, + "${extra_prefix}imagick" => { + package_prefix => $variant_prefix + }, + 'bcmath' => {}, + "${extra_prefix}zip" => {}, + 'json' => {}, + "${extra_prefix}apcu" => { + package_prefix => $variant_prefix + }, + 'gmp' => {}, + 'enchant' => {} + } + $extra_extras, } #Setup MySQL, using (private) templates to make sure that we set non-std passwords and a default user diff -r 66c406eec60d -r 2c6065b5be5e modules/website/manifests/php.pp --- a/modules/website/manifests/php.pp Wed Apr 20 19:04:13 2022 +0100 +++ b/modules/website/manifests/php.pp Wed Apr 20 19:08:14 2022 +0100 @@ -60,97 +60,11 @@ } }, xml => {}, - }, + } + $extras, } apache::custom_config { "php.conf": ensure => present, source => "puppet:///modules/website/php.conf" } class { ['apache::mod::proxy', 'apache::mod::proxy_fcgi']:} - - $extras.each |String $extra| { - ::php::extension { $extra: - ensure => present - } - } - -if false { - Package <| tag == 'php-package' |> -> File <| tag == 'php-file' |> ~> Service['php-fpm'] ~> Service['httpd'] - - $php_core = ($module != undef) ? { true => "php", default => "php${suffix}" } - - package { $php_core: - provider => ($module != undef) ? { true => 'dnfmodule', default => undef }, - ensure => ($module != undef) ? { true => $module, default => installed }, - tag => 'php-package', - } - - if $osfamily == 'RedHat' { - $php_conf_dir = '/etc/php.d/' - $php_fpm_conf_dir = '/etc/php-fpm.d/' - $mod_fcgid_package = 'mod_fcgid' - } - elsif $osfamily == 'Debian' { - # FIXME: This hard-codes the version number, which isn't great - $php_conf_dir = '/etc/php/7.4/fpm/conf.d/' - $php_fpm_conf_dir = $php_conf_dir - $mod_fcgid_package = 'libapache2-mod-fcgid' - } - - package { $mod_fcgid_package: - ensure => installed, - } - class { ['apache::mod::proxy', 'apache::mod::proxy_fcgi']:} - - $packages = [ "php${suffix}-mbstring", "php${suffix}-xml", "php${suffix}-gd", "php${suffix}-fpm" ] - package { $packages: - ensure => installed, - tag => 'php-package', - } - - service { 'php-fpm': - ensure => 'running', - enable => true, - } - - website::php::extra { $extras: } - - file { '/etc/php.d/datetime.ini': - ensure => present, - source => "puppet:///modules/website/datetime.ini", - require => Class['apache'], - notify => Service['httpd']; - } - file { '/etc/php-fpm.d/www.conf': - ensure => present, - source => 'puppet:///modules/website/php-fpm-www.conf', - tag => 'php-file', - } - file { '/etc/php.d/custom-lockdown.ini': - ensure => present, - content => 'allow_url_fopen = \'off\' - expose_php = Off', - tag => 'php-file', - } - file { '/etc/php.d/custom-php.ini': - ensure => present, - source => 'puppet:///modules/website/custom-php.ini', - tag => 'php-file', - } - - package { "php${suffix}-opcache": - ensure => installed, - require => Package[$php_core], - tag => 'php-package', - } - # Use Remi's (and the OS's) naming convention - file { '/etc/php.d/opcache.ini': - ensure => absent, - } - file { '/etc/php.d/10-opcache.ini': - ensure => present, - source => "puppet:///modules/website/opcache.ini", - tag => 'php-file', - } } -} diff -r 66c406eec60d -r 2c6065b5be5e modules/website/manifests/php/extra.pp --- a/modules/website/manifests/php/extra.pp Wed Apr 20 19:04:13 2022 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -define website::php::extra ($pkg = $title) { - package { "php${website::php::suffix}-${pkg}": - ensure => installed, - tag => 'php-package', - } -}