All of the various subprocess.Popen invocations are now merged into one mega
function to call subprocess.Popen and return the results happily for you
root@desktopmonster:~# salt '*' cmd.run 'su - jeff -c "cat /etc/shadow"' --text-out
desktopmonster: cat: /etc/shadow: Permission denied
root@desktopmonster:~# salt '*' cmd.run 'whoami' --text-out
desktopmonster: root
root@desktopmonster:~# salt '*' cmd.run_stdout 'su - jeff -c "cat /etc/shadow"' --text-out
root@desktopmonster:~# salt '*' cmd.run_stdout 'whoami' --text-out
desktopmonster: root
root@desktopmonster:~# salt '*' cmd.run_stderr 'su - jeff -c "cat /etc/shadow"' --text-out
desktopmonster: cat: /etc/shadow: Permission denied
root@desktopmonster:~# salt '*' cmd.run_stderr 'whoami' --text-out
root@desktopmonster:~# salt '*' cmd.run_all 'su - jeff -c "cat /etc/shadow"' --text-out
key: {'pid': 573, 'retcode': 1, 'stderr': 'cat: /etc/shadow: Permission denied\n', 'stdout': ''}
root@desktopmonster:~# salt '*' cmd.run_all 'whoami' --text-out
desktopmonster: {'pid': 601, 'retcode': 0, 'stderr': '', 'stdout': 'root\n'}
root@desktopmonster:~# salt '*' cmd.retcode 'su - jeff -c "cat /etc/shadow"'
{'desktopmonster': 1}
root@desktopmonster:~# salt '*' cmd.retcode 'whoami'
{'desktopmonster': 0}
root@desktopmonster:~# salt '*' cmd.exec_code python 'print "HI"'
{'desktopmonster': 'HI\n'}
The new exceptions module's SaltInvocationError was written specifically
to pretty-print errors whenever a nodegroup is references that doesn't
exist in the master's configuration file.
===== BEFORE =====
root@desktopmonster:~# salt -N group3 test.version
Traceback (most recent call last):
File "/home/jeff/git/salt/scripts/salt", line 17, in <module>
main()
File "/home/jeff/git/salt/scripts/salt", line 14, in main
client.run()
File "/home/jeff/git/salt/salt/cli/__init__.py", line 248, in run
full_ret = local.cmd_full_return(*args)
File "/home/jeff/git/salt/salt/client.py", line 170, in cmd_full_return
timeout=timeout)
File "/home/jeff/git/salt/salt/client.py", line 321, in pub
tgt = self.opts['nodegroups'][tgt]
KeyError: 'group3'
===== AFTER =====
root@desktopmonster:~# salt -N group3 test.version
Node group 'group3' not available in /etc/salt/master
The idea of this is for fixing the nodegroups patch series when an
invalid nodegroup name is specified on the commandline and return
a user friendly error message instead of blowing up angrily.