Puppet Class: psick::php::tp
- Defined in:
- manifests/php/tp.pp
Summary
This class manages php with Tiny Puppet (tp)Overview
psick::php::tp
When you include this class the relevant tp::install define is declared which is expected to install php package and manage its service. Via the resources_hash parameter is possible to pass hashes of tp::conf and tp::dir defines which can manage php configuration files and whole dirs. All the parameters ending with the _hash suffix expect and Hash and are looked up on Hiera via the deep merge lookup option.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'manifests/php/tp.pp', line 93
class psick::php::tp (
Psick::Ensure $ensure = 'present',
Boolean $manage = true,
Optional[Boolean] $upstream_repo = undef,
Hash $install_hash = {},
Hash $settings_hash = {},
# This param is looked up in code according to $resources_lookup_method
# Hash $resources = {},
Hash $resources_defaults = {},
Enum['first','deep','hash'] $resources_lookup_method = 'deep',
# This param is looked up in code according to $options_lookup_method
# Hash $options = {},
Enum['first','deep','hash'] $options_lookup_method = 'deep',
Boolean $auto_conf = false,
Hash $resources_auto_conf_hash = {},
Hash $options_auto_conf_hash = {},
Boolean $auto_prereq = true,
Boolean $noop_manage = false,
Boolean $noop_value = false,
) {
$options=lookup('psick::php::tp::options', Hash, $options_lookup_method, {})
if $manage {
if $noop_manage {
noop($noop_value)
}
$options_all = $auto_conf ? {
true => $options_auto_conf_hash + $options,
false => $options,
}
$install_defaults = {
ensure => $ensure,
options_hash => $options_all,
settings_hash => $settings_hash,
auto_repo => $auto_prereq,
auto_prereq => $auto_prereq,
upstream_repo => $upstream_repo,
}
tp::install { 'php':
* => $install_defaults + $install_hash,
}
$file_ensure = $ensure ? {
'absent' => 'absent',
default => 'present',
}
$dir_ensure = $ensure ? {
'absent' => 'absent',
default => 'directory',
}
# Declaration of psick::php::tp::resources
$resources=lookup('psick::php::tp::resources', Hash, $resources_lookup_method, {})
$resources.each |String $resource_type, Hash $content| {
$resources_all = $auto_conf ? {
true => pick($resources_auto_conf_hash[$resource_type], {}) + pick($resources[$resource_type], {}),
false => pick($resources[$resource_type], {}),
}
$resources_all.each |String $resource_name, Hash $resource_params| {
$resources_params_default = $resource_type ? {
'tp::conf' => {
ensure => $file_ensure,
options_hash => $options_all,
settings_hash => $settings_hash,
},
'tp::dir' => {
ensure => $dir_ensure,
settings_hash => $settings_hash,
},
'exec' => {
path => $facts['path'],
},
'file' => {
ensure => $file_ensure,
},
'package' => {
ensure => $file_ensure,
},
default => {},
}
$resource_params_all = deep_merge($resources_defaults[$resource_type], $resources_params_default, $resource_params)
ensure_resource($resource_type,$resource_name,$resource_params_all)
}
}
}
}
|