Why do these SaltStack functions have different output?

32 Views Asked by At

I'm new to SaltStack and ran these two command:

# salt '*' test.echo "$PWD"
# salt '*' cmd.run "pwd"

I have got different output! Does anyone know what is the difference between two above command?

I expected the same result for both commands.

1

There are 1 best solutions below

0
OrangeDog On BEST ANSWER

When you run a shell command, first any shell expansions are processed, then the command is executed.

For the first command it expands "$PWD" to the current working directory of the shell, then instructs all minions to run e.g. test.echo('/home/mhm').

For the second command it instead instructs all minions to run cmd.run('pwd'), which returns the current working directory of the minion service.