From d4e98f6b57d5d9ba93d8c5050df6a7b333c84c18 Mon Sep 17 00:00:00 2001 From: Nathan Carlson Date: Thu, 19 Sep 2024 13:52:22 -0500 Subject: [PATCH] More reliably test for current user state --- manifests/user.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/user.pp b/manifests/user.pp index 71a3e1b..6d4a868 100644 --- a/manifests/user.pp +++ b/manifests/user.pp @@ -60,13 +60,13 @@ exec { "ipmi_user_add_${title}": command => "/usr/bin/ipmitool user set name ${user_id} ${user}", - unless => "/usr/bin/test \"$(ipmitool user list ${channel} | grep '^${user_id}' | awk '{print \$2}' | head -n1)\" = \"${user}\"", + unless => "/usr/bin/ipmitool user list ${channel} | grep -qE '^${user_id}[ ]+${user} '", notify => [Exec["ipmi_user_priv_${title}"], Exec["ipmi_user_setpw_${title}"]], } exec { "ipmi_user_priv_${title}": command => "/usr/bin/ipmitool user priv ${user_id} ${priv} ${channel}", - unless => "/usr/bin/test \"$(ipmitool user list ${channel} | grep '^${user_id}' | awk '{print \$6}' | head -n1)\" = ${privilege}", + unless => "/usr/bin/ipmitool user list ${channel} | grep -qE '^${user_id} .+ ${privilege}$'", notify => [Exec["ipmi_user_enable_${title}"], Exec["ipmi_user_enable_sol_${title}"], Exec["ipmi_user_channel_setaccess_${title}"]], } @@ -97,7 +97,7 @@ } else { exec { "ipmi_user_priv_${title}": command => "/usr/bin/ipmitool user priv ${user_id} 0xF ${channel}", - unless => "/usr/bin/test \"$(ipmitool user list ${channel} | grep '^${user_id}' | awk '{print \$6}' | head -n1)\" = 'NO ACCESS'", + unless => "/usr/bin/ipmitool user list ${channel} | grep -qE '^${user_id} .+ NO ACCESS$'", notify => [Exec["ipmi_user_disable_${title}"], Exec["ipmi_user_disable_sol_${title}"], Exec["ipmi_user_channel_setaccess_${title}"]], }