Search code examples
jbossmd5puppetjboss-eap-6puppet-enterprise

Getting different hash value with puppet exec


When I have executed the following command I am getting the perfect hash value which i have expected.

/opt/Jboss/dc/bin/add-user.sh --silent --user testuser --password testuser*1 --realm ManagementRealm

Hash Logic = md5(testuser:ManagementRealm:testuser*1)

Expected hash value = e72bfb358dd2116ad0033c01e357c1b2

But when i have tried the same thing with puppet exec. I am getting different hash value. I don't know how to debug or fix it. Any help is much appreciated.

my puppet code :

define jboss::useradd(
$home,
$username,
$password,
) {
        $jbossuserfix   = '2>&1 | awk \'BEGIN{a=0}{if (/Error/){a=1};print}END{if (a==1) exit 1}\''
        $realm          = "ManagementRealm"
        $filepath       = "${home}/domain/configuration/mgmt-users.properties"
        $encrypasswd    = md5("${username}:ManagementRealm:${password}")
        notify { " ${title} Encry ${encrypasswd} ": }
        exec { "${title}::user::add":
                environment => ["JBOSS_HOME=${home}","__PASSWD=${password}"],
                command     => "${home}/bin/add-user.sh --silent --user '${username}' --password \"\$__PASSWD\" --realm '{realm}' ${jbossuserfix}",
                unless      => "/bin/egrep -e '^${username}=${encrypasswd}' ${filepath}",
                require     => File["${home}/domain/configuration/domain.xml"],
                logoutput   => true,
        }
}

The following is the result i am getting with my above code.

Result hash value : fb8ed958ba3d535fb8314d4da4b96d42


Solution

  • The command attribute in your puppet code doesn't match the example line you give.

    First, you're missing the $ on ${realm}.

    Second, you've added quotes around the parameters in the puppet code. Not knowing anything about the script you are calling, that may or may not be important.