Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions site/profile/functions/getcidr.pp

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function profile::is_grid_vgpu() >> Boolean {
function profile::gpu::has_vgpu() >> Boolean {
if $facts['nvidia_grid_vgpu'] {
true
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function profile::generate_slurm_node_line($name, $attr, $comp_weight) >> String {
function profile::slurm::generate_node_line($name, $attr, $comp_weight) >> String {
if $attr['specs']['gpus'] > 0 {
if $attr['specs']['mig'] and ! $attr['specs']['mig'].empty {
$gpu = $attr['specs']['mig'].map|$key,$value| {
Expand Down
7 changes: 7 additions & 0 deletions site/profile/functions/utils/getcidr.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function profile::utils::getcidr() >> String {
$interface = profile::utils::getlocalinterface()
$masklen = extlib::netmask_to_cidr(profile::utils::getnetmask())
$ip = $networking['interfaces'][$interface]['ip']
$network = extlib::cidr_to_network("${ip}/${masklen}")
"${network}/${masklen}"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function profile::gethostnames_with_class($class_name) >> Array[String] {
function profile::utils::gethostnames_with_class($class_name) >> Array[String] {
$instances = lookup('terraform.instances')
$site_all = lookup('magic_castle::site::all')
$site_tags = lookup('magic_castle::site::tags')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function profile::getlocalinterface() >> String {
function profile::utils::getlocalinterface() >> String {
$local_ip = lookup('terraform.self.local_ip')
$interfaces = keys($facts['networking']['interfaces'])
$search = $interfaces.filter | $interface | {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
function profile::getnetmask() >> String {
function profile::utils::getnetmask() >> String {
if $facts['gce'] {
# GCP instances netmask is set to /32 but the network netmask is available
$netmask = $gce['instance']['networkInterfaces'][0]['subnetmask']
} else {
$interface = profile::getlocalinterface()
$interface = profile::utils::getlocalinterface()
$netmask = $networking['interfaces'][$interface]['netmask']
}
$netmask
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function profile::getptrrecord() >> String {
$interface = profile::getlocalinterface()
function profile::utils::getptrrecord() >> String {
$interface = profile::utils::getlocalinterface()
$ip = $networking['interfaces'][$interface]['ip']
$ip_list = split($ip, '[.]')
$netmask_list = split(profile::getnetmask(), '[.]')
$netmask_list = split(profile::utils::getnetmask(), '[.]')

$filtered_ip = $ip_list.filter |$i, $v| { $netmask_list[$i] == '0' }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function profile::getreversezone() >> String {
$interface = profile::getlocalinterface()
function profile::utils::getreversezone() >> String {
$interface = profile::utils::getlocalinterface()
$network = $networking['interfaces'][$interface]['network']
$network_list = split($network, '[.]')
$netmask_list = split(profile::getnetmask(), '[.]')
$netmask_list = split(profile::utils::getnetmask(), '[.]')

$filtered_network = $network_list.filter |$i, $v| { $netmask_list[$i] != '0' }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Puppet::Functions.create_function(:slurm_compute_weights) do
dispatch :slurm_compute_weights do
Puppet::Functions.create_function(:'profile::slurm::compute_weights') do
dispatch :compute_weights do
param 'Hash', :instances
return_type 'Hash'
end

def slurm_compute_weights(instances)
def compute_weights(instances)
require 'set'
unique_specs = Set.new(instances.values.map {|i| i['specs']})
sorted_specs = unique_specs.sort_by{|spec| [spec['gpus'], spec['ram'], spec['cpus']]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Puppet::Functions.create_function(:ssh_split_options) do
dispatch :ssh_split_options do
Puppet::Functions.create_function(:'profile::utils::split_options') do
dispatch :split_options do
param 'String', :options
return_type 'Array'
end
def ssh_split_options(options)
def split_options(options)
return options.scan(/(\w+=".*?"|[\w-]+)/).flatten
end
end
2 changes: 1 addition & 1 deletion site/profile/manifests/base.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
firewall { '001 accept all from local network':
chain => 'INPUT',
proto => 'all',
source => profile::getcidr(),
source => profile::utils::getcidr(),
action => 'accept',
tag => 'mc_bootstrap',
}
Expand Down
2 changes: 1 addition & 1 deletion site/profile/manifests/fail2ban.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
include epel

class { 'fail2ban' :
whitelist => ['127.0.0.1/8', profile::getcidr()] + $ignoreip,
whitelist => ['127.0.0.1/8', profile::utils::getcidr()] + $ignoreip,
}

file_line { 'fail2ban_sshd_recv_disconnect':
Expand Down
2 changes: 1 addition & 1 deletion site/profile/manifests/freeipa.pp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@

$realm = upcase($ipa_domain)
$fqdn = "${facts['networking']['hostname']}.${ipa_domain}"
$reverse_zone = profile::getreversezone()
$reverse_zone = profile::utils::getreversezone()
$ipaddress = lookup('terraform.self.local_ip')

$ipa_server_install_cmd = @("IPASERVERINSTALL"/L)
Expand Down
6 changes: 3 additions & 3 deletions site/profile/manifests/gpu.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
path => ['/bin', '/sbin'],
}

if ! profile::is_grid_vgpu() {
if ! profile::gpu::has_vgpu() {
include profile::gpu::install::passthrough
Class['profile::gpu::install::passthrough'] -> Exec['dkms_nvidia']
} else {
Expand All @@ -58,7 +58,7 @@

# Binary installer do not build drivers with DKMS
$installer = lookup('profile::gpu::install::vgpu::installer', undef, undef, '')
if ! profile::is_grid_vgpu() or $installer != 'bin' {
if ! profile::gpu::has_vgpu() or $installer != 'bin' {
exec { 'dkms_nvidia':
command => "dkms autoinstall -m nvidia -k ${facts['kernelrelease']}",
path => ['/usr/bin', '/usr/sbin'],
Expand Down Expand Up @@ -327,7 +327,7 @@
}

class profile::gpu::services {
if ! profile::is_grid_vgpu() {
if ! profile::gpu::has_vgpu() {
$gpu_services = ['nvidia-persistenced', 'nvidia-dcgm']
} else {
$gpu_services = ['nvidia-gridd']
Expand Down
6 changes: 3 additions & 3 deletions site/profile/manifests/slurm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@
'suspend_rate' => $suspend_rate,
'memlimit' => $os_reserved_memory,
'partitions' => $partitions,
'slurmctl' => profile::gethostnames_with_class('profile::slurm::controller'),
'slurmdb' => profile::gethostnames_with_class('profile::slurm::accounting'),
'slurmctl' => profile::utils::gethostnames_with_class('profile::slurm::controller'),
'slurmdb' => profile::utils::gethostnames_with_class('profile::slurm::accounting'),
}),
group => 'slurm',
owner => 'slurm',
Expand Down Expand Up @@ -244,7 +244,7 @@
{
'nodes' => $nodes,
'memlimit' => $os_reserved_memory,
'weights' => slurm_compute_weights($nodes),
'weights' => profile::slurm::compute_weights($nodes),
}),
}

Expand Down
2 changes: 1 addition & 1 deletion site/profile/manifests/squid.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
squid::acl { 'CLUSTER_NETWORK':
type => 'src',
entries => [profile::getcidr()],
entries => [profile::utils::getcidr()],
}
# How can we have multiple regex entries under the same ACL name?
# From Squid documentation:
Expand Down
2 changes: 1 addition & 1 deletion site/profile/manifests/users.pp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
$key_value = $split[$key_type_index+1]

if $key_type_index != 0 {
$key_options = ssh_split_options($split[0, $key_type_index].join(' '))
$key_options = profile::utils::split_options($split[0, $key_type_index].join(' '))
} else {
$key_options = undef
}
Expand Down
4 changes: 2 additions & 2 deletions site/profile/templates/slurm/nodes.conf.epp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ NodeName=DEFAULT MemSpecLimit=<%= $memlimit %> State=CLOUD
# Always online computes nodes
<% $nodes.each |$name, $attr| { -%>
<% if !('pool' in $attr['tags']) { -%>
<%= profile::generate_slurm_node_line($name, $attr, $weights[$name]) %>
<%= profile::slurm::generate_node_line($name, $attr, $weights[$name]) %>
<% }} -%>

# On-demand pool compute nodes
<% $nodes.each |$name, $attr| { -%>
<% if 'pool' in $attr['tags'] { -%>
<%= profile::generate_slurm_node_line($name, $attr, $weights[$name]) %>
<%= profile::slurm::generate_node_line($name, $attr, $weights[$name]) %>
<% }} -%>