Эх сурвалжийг харах

Added a script that calles salt function on a minion

nee2c 4 жил өмнө
parent
commit
a1dfa51a1a
1 өөрчлөгдсөн 19 нэмэгдсэн , 0 устгасан
  1. 19 0
      api/caller.py

+ 19 - 0
api/caller.py

@@ -0,0 +1,19 @@
+import salt.client
+
+salt = salt.client.Caller()
+
+print(type(salt.cmd('network.ping', '1.1.1.1')))
+
+
+print(salt.cmd('archive.tar', 'czf', '/tmp/etc.tar.gz', '/etc/'))
+
+print(salt.cmd('file.readdir', '/tmp/'))
+
+req = salt.cmd('http.query', 'https://checkip.amazonaws.com', method='GET')
+
+ip = req.get('body', '0.0.0.0').strip()
+
+print(ip)
+print(req)
+
+salt.cmd('event.send', 'salt/hello', {'msg':'Hello world'})