Commit 8faf2e92 authored by Markus Frosch's avatar Markus Frosch 📣
Browse files

Add php profile

with timezone support
parent e06685ee
class icinga2_testing::profiles::apache
{
class icinga2_testing::profiles::apache (
$php = true,
) {
include ::apache::params
$conf_dir = hiera('apache::conf_dir', $::apache::params::conf_dir)
$default_ssl_vhost = hiera('apache::default_ssl_vhost', false)
......@@ -28,7 +29,10 @@ class icinga2_testing::profiles::apache
contain ::apache
contain ::apache::mod::rewrite
contain ::apache::mod::php
if $php {
contain ::icinga2_testing::profiles::php
}
if $default_ssl_key and $default_ssl_cert {
Package['httpd'] ->
......
class icinga2_testing::profiles::php (
$timezone = undef,
$conf_d = undef,
) {
include ::icinga2_testing::profiles::apache
contain ::apache::mod::php
$_timezone = pick(
$timezone,
hiera('timezone::timezone', undef), # from saz-timezone
$::timezone,
'UTC'
)
if $conf_d {
validate_absolute_path($conf_d)
$_conf_d = $conf_d
} else {
if $::operatingsystem == 'Debian' {
if versioncmp($::operatingsystemmajrelease, '16.04') >= 0 {
$_conf_d = '/etc/php7/apache2/conf.d'
} else {
$_conf_d = '/etc/php5/apache2/conf.d'
}
} elsif $::operatingsystem == 'Ubuntu' {
if versioncmp($::operatingsystemmajrelease, '9') >= 0 {
$_conf_d = '/etc/php7/apache2/conf.d'
} else {
$_conf_d = '/etc/php5/apache2/conf.d'
}
} elsif $::osfamily == 'RedHat' {
$_conf_d = '/etc/php.d'
} else {
fail("osfamily ")
}
}
# set PHP timezone
file { 'php timezone':
ensure => file,
path => "${_conf_d}/timezone.ini",
content => "; generated by Puppet\ndate.timezone=${_timezone}\n",
require => Class['apache::mod::php'],
notify => Class['apache::service'],
}
}
require 'spec_helper'
describe 'icinga2_testing::profiles::php' do
on_supported_os.each do |os, facts|
context "on #{os}" do
let :facts do
facts
end
let :php_confd do
if facts[:osfamily] == 'Debian'
%r{^/etc/php\d/apache2/conf.d/timezone.ini$}
elsif facts[:osfamily] == 'RedHat'
'/etc/php.d/timezone.ini'
else
'unknown'
end
end
context 'with default parameters' do
it { should compile.with_all_deps }
it { should contain_class('icinga2_testing::profiles::php') }
it { should contain_class('icinga2_testing::profiles::apache') }
it do
should contain_file('php timezone')
.with_path(php_confd)
.with_content(/date\.timezone=#{facts[:timezone]}/)
end
end
context 'with changed parameters' do
let :params do
{
timezone: 'Europe/Berlin',
conf_d: '/etc/php8/nginx/conf.d'
}
end
it { should compile.with_all_deps }
it { should contain_class('icinga2_testing::profiles::php') }
it do
should contain_file('php timezone')
.with_path('/etc/php8/nginx/conf.d/timezone.ini')
.with_content(%r{date\.timezone=Europe/Berlin})
end
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment