Skip to content

How to pass sensitive data to a command in a cmd.run state #66420

Answered by merlinz01
merlinz01 asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks, I hadn't seen the slots feature before. I also just discovered that the cmd.run state accepts more options than are documented, including a stdin option, which is perfect to use in conjunction with the slots feature. So we end up with this proof-of-concept:

fancy little trick:
  cmd.run:
    - name: rev /dev/stdin
    - stdin: __slot__:salt:test.echo("hello there")

resulting in

local:
----------
          ID: mycommand
    Function: cmd.run
        Name: rev /dev/stdin
      Result: True
     Comment: Command "rev /dev/stdin" run
     Started: 18:54:14.194017
    Duration: 9.259 ms
     Changes:   
              ----------
              pid:
                  2023192
             …

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@merlinz01
Comment options

Answer selected by merlinz01
@merlinz01
Comment options

@nicholasmhughes
Comment options

@merlinz01
Comment options

@merlinz01
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants