getting the output of cmd.run into a jinja variable with orchestrate runner

448 views
Skip to first unread message

אורן שני

unread,
Aug 28, 2017, 11:18:13 AM8/28/17
to Salt-users
Hi All,

I have a question which I think should be pretty simple, I just can't find the exact syntax for doing that, so I hope you can help.

I using the salt orchestrate runner to implement a backup system in our network. Basically there is a machine called 'bkpserver' that we use to copy fiels from other machines (via rsync) and I am looking for a way to stick the rsync output into a jinja variable, so that I can write it into a grain.

I know I can do something like  {% o = salt['cmd.run'] ... %} , but this is not going to help me since the command will run on the salt master, not on bkpserver,, so what I really need is to stick something like:

salt.function:
  - name: run.cmd
  - tgt: bkpserver
  - arg:
    - <command to cat the log file>

Into a {% o = salt[... %} statement.

Of course if someone can tell me of a better way to get the content of a file on one host into a grain on anther host, that would be even better.

Thanks in advance,

Oren

Sean Brennan

unread,
Aug 31, 2017, 5:25:21 PM8/31/17
to Salt-users
I think saltutil.cmd is what you are looking for. 


Ex: {% set o = salt['saltutil.cmd'](tgt, fun, ...) %}
Reply all
Reply to author
Forward
0 new messages