Skip to content

Instantly share code, notes, and snippets.

Created December 8, 2015 23:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/279350ea9a0accf2a530 to your computer and use it in GitHub Desktop.
Save anonymous/279350ea9a0accf2a530 to your computer and use it in GitHub Desktop.
def pillar_queries(pillar_queries):
'''
Execute a set of queries as described in a pillar key
Specified Pillar key must contain an array of dictionaries,
Each dictionary must contain a "query" and "query_id" key
CLI Example:
.. code-block:: bash
salt '*' osquery.pillar_queries "select * from users;"
'''
queries = __salt__['pillar.item'](pillar_queries)[pillar_queries]
results = []
for q in queries:
q_res = _osquery(q['query'])
results.append(
{'query_id':q['query_id'],
'results':q_res,
'fqdn':__salt__['grains.get']("fqdn"),
})
return results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment