Puppet Class: psick
- Defined in:
- manifests/init.pp
Overview
The main psick class. From here the whole infrastructure can be built. This class exposes parameters that serve as entry points to set general settings used by other psick profiles. When included, this class does nothing by default, but it’s required to be able to use PSICK for classification and/or to use any PSICK profile.
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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'manifests/init.pp', line 106
class psick (
# PSICK global vars
Boolean $manage = true,
Boolean $auto_prereq = true,
Boolean $enable_firstrun = false,
Optional[Boolean] $noop_mode = lookup('noop_mode',Optional[Boolean],'first',undef), # lint:ignore:lookup_in_parameter
Boolean $noop_manage = false,
Boolean $noop_value = false,
# General network settings
Optional[Stdlib::IP::Address] $primary_ip = fact('networking.ip'),
Optional[String] $mgmt_interface = fact('networking.primary'),
Optional[String] $timezone = undef,
Hash $interfaces_hash = {},
# General endpoints and variables
Hash $settings = {},
Hash $servers = {},
Hash $tp = {},
Hash $firewall = {},
Hash $monitor = {},
Boolean $force_ordering = true,
# General resources
# Hash $resources (lookup with $resources_merge_behaviour) = {},
# Hash $resources_defaults (lookup with $resources_defaults_merge_behaviour) = {},
Enum['first','hash','deep'] $resources_merge_behaviour = 'deep',
Enum['first','hash','deep'] $resources_defaults_merge_behaviour = 'deep',
# $::os['family'] based resources
# Hash $osfamily_resources (lookup with $osfamily_resources_merge_behaviour) = {},
# Hash $osfamily_resources_defaults (lookup with $osfamily_resources_defaults_merge_behaviour) = {},
Enum['first','hash','deep'] $osfamily_resources_merge_behaviour = 'deep',
Enum['first','hash','deep'] $osfamily_resources_defaults_merge_behaviour = 'deep',
) {
if $noop_mode != undef {
fail('psick::noop_mode parameter has been deprecated. Use $noop_manage and $noop_manage instead')
}
if $noop_manage {
noop($noop_value)
}
# Resource defaults for Tiny Puppet defines
Tp::Install {
cli_enable => $tp['cli_enable'],
test_enable => $tp['test_enable'],
puppi_enable => $tp['puppi_enable'],
debug => $tp['debug'],
data_module => $tp['data_module'],
}
Tp::Conf {
config_file_notify => $tp['config_file_notify'],
config_file_require => $tp['config_file_require'],
debug => $tp['debug'],
data_module => $tp['data_module'],
}
Tp::Dir {
config_dir_notify => $tp['config_dir_notify'],
config_dir_require => $tp['config_dir_require'],
debug => $tp['debug'],
data_module => $tp['data_module'],
}
# Building of the $::psick::interfaces variable, usable in any class included
# via or after psick.
# By default are set main and mgmt interfaces based on sane facts values and
# user params $primary_ip and $mgmt_interface
$primary_interface = $facts['networking']['primary']
$interfaces_default = {
main => {
interface => $facts['networking']['primary'],
address => pick($primary_ip, $facts['networking']['interfaces'][$primary_interface]['ip']),
netmask => $facts['networking']['interfaces'][$primary_interface]['netmask'],
network => $facts['networking']['interfaces'][$primary_interface]['network'],
hostname => $facts['networking']['fqdn'],
},
mgmt => {
interface => $mgmt_interface,
address => $facts['networking']['interfaces'][$mgmt_interface]['ip'],
netmask => $facts['networking']['interfaces'][$mgmt_interface]['netmask'],
network => $facts['networking']['interfaces'][$mgmt_interface]['network'],
hostname => $facts['networking']['fqdn'],
},
}
$interfaces = deep_merge($interfaces_default, $interfaces_hash)
# PSICK PRE, BASE CLASSES AND PROFILES + OPTIONAL FIRSTRUN MODE
# The classes included here manage PSICK classification and
# relevant class ordering
if $facts['firstrun'] == 'done' or $enable_firstrun == false {
contain psick::pre
contain psick::base
contain psick::profiles
if $force_ordering {
Class['psick::pre'] -> Class['psick::base'] -> Class['psick::profiles']
}
} else {
contain psick::firstrun
notify { "This catalog should be applied only at the first Puppen run\n": }
}
# Custom Resources management
$resources = lookup('psick::resources',Hash,$resources_merge_behaviour, {})
$resources_defaults = lookup('psick::resources_defaults',Hash,$resources_defaults_merge_behaviour, {})
$resources.each |$k,$v| {
if $k in keys($resources_defaults) {
$resource_defaults = $resources_defaults[$k]
} else {
$resource_defaults = {}
}
create_resources( $k, $v, $resource_defaults )
}
# Custom Resources management
$osfamily_resources = lookup('psick::osfamily_resources',Hash,$osfamily_resources_merge_behaviour, {})
$osfamily_resources_defaults = lookup('psick::osfamily_resources_defaults',Hash,$osfamily_resources_defaults_merge_behaviour, {})
$osfamily_resources.each |$k,$v| {
if $facts['os']['family'] == $k {
if $k in $osfamily_resources_defaults {
$os_defaults = $osfamily_resources_defaults[$k]
} else {
$os_defaults = {}
}
create_resources( $k, $v, $os_defaults )
}
}
}
|