How to store linux command output into a variable in puppet

前端 未结 1 2010
-上瘾入骨i
-上瘾入骨i 2021-01-05 06:09

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

相关标签:
1条回答
  • 2021-01-05 07:02

    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)
    
    0 讨论(0)
提交回复
热议问题