changeset 399:2c6065b5be5e

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.
author IBBoard <dev@ibboard.co.uk>
date Wed, 20 Apr 2022 19:08:14 +0100
parents 66c406eec60d
children f354100b688a
files manifests/templates.pp modules/website/manifests/php.pp modules/website/manifests/php/extra.pp
diffstat 3 files changed, 19 insertions(+), 96 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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',
-  }
 }
-}
--- 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',
-  }
-}