7

Is it possible to store a linux command result in variable?

I am trying to store an encrypted value in a variable. To encrypt I am using base64 command. To store it in variable, I am using generate method. But I am not able to store a value.

$secretvalue    = generate("/bin/bash","-c","/usr/bin/echo ${password} | /usr/bin/base64")
1
  • 8
    base64 is not an encryption. Commented Nov 21, 2015 at 10:10

1 Answer 1

11
+50

If you want to execute any command on Puppet Master server you can use inline_template function with ERB template inside and Ruby code for execute shell command:

$password = "12345"

$secretvalue = inline_template("<%= `/bin/echo ${password} | /usr/bin/base64` %>")

notify { "STDOUT: ${secretvalue}": }

P.S. If you just want to encode string to Base64 format you can import puppetlabs-stdlib module and use base64 function from it:

$secretvalue = base64('encode', $password)
Sign up to request clarification or add additional context in comments.

2 Comments

Is it possible to launch some bash command on puppet client host and save it into variable?
Yes, but only through your custom facts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.