22.16.112. salt.modules.mod_random

New in version 2014.7.0.

Provides access to randomness generators.

salt.modules.mod_random.get_str(length=20)

New in version 2014.7.0.

Returns a random string of the specified length.

length : 20
Any valid number of bytes.

CLI Example:

salt '*' random.get_str 128
salt.modules.mod_random.hash(value, algorithm='sha512')

New in version 2014.7.0.

Encodes a value with the specified encoder.

value
The value to be hashed.
algorithm : sha512
The algorithm to use. May be any valid algorithm supported by hashlib.

CLI Example:

salt '*' random.hash 'I am a string' md5
salt.modules.mod_random.shadow_hash(crypt_salt=None, password=None, algorithm='sha512')

Generates a salted hash suitable for /etc/shadow.

crypt_salt : None
Salt to be used in the generation of the hash. If one is not provided, a random salt will be generated.
password : None
Value to be salted and hashed. If one is not provided, a random password will be generated.
algorithm : sha512
Hash algorithm to use.

CLI Example:

salt '*' random.shadow_hash 'My5alT' 'MyP@asswd' md5
salt.modules.mod_random.str_encode(value, encoder='base64')

New in version 2014.7.0.

value
The value to be encoded.
encoder : base64
The encoder to use on the subsequent string.

CLI Example:

salt '*' random.str_encode 'I am a new string' base64

Docs for previous releases are available on salt.rtfd.org.

Latest Salt release: 2014.1.13

Try the shiny new release candidate of Salt, v2014.7.0rc6! More info here.

Previous topic

22.16.111. salt.modules.mine

Next topic

22.16.113. salt.modules.modjk

SaltStack News

Upcoming SaltStack events, webinars and local meet ups and user groups.