pass the cmd.run stdout to variable #67887
Replies: 2 comments 1 reply
-
so, for your first question, you use the module cmd.run not the state if it is happening in a state it is already too late to be in the jinja. and please. in the future use markdown to clarify and code like snippets.
as for the second question. it already works that way.
you need to make sure your if statement is actually true of coarse. |
Beta Was this translation helpful? Give feedback.
-
one final thing. about the first question. I would look for a module that handles that data cleaner then the cmd.run first. such as the status module or some other module. that might beable to pick up the information. cmd.run in jinja can be messy. |
Beta Was this translation helpful? Give feedback.
-
Hi All,
I need some help in assigning the result (std output) of cmd.run module to a variable in state file and also I need some help in calling a variable from inside of an if condition to out side of it
exp:
test:
cmd.run:
- name: "df -hT"
I want the std out of above to a variable
also I need some help in
{% set node = salt'pillar.get' %}
{% if node == grains.host %}
{% set data = '123 %}
{% endif %}
test_1:
cmd.run:
- name: echo {{ data }}
Beta Was this translation helpful? Give feedback.
All reactions