Skip to content

Instantly share code, notes, and snippets.

@kaithar
Created December 13, 2013 18:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaithar/7948949 to your computer and use it in GitHub Desktop.
Save kaithar/7948949 to your computer and use it in GitHub Desktop.
from salt.client import LocalClient
client = LocalClient()
o = client.cmd(t, 'cmd.run_all', kwarg={
'cmd': 'curl *options and url redacted*',
'cwd': dirname
})
print "Ret: %(retcode)d\n\nstdout:\n%(stdout)s\n\nstderr:\n%(stderr)s\n" % o[t]
print o[t], "\n"
if o[t]['retcode'] != 0:
client.cmd(t, 'file.remove', arg=(dirname,), timeout=5)
else:
o = client.cmd(t, 'cmd.run_all', kwarg={ 'cmd': sed_monster, 'cwd': dirname})
if o[t]['retcode'] != 0:
client.cmd(t, 'file.remove', arg=(dirname,), timeout=5)
else:
print client.cmd(t, 'cmd.run_all', kwarg={
'cmd': 'mv %s %s' % (dirname, realdirname)},
timeout=5)
#---
from salt.client import LocalClient
from salt.key import Key
client = LocalClient()
keys = Key(client.opts)
grains = client.cmd("*", "grains.items", timeout=1)
army = []
for node in keys.all_keys()['minions']:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment