puppet-prod/site/profiles/manifests/nomad/node.pp
2025-06-14 19:37:50 +10:00

88 lines
2.1 KiB
Puppet

# profiles::nomad::node
class profiles::nomad::node (
Stdlib::Absolutepath $data_dir = '/data/nomad',
Stdlib::Absolutepath $nomad_root = '/shared/nomad',
Integer $bootstrap_expect = 3,
Boolean $server = false,
Boolean $client = false,
Boolean $manage_service = true,
Boolean $manage_user = true,
String $user = 'nomad',
String $group = 'nomad',
Array $host_volumes = [],
){
if $manage_user {
# Define the group for Nomad
group { $group:
ensure => 'present',
system => true,
}
# Define the user for Nomad
user { $user:
ensure => 'present',
comment => 'Nomad System User',
home => '/var/lib/nomad',
managehome => true,
shell => '/sbin/nologin',
system => true,
gid => $group,
require => Group[$group],
}
}
if $client {
if $facts['virtual'] != 'lxc' {
include profiles::ceph::client
# manage the sharedvol
profiles::storage::cephfsvol {"${::facts['networking']['fqdn']}_nomad":
mount => $nomad_root,
keyring => '/etc/ceph/ceph.client.nomad.keyring',
cephfs_name => 'nomad',
cephfs_fs => 'nomadfs',
require => Profiles::Ceph::Keyring['nomad'],
}
}
}
file { $data_dir:
ensure => directory,
owner => $user,
group => $group,
mode => '0755',
require => [
User[$user],
Group[$group],
],
}
mkdir::p {'/etc/nomad.d/':}
-> file { '/etc/nomad.d/config.hcl':
ensure => file,
owner => 'root',
group => 'root',
mode => '0755',
content => template('profiles/nomad/config.hcl.erb'),
require => [
Package['nomad'],
],
}
if $manage_service {
include ::systemd
systemd::unit_file { 'nomad.service':
content => template('profiles/nomad/nomad.service.erb'),
enable => true,
active => true,
subscribe => [
File['/etc/pki/tls/vault/private.key'],
File['/etc/nomad.d/config.hcl']
],
}
}
}