comparison modules/apache/manifests/mod/php.pp @ 257:675c1cc61eaf

Update Apache module to get CentOS 8 support Unfortunately it only fixes some bits. mod_wsgi still needs other approaches This also overrides the vhost modification to make them come last in the import order (after module loading)
author IBBoard <dev@ibboard.co.uk>
date Sun, 22 Dec 2019 14:43:29 -0500
parents 37675581a273
children d9352a684e62
comparison
equal deleted inserted replaced
252:47750947f4dc 257:675c1cc61eaf
2 $package_name = undef, 2 $package_name = undef,
3 $package_ensure = 'present', 3 $package_ensure = 'present',
4 $path = undef, 4 $path = undef,
5 $extensions = ['.php'], 5 $extensions = ['.php'],
6 $content = undef, 6 $content = undef,
7 $template = 'apache/mod/php5.conf.erb', 7 $template = 'apache/mod/php.conf.erb',
8 $source = undef, 8 $source = undef,
9 $root_group = $::apache::params::root_group, 9 $root_group = $::apache::params::root_group,
10 $php_version = $::apache::params::php_version,
10 ) inherits apache::params { 11 ) inherits apache::params {
12 include ::apache
13 $mod = "php${php_version}"
11 14
12 if defined(Class['::apache::mod::prefork']) { 15 if defined(Class['::apache::mod::prefork']) {
13 Class['::apache::mod::prefork']->File['php5.conf'] 16 Class['::apache::mod::prefork']->File["${mod}.conf"]
14 } 17 }
15 elsif defined(Class['::apache::mod::itk']) { 18 elsif defined(Class['::apache::mod::itk']) {
16 Class['::apache::mod::itk']->File['php5.conf'] 19 Class['::apache::mod::itk']->File["${mod}.conf"]
17 } 20 }
18 else { 21 else {
19 fail('apache::mod::php requires apache::mod::prefork or apache::mod::itk; please enable mpm_module => \'prefork\' or mpm_module => \'itk\' on Class[\'apache\']') 22 fail('apache::mod::php requires apache::mod::prefork or apache::mod::itk; please enable mpm_module => \'prefork\' or mpm_module => \'itk\' on Class[\'apache\']')
20 } 23 }
21 validate_array($extensions) 24 validate_array($extensions)
22 25
23 if $source and ($content or $template != 'apache/mod/php5.conf.erb') { 26 if $source and ($content or $template != 'apache/mod/php.conf.erb') {
24 warning('source and content or template parameters are provided. source parameter will be used') 27 warning('source and content or template parameters are provided. source parameter will be used')
25 } elsif $content and $template != 'apache/mod/php5.conf.erb' { 28 } elsif $content and $template != 'apache/mod/php.conf.erb' {
26 warning('content and template parameters are provided. content parameter will be used') 29 warning('content and template parameters are provided. content parameter will be used')
27 } 30 }
28 31
29 $manage_content = $source ? { 32 $manage_content = $source ? {
30 undef => $content ? { 33 undef => $content ? {
32 default => $content, 35 default => $content,
33 }, 36 },
34 default => undef, 37 default => undef,
35 } 38 }
36 39
37 ::apache::mod { 'php5': 40 # Determine if we have a package
38 package => $package_name, 41 $mod_packages = $::apache::params::mod_packages
39 package_ensure => $package_ensure, 42 if $package_name {
40 path => $path, 43 $_package_name = $package_name
44 } elsif has_key($mod_packages, $mod) { # 2.6 compatibility hack
45 $_package_name = $mod_packages[$mod]
46 } elsif has_key($mod_packages, 'phpXXX') { # 2.6 compatibility hack
47 $_package_name = regsubst($mod_packages['phpXXX'], 'XXX', $php_version)
48 } else {
49 $_package_name = undef
41 } 50 }
51
52 $_lib = "libphp${php_version}.so"
53 $_php_major = regsubst($php_version, '^(\d+)\..*$', '\1')
54
55 if $::operatingsystem == 'SLES' {
56 ::apache::mod { $mod:
57 package => $_package_name,
58 package_ensure => $package_ensure,
59 lib => 'mod_php5.so',
60 id => "php${_php_major}_module",
61 path => "${::apache::lib_path}/mod_php5.so",
62 }
63 } else {
64 ::apache::mod { $mod:
65 package => $_package_name,
66 package_ensure => $package_ensure,
67 lib => $_lib,
68 id => "php${_php_major}_module",
69 path => $path,
70 }
71
72 }
73
42 74
43 include ::apache::mod::mime 75 include ::apache::mod::mime
44 include ::apache::mod::dir 76 include ::apache::mod::dir
45 Class['::apache::mod::mime'] -> Class['::apache::mod::dir'] -> Class['::apache::mod::php'] 77 Class['::apache::mod::mime'] -> Class['::apache::mod::dir'] -> Class['::apache::mod::php']
46 78
47 # Template uses $extensions 79 # Template uses $extensions
48 file { 'php5.conf': 80 file { "${mod}.conf":
49 ensure => file, 81 ensure => file,
50 path => "${::apache::mod_dir}/php5.conf", 82 path => "${::apache::mod_dir}/${mod}.conf",
51 owner => 'root', 83 owner => 'root',
52 group => $root_group, 84 group => $root_group,
53 mode => '0644', 85 mode => $::apache::file_mode,
54 content => $manage_content, 86 content => $manage_content,
55 source => $source, 87 source => $source,
56 require => [ 88 require => [
57 Exec["mkdir ${::apache::mod_dir}"], 89 Exec["mkdir ${::apache::mod_dir}"],
58 ], 90 ],