Puppet Class: nomad
- Defined in:
- manifests/init.pp
Overview
Installs, configures, and manages nomad
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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'manifests/init.pp', line 150
class nomad (
String[1] $arch,
Boolean $purge_config_dir = true,
Stdlib::Filemode $data_dir_mode = '0755',
Stdlib::Filemode $plugin_dir_mode = '0755',
Optional[String[1]] $join_wan = undef,
Stdlib::Absolutepath $bin_dir = '/usr/bin',
String[1] $version = 'installed',
Enum['none', 'package', 'url'] $install_method = 'package',
String[1] $os = downcase($facts['kernel']),
Optional[String[1]] $download_url = undef,
String[1] $download_url_base = 'https://releases.hashicorp.com/nomad/',
String[1] $download_extension = 'zip',
String[1] $package_name = 'nomad',
Stdlib::Absolutepath $config_dir = '/etc/nomad.d',
Optional[String[1]] $extra_options = undef,
Hash $config_hash = {},
Hash $config_defaults = {},
Stdlib::Filemode $config_mode = '0660',
Boolean $pretty_config = false,
Boolean $service_enable = true,
Stdlib::Ensure::Service $service_ensure = 'running',
Boolean $manage_repo = true,
Boolean $manage_service = true,
Boolean $manage_service_file = false,
Boolean $restart_on_change = true,
Hash[String[1], String] $env_vars = {},
String[1] $user = 'root',
String[1] $group = 'root',
Boolean $server_recovery = false,
Optional[String] $recovery_nomad_server_regex = undef,
Optional[Hash] $recovery_nomad_server_hash = undef,
Optional[String] $recovery_network_interface = undef,
Stdlib::Port $recovery_rpc_port = 4647,
Variant[
Enum['nomad_validator', 'ruby_validator'], Pattern[/\A.*\ %\z/]
] $config_validator = 'nomad_validator',
) {
$real_download_url = pick($download_url, "${download_url_base}${version}/${package_name}_${version}_${os}_${arch}.${download_extension}")
$config_hash_real = deep_merge($config_defaults, $config_hash)
if $config_hash_real['data_dir'] {
$data_dir = $config_hash_real['data_dir']
} else {
$data_dir = undef
}
if $config_hash_real['plugin_dir'] {
$plugin_dir = $config_hash_real['plugin_dir']
} else {
$plugin_dir = undef
}
if ($config_hash_real['ports'] and $config_hash_real['ports']['rpc']) {
$rpc_port = $config_hash_real['ports']['rpc']
} else {
$rpc_port = 8400
}
if ($config_hash_real['addresses'] and $config_hash_real['addresses']['rpc']) {
$rpc_addr = $config_hash_real['addresses']['rpc']
} elsif ($config_hash_real['client_addr']) {
$rpc_addr = $config_hash_real['client_addr']
} else {
$rpc_addr = $facts['networking']['interfaces']['lo']['ip']
}
$notify_service = $restart_on_change ? {
true => Class['nomad::run_service'],
default => undef,
}
class { 'nomad::install': }
-> class { 'nomad::config':
notify => $notify_service,
}
-> class { 'nomad::run_service': }
-> class { 'nomad::reload_service': }
contain nomad::install
contain nomad::config
contain nomad::run_service
contain nomad::reload_service
if ($server_recovery) {
if ($recovery_nomad_server_regex) and ($recovery_nomad_server_hash) {
fail('You can only use one of the parameters: recovery_nomad_server_regex or recovery_nomad_server_hash')
}
elsif !($recovery_nomad_server_regex) and !($recovery_nomad_server_hash) {
fail('You must use one of the parameters: recovery_nomad_server_regex or recovery_nomad_server_hash')
}
if !($recovery_network_interface) and ($recovery_nomad_server_regex) {
fail('You must specify the network_interface parameter when using recovery_nomad_server_regex')
}
class { 'nomad::server_recovery':
nomad_server_regex => $recovery_nomad_server_regex,
nomad_server_hash => $recovery_nomad_server_hash,
rpc_port => $recovery_rpc_port,
network_interface => $recovery_network_interface,
}
} else {
file { '/usr/local/bin/nomad-server-outage-recovery.sh':
ensure => 'absent',
}
}
}
|