The final module

With all of our code in place, the final module will look like:

''' Scan Minions for various pieces of information This file should be saved as salt/runners/scan.py ''' import salt.client import salt.key __func_alias__ = { 'up_': 'up' } def up_(tgt='*', tgt_type='glob'): ''' Return a list of minions which are responding ''' client = salt.client.get_local_client(__opts__['conf_file']) minions = client.cmd( tgt, 'test.ping', expr_form=tgt_type, timeout=__opts__['timeout'] ''' Return a list of minions which are NOT responding ''' minions = up_(tgt, tgt_type) key = salt.key.Key(__opts__) keys = key.list_keys() return sorted(set(keys['minions']) - set(minions)) def hypers(client=None): ''' Return a list of Minions that are running hypervisors ...

Get Extending SaltStack now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.