Skip to content

Commit

Permalink
Provide password capacity parameter to set password command
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanlcarlson committed Sep 20, 2024
1 parent 287b744 commit 9d071bd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion manifests/user.pp
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,24 @@
notify => [Exec["ipmi_user_enable_${title}"], Exec["ipmi_user_enable_sol_${title}"], Exec["ipmi_user_channel_setaccess_${title}"]],
}

if $real_password.length > 20 {
fail('ipmi v2 restricts passwords to 20 or fewer characters')
}
# Password capacity parameter defaults to 16 if not provided
# and will result in truncated passwords
if $real_password.length <= 16 {
$password_capacity = '16'
} else {
$password_capacity = '20'
}

$unless_cmd = @("CMD"/L$)
/usr/bin/ipmitool user test ${user_id} 16 "\$PASSWORD" || \
/usr/bin/ipmitool user test ${user_id} 20 "\$PASSWORD"
|- CMD
exec { "ipmi_user_setpw_${title}":
environment => ["PASSWORD=${real_password}"],
command => "/usr/bin/ipmitool user set password ${user_id} \"\$PASSWORD\"",
command => "/usr/bin/ipmitool user set password ${user_id} \"\$PASSWORD\" ${password_capacity}",
unless => $unless_cmd,
notify => Exec[
"ipmi_user_enable_${title}",
Expand Down

0 comments on commit 9d071bd

Please sign in to comment.