Puppet Class: psick::network
- Defined in:
- manifests/network.pp
Summary
This psick profile manages network settings, such as interfaces andOverview
psick::network
routes.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 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 |
# File 'manifests/network.pp', line 38
class psick::network (
Psick::Ensure $ensure = 'present',
Boolean $manage = $psick::manage,
Boolean $auto_prereq = $psick::auto_prereq,
Hash $options_hash = {},
String $module = 'psick',
Boolean $noop_manage = $psick::noop_manage,
Boolean $noop_value = $psick::noop_value,
Optional[String] $hostname = undef,
Optional[String] $host_conf_template = undef,
Hash $host_conf_options = {},
Optional[String] $nsswitch_conf_template = undef,
Hash $nsswitch_conf_options = {},
Boolean $use_netplan = false,
# This "param" is looked up in code according to interfaces_merge_behaviour
# Optional[Hash] $interfaces = undef,
Enum['first','hash','deep'] $interfaces_merge_behaviour = 'first',
Hash $interfaces_defaults = {},
# This "param" is looked up in code according to routes_merge_behaviour
# Optional[Hash] $routes = undef,
Enum['first','hash','deep'] $routes_merge_behaviour = 'first',
Hash $routes_defaults = {},
# This "param" is looked up in code according to rules_merge_behaviour
# Optional[Hash] $rules = undef,
Enum['first','hash','deep'] $rules_merge_behaviour = 'first',
Hash $rules_defaults = {},
# This "param" is looked up in code according to tables_merge_behaviour
# Optional[Hash] $tables = undef,
Enum['first','hash','deep'] $tables_merge_behaviour = 'first',
Hash $tables_defaults = {},
String $service_restart_exec = 'service network restart',
Variant[Resource,String[0,0],Undef,Boolean] $config_file_notify = true,
Variant[Resource,String[0,0],Undef,Boolean] $config_file_require = undef,
Boolean $config_file_per_interface = true,
) {
# We declare resources only if $manage = true
if $manage {
if $noop_manage {
noop($noop_value)
}
$manage_config_file_notify = $config_file_notify ? {
true => "Exec[${service_restart_exec}]",
false => undef,
'' => undef,
undef => undef,
default => $config_file_notify,
}
$manage_config_file_require = $config_file_require ? {
true => undef,
false => undef,
'' => undef,
undef => undef,
default => $config_file_require,
}
# Exec to restart interfaces
exec { $service_restart_exec :
command => $service_restart_exec,
alias => 'network_restart',
refreshonly => true,
path => $facts['path'],
}
if $hostname {
contain psick::network::hostname
}
# Manage /etc/host.conf if $host_conf_template is set
if $host_conf_template {
$host_conf_template_type=$host_conf_template[-4,4]
$host_conf_content = $host_conf_template_type ? {
'.epp' => epp($host_conf_template, { options => $host_conf_options }),
'.erb' => template($host_conf_template),
default => template($host_conf_template),
}
file { '/etc/host.conf':
ensure => file,
content => $host_conf_content,
notify => $manage_config_file_notify,
}
}
# Manage /etc/nsswitch.conf if $nsswitch_conf_template is set
if $nsswitch_conf_template {
$nsswitch_conf_template_type=$nsswitch_conf_template[-4,4]
$nsswitch_conf_content = $nsswitch_conf_template_type ? {
'.epp' => epp($nsswitch_conf_template, { options => $nsswitch_conf_options }),
'.erb' => template($nsswitch_conf_template),
default => template($nsswitch_conf_template),
}
file { '/etc/nsswitch.conf':
ensure => file,
content => $nsswitch_conf_content,
notify => $manage_config_file_notify,
}
}
# Declare network interfaces based on network::interfaces
$interfaces = lookup('psick::network::interfaces',Hash,$interfaces_merge_behaviour, {})
$interfaces.each |$k,$v| {
psick::network::interface { $k:
* => $interfaces_defaults + $v,
}
}
# Declare network routes based on network::routes
$routes = lookup('psick::network::routes',Hash,$routes_merge_behaviour, {})
$routes.each |$k,$v| {
psick::network::route { $k:
* => $routes_defaults + $v,
}
}
# Declare network rules based on network::rules
$rules = lookup('psick::network::rules',Hash,$rules_merge_behaviour, {})
$rules.each |$k,$v| {
psick::network::rule { $k:
* => $rules_defaults + $v,
}
}
# Declare network tables based on network::tables
$tables = lookup('psick::network::tables',Hash,$tables_merge_behaviour, {})
$tables.each |$k,$v| {
psick::network::table { $k:
* => $tables_defaults + $v,
}
}
}
}
|