Skip to content

Commit ef1afcb

Browse files
Debian 11: fix typo in versioncmp() / set default php to 7.4
tl;dr `$::operatingsystemrelease` is different from `$::operatingsystemmajrelease`. `$::operatingsystemmajrelease` returns '11.0' on Debian 11, whereas `$::operatingsystemmajrelease` is `11`. In addition `versioncmp()` says that `'11.0'` is greater than `11`. Without this change, the module sets the default PHP version on Debian 11 to 7.2, but the actual default in Debian is 7.4: * https://packages.debian.org/bullseye/php The 7.2 currently comes from the default entry in the selector statement: * https://github.com/puppetlabs/puppetlabs-apache/blob/main/manifests/params.pp#L401 To test: ```puppet notify { "operatingsystemrelease compared to 11: ${versioncmp($::operatingsystemrelease, '11')}":} notify { "operatingsystemmajrelease compared to 11: ${versioncmp($::operatingsystemmajrelease, '11')}":} notify { "operatingsystemrelease: ${::operatingsystemrelease}":} notify { "operatingsystemmajrelease: ${::operatingsystemmajrelease}":} ``` which produces: ```terminal puppet apply test.pp Notice: Compiled catalog for blal in environment production in 0.02 seconds Notice: operatingsystemrelease compared to 11: 1 Notice: /Stage[main]/Main/Notify[operatingsystemrelease compared to 11: 1]/message: defined 'message' as 'operatingsystemrelease compared to 11: 1' Notice: operatingsystemmajrelease compared to 11: 0 Notice: /Stage[main]/Main/Notify[operatingsystemmajrelease compared to 11: 0]/message: defined 'message' as 'operatingsystemmajrelease compared to 11: 0' Notice: operatingsystemrelease: 11.0 Notice: /Stage[main]/Main/Notify[operatingsystemrelease: 11.0]/message: defined 'message' as 'operatingsystemrelease: 11.0' Notice: operatingsystemmajrelease: 11.0 Notice: /Stage[main]/Main/Notify[operatingsystemmajrelease: 11.0]/message: defined 'message' as 'operatingsystemmajrelease: 11' Notice: Applied catalog in 0.01 seconds ``` ```terminal :~> facter operatingsystemmajrelease 11 :~> facter operatingsystemrelease 11.0 ``` The spec tests are copied from #2181 Co-authored-by: Kienan Stewart <kienan.stewart@burntworld.ca>
1 parent 3fff7d8 commit ef1afcb

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

manifests/params.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@
392392
'wsgi' => 'libapache2-mod-wsgi',
393393
'xsendfile' => 'libapache2-mod-xsendfile',
394394
}
395-
} elsif ($::operatingsystem == 'Ubuntu') or ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '11') < 0) {
395+
} elsif ($::operatingsystem == 'Ubuntu') or ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemmajrelease, '11') < 0) {
396396
$php_version = $facts['operatingsystemmajrelease'] ? {
397397
'9' => '7.0', # Debian Stretch
398398
'16.04' => '7.0', # Ubuntu Xenial

spec/classes/mod/php_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,29 @@
6868
{ php_version: '8.0' }
6969
end
7070

71+
it { is_expected.to contain_apache__mod('php') }
72+
it { is_expected.to contain_package('libapache2-mod-php8.0') }
73+
it {
74+
is_expected.to contain_file('php.load').with(
75+
content: "LoadModule php_module /usr/lib/apache2/modules/libphp.so\n",
76+
)
77+
}
78+
end
79+
when '11'
80+
context 'on bullseye' do
81+
it { is_expected.to contain_apache__mod('php7.4') }
82+
it { is_expected.to contain_package('libapache2-mod-php7.4') }
83+
it {
84+
is_expected.to contain_file('php7.4.load').with(
85+
content: "LoadModule php7_module /usr/lib/apache2/modules/libphp7.4.so\n",
86+
)
87+
}
88+
end
89+
context 'on bullseye with experimental php8.0' do
90+
let :params do
91+
{ php_version: '8.0' }
92+
end
93+
7194
it { is_expected.to contain_apache__mod('php') }
7295
it { is_expected.to contain_package('libapache2-mod-php8.0') }
7396
it {

0 commit comments

Comments
 (0)