view modules/php/manifests/config/setting.pp @ 482:d83de9b3a62b default tip

Update hiera.yaml within Puppet config Forgot that we manage it from here. Now has content to match new packages
author IBBoard <dev@ibboard.co.uk>
date Fri, 30 Aug 2024 16:10:36 +0100
parents adf6fe9bbc17
children
line wrap: on
line source

# 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,
  Stdlib::Absolutepath $file,
  Optional[Variant[Integer, String]] $value = undef,
) {
  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,
  }
}