cmd.run hanging on minion script

51 views
Skip to first unread message

John Ratliff

unread,
Jan 17, 2018, 1:12:19 PM1/17/18
to Salt-users
I have a script, and when it executes from cmd.run, it always hangs.

I've found that it hangs on this line in the bourne shell script:

PW=$($CAT /dev/urandom | $TR -dc 'a-zA-Z0-9' | $FOLD -w 32 | $HEAD -n 1)

which I use to generate a random password.

Why would salt-minion hang when running this? Suggestions for how to resolve this problem?

Thanks.

Daniel Wallace

unread,
Jan 17, 2018, 1:18:40 PM1/17/18
to Salt-users
Probably trying slowly generating random numbers for generating the password.

/dev/urandom first uses the /dev/random entropy buffer, and then will generate random numbers afterwards.

There are salt modules that you could use in your script to generate passwords, but you could also install a service like `haveged` https://linux.die.net/man/8/haveged or `rngd` https://linux.die.net/man/8/rngd to generate and add extra randomness to the entropy faster.

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/594b8f60-0076-4696-921e-6e311b4a30da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Ratliff

unread,
Jan 17, 2018, 2:33:43 PM1/17/18
to Salt-users
I installed haveged. It made no difference. The available entropy went from hovering around 850 to hovering around 2250, but it still hangs, which it never does when running locally; only when it is called by salt.

How would I do something like
salt 'name' random.get_str 128

on the minion itself?

On Wednesday, January 17, 2018 at 1:18:40 PM UTC-5, Daniel Wallace wrote:
Probably trying slowly generating random numbers for generating the password.

/dev/urandom first uses the /dev/random entropy buffer, and then will generate random numbers afterwards.

There are salt modules that you could use in your script to generate passwords, but you could also install a service like `haveged` https://linux.die.net/man/8/haveged or `rngd` https://linux.die.net/man/8/rngd to generate and add extra randomness to the entropy faster.
On Wed, Jan 17, 2018 at 11:12 AM, John Ratliff <jo...@technoplaza.net> wrote:
I have a script, and when it executes from cmd.run, it always hangs.

I've found that it hangs on this line in the bourne shell script:

PW=$($CAT /dev/urandom | $TR -dc 'a-zA-Z0-9' | $FOLD -w 32 | $HEAD -n 1)

which I use to generate a random password.

Why would salt-minion hang when running this? Suggestions for how to resolve this problem?

Thanks.

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.

Daniel Wallace

unread,
Jan 17, 2018, 3:29:48 PM1/17/18
to Salt-users
`salt-call random.get_str 128`

alternatively, https://docs.saltstack.com/en/latest/ref/clients/#salt.client.Caller if you wanted to write something in python, you could use the caller client.

To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/52a516e0-bfaf-45ba-b51f-c8d4109b0ef3%40googlegroups.com.

John Ratliff

unread,
Jan 20, 2018, 12:38:20 PM1/20/18
to Salt-users
Thanks. I found the salt-call thing very useful. Still not sure why it hangs when it seems to have plenty of entropy, but the workaround is good enough.
Reply all
Reply to author
Forward
0 new messages