Mercurial > repos > other > Puppet
diff modules/php/manifests/config/setting.pp @ 386:3fce34f642f1
Add a PHP module to handle platform differences
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 03 Jan 2022 17:09:39 +0000 |
parents | |
children | adf6fe9bbc17 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/modules/php/manifests/config/setting.pp Mon Jan 03 17:09:39 2022 +0000 @@ -0,0 +1,50 @@ +# Configure php.ini settings +# +# === Parameters +# +# [*key*] +# The key of the value, like `ini_setting` +# +# [*file*] +# The path to ini file +# +# [*value*] +# The value to set +# +# === Examples +# +# php::config::setting { 'Date/date.timezone': +# file => '$full_path_to_ini_file' +# value => 'Europe/Berlin' +# } +# +define php::config::setting ( + String[1] $key, + Variant[Integer, String] $value, + Stdlib::Absolutepath $file, +) { + assert_private() + + $split_name = split($key, '/') + if count($split_name) == 1 { + $section = '' # lint:ignore:empty_string_assignment + $setting = $split_name[0] + } else { + $section = $split_name[0] + $setting = $split_name[1] + } + + if $value == undef { + $ensure = 'absent' + } else { + $ensure = 'present' + } + + ini_setting { $name: + ensure => $ensure, + value => $value, + path => $file, + section => $section, + setting => $setting, + } +}