如何将linux命令输出存储到puppet中的一个variables中

是否有可能存储一个Linux命令的结果variables?

我正试图在一个variables中存储一个encryption的值。 要encryption,我使用base64命令。 要将其存储在variables中,我正在使用生成方法。 但是我不能存储一个值。

$secretvalue = generate("/bin/bash","-c","/usr/bin/echo ${password} | /usr/bin/base64") 

如果你想在Puppet主服务器上执行任何命令,你可以使用带有ERB模板的inline_template函数和执行shell命令的Ruby代码:

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

PS如果您只想将字符串编码为Base64格式,则可以导入puppetlabs-stdlib模块并使用base64功能:

 $secretvalue = base64('encode', $password)