Skip to content

Commit

Permalink
Remove profile::nfs::server::device dep from profile::account
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd-ntrf committed Dec 18, 2023
1 parent b761ed0 commit fffeed7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
23 changes: 12 additions & 11 deletions site/profile/manifests/accounts.pp
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# @summary Class configuring services to bridge LDAP users, Slurm accounts and users' folders in filesystems
# @param project_regex Regex identifying FreeIPA groups that require a corresponding Slurm account
# @param manage_home
# @param manage_scratch
# @param manage_project
# @param skel_archives Archives extracted in each FreeIPA user's home when created
class profile::accounts (
String $project_regex,
Boolean $manage_home = true,
Boolean $manage_scratch = true,
Boolean $manage_project = true,
Array[Struct[{ filename => String[1], source => String[1] }]] $skel_archives = [],
) {
Service <| tag == profile::slurm |> -> Service['mkhome']
Expand All @@ -12,11 +18,6 @@
Mount <| |> -> Service['mkhome']
Mount <| |> -> Service['mkproject']

$nfs_devices = lookup('profile::nfs::server::devices', undef, undef, {})
$with_home = 'home' in $nfs_devices
$with_project = 'project' in $nfs_devices
$with_scratch = 'scratch' in $nfs_devices

package { 'rsync':
ensure => 'installed',
}
Expand All @@ -29,10 +30,10 @@
file { '/sbin/mkhome.sh':
content => epp('profile/accounts/mkhome.sh',
{
with_home => $with_home,
with_scratch => $with_scratch,
project_regex => $project_regex,
with_project => $with_project,
manage_home => $manage_home,
manage_scratch => $manage_scratch,
project_regex => $project_regex,
manage_project => $manage_project,
}
),
mode => '0755',
Expand Down Expand Up @@ -93,7 +94,7 @@
path => ['/bin/', '/usr/bin'],
}

$mkhome_running = $with_home or $with_scratch
$mkhome_running = $manage_home or $manage_scratch
service { 'mkhome':
ensure => $mkhome_running,
enable => $mkhome_running,
Expand All @@ -113,7 +114,7 @@
content => epp('profile/accounts/mkproject.sh',
{
project_regex => $project_regex,
with_folder => $with_project,
manage_folder => $manage_project,
}
),
mode => '0755',
Expand Down
8 changes: 4 additions & 4 deletions site/profile/manifests/nfs.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
nfs_v4_idmap_domain => $nfs_domain,
}

$nfs_server = keys(lookup('terraform.instances').filter| $key, $values | { $values['local_ip'] == $server_ip })[0]
$devices = lookup("terraform.instances.${nfs_server}.volumes.nfs", Hash[String, Array[String]], 'first', {})
if $devices =~ Hash[String, Array[String]] {
$nfs_export_list = keys($devices)
$nfs_server = lookup('terraform.instances').filter| $key, $values | { $values['local_ip'] == $server_ip }
$nfs_volumes = $nfs_server['volumes']['nfs']
if $nfs_volumes =~ Hash[String, Array[String]] {
$nfs_export_list = keys($nfs_volumes)
$options_nfsv4 = 'proto=tcp,nosuid,nolock,noatime,actimeo=3,nfsvers=4.2,seclabel,x-systemd.automount,x-systemd.mount-timeout=30,_netdev'
$nfs_export_list.each | String $name | {
nfs::client::mount { "/${name}":
Expand Down
8 changes: 4 additions & 4 deletions site/profile/templates/accounts/mkhome.sh.epp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ PROJECT_REGEX="<%= $project_regex %>"
tail -F /var/log/dirsrv/slapd-*/access |
grep --line-buffered -oP 'ADD dn=\"uid=\K([a-z0-9A-Z_]*)(?=,cn=users)' |
while read USERNAME; do
<% if $with_home { -%>
<% if $manage_home { -%>
mkhome $USERNAME
<% } -%>
<% if $with_scratch { -%>
mkscratch $USERNAME <%= $with_home %>
<% if $manage_scratch { -%>
mkscratch $USERNAME <%= $manage_home %>
<% } -%>

for PROJECT in $((id -Gn ${USERNAME} 2> /dev/null || kexec ipa user-show ${USERNAME} | grep 'Member of groups:') | grep -P -o "${PROJECT_REGEX}"); do
modproject ${PROJECT} <%= $with_project %> ${USERNAME}
modproject ${PROJECT} <%= $manage_project %> ${USERNAME}
done
done

0 comments on commit fffeed7

Please sign in to comment.