Proxy Runner

Salt Runner to invoke arbitrary commands on network devices that are not managed via a Proxy or regular Minion. Therefore, this Runner doesn’t necessarily require the targets to be up and running, as it will connect to collect the Grains, compile the Pillar, then execute the commands.

class _runners.proxy.NoPingBatch(opts, eauth=None, quiet=False, parser=None)[source]

Similar to the native Salt Batch. but without issuing test.ping to ensure that the Minions are up and running.

gather_minions()[source]

Return a list of minions to use for the batch run

class _runners.proxy.PingBatch(opts, eauth=None, quiet=False, parser=None)[source]
class _runners.proxy.SProxyMinion(opts, context=None)[source]

Create an object that has loaded all of the minion module functions, grains, modules, returners etc. The SProxyMinion allows developers to generate all of the salt minion functions and present them with these functions for general use.

gen_modules(initial_load=False)[source]

Tell the minion to reload the execution modules.

CLI Example:

salt '*' sys.reload_modules
class _runners.proxy.StandaloneProxy(opts, unreachable_devices=None)[source]
_runners.proxy.execute(tgt, salt_function=None, tgt_type='glob', roster=None, preview_target=False, target_details=False, timeout=60, with_grains=True, with_pillar=True, preload_grains=True, preload_pillar=True, default_grains=None, default_pillar=None, args=(), batch_size=None, batch_wait=0, static=False, events=True, cache_grains=True, cache_pillar=True, use_cached_grains=True, use_cached_pillar=True, use_existing_proxy=False, no_connect=False, test_ping=False, target_cache=False, target_cache_timeout=60, preload_targeting=False, invasive_targeting=False, failhard=False, summary=False, verbose=False, show_jid=False, progress=False, hide_timeout=False, sync_roster=False, sync_modules=False, sync_grains=False, sync_all=False, returner='', returner_config='', returner_kwargs=None, **kwargs)[source]

Invoke a Salt function on the list of devices matched by the Roster subsystem.

tgt
The target expression, e.g., * for all devices, or host1,host2 for a list, etc. The tgt_list argument must be used accordingly, depending on the type of this expression.
salt_function
The name of the Salt function to invoke.
tgt_type: glob
The type of the tgt expression. Choose between: glob (default), list, pcre, rage, or nodegroup.
roster: None
The name of the Roster to generate the targets. Alternatively, you can specify the name of the Roster by configuring the proxy_roster option into the Master config.
preview_target: False
Return the list of Roster targets matched by the tgt and tgt_type arguments.
preload_grains: True
Whether to preload the Grains before establishing the connection with the remote network device.
default_grains:
Dictionary of the default Grains to make available within the functions loaded.
with_grains: True
Whether to load the Grains modules and collect Grains data and make it available inside the Execution Functions. The Grains will be loaded after opening the connection with the remote network device.
default_pillar:
Dictionary of the default Pillar data to make it available within the functions loaded.
with_pillar: True
Whether to load the Pillar modules and compile Pillar data and make it available inside the Execution Functions.
arg
The list of arguments to send to the Salt function.
kwargs
Key-value arguments to send to the Salt function.
batch_size: None
The size of each batch to execute.
static: False
Whether to return the results synchronously (or return them as soon as the device replies).
events: True
Whether should push events on the Salt bus, similar to when executing equivalent through the salt command.
use_cached_pillar: True
Use cached Pillars whenever possible. If unable to gather cached data, it falls back to compiling the Pillar.
use_cached_grains: True
Use cached Grains whenever possible. If unable to gather cached data, it falls back to collecting Grains.
cache_pillar: True
Cache the compiled Pillar data before returning.
cache_grains: True
Cache the collected Grains before returning.
use_existing_proxy: False
Use the existing Proxy Minions when they are available (say on an already running Master).
no_connect: False
Don’t attempt to initiate the connection with the remote device. Default: False (it will initiate the connection).
test_ping: False
When using the existing Proxy Minion with the use_existing_proxy option, can use this argument to verify also if the Minion is responsive.
target_cache: True
Whether to use the cached target matching results.
target_cache_timeout: 60
The duration to cache the target results for (in seconds).

CLI Example:

salt-run proxy.execute_roster edge* test.ping
salt-run proxy.execute_roster junos-edges test.ping tgt_type=nodegroup
_runners.proxy.execute_devices(minions, salt_function, with_grains=True, with_pillar=True, preload_grains=True, preload_pillar=True, default_grains=None, default_pillar=None, args=(), batch_size=None, batch_wait=0, static=False, tgt=None, tgt_type=None, jid=None, events=True, cache_grains=True, cache_pillar=True, use_cached_grains=True, use_cached_pillar=True, use_existing_proxy=False, existing_minions=None, no_connect=False, roster_targets=None, test_ping=False, preload_targeting=False, invasive_targeting=False, failhard=False, timeout=60, summary=False, verbose=False, progress=False, hide_timeout=False, returner='', returner_config='', returner_kwargs=None, **kwargs)[source]

Execute a Salt function on a group of network devices identified by their Minion ID, as listed under the minions argument.

minions
A list of Minion IDs to invoke function on.
salt_function
The name of the Salt function to invoke.
preload_grains: True
Whether to preload the Grains before establishing the connection with the remote network device.
default_grains:
Dictionary of the default Grains to make available within the functions loaded.
with_grains: False
Whether to load the Grains modules and collect Grains data and make it available inside the Execution Functions. The Grains will be loaded after opening the connection with the remote network device.
preload_pillar: True
Whether to preload Pillar data before opening the connection with the remote network device.
default_pillar:
Dictionary of the default Pillar data to make it available within the functions loaded.
with_pillar: True
Whether to load the Pillar modules and compile Pillar data and make it available inside the Execution Functions.
args
The list of arguments to send to the Salt function.
kwargs
Key-value arguments to send to the Salt function.
batch_size: None
The size of each batch to execute.
static: False
Whether to return the results synchronously (or return them as soon as the device replies).
events: True
Whether should push events on the Salt bus, similar to when executing equivalent through the salt command.
use_cached_pillar: True
Use cached Pillars whenever possible. If unable to gather cached data, it falls back to compiling the Pillar.
use_cached_grains: True
Use cached Grains whenever possible. If unable to gather cached data, it falls back to collecting Grains.
cache_pillar: True
Cache the compiled Pillar data before returning.
cache_grains: True
Cache the collected Grains before returning.
use_existing_proxy: False
Use the existing Proxy Minions when they are available (say on an already running Master).
no_connect: False
Don’t attempt to initiate the connection with the remote device. Default: False (it will initiate the connection).
test_ping: False
When using the existing Proxy Minion with the use_existing_proxy option, can use this argument to verify also if the Minion is responsive.

CLI Example:

salt-run proxy.execute "['172.17.17.1', '172.17.17.2']" test.ping driver=eos username=test password=test123
_runners.proxy.salt_call(minion_id, salt_function=None, unreachable_devices=None, failed_devices=None, with_grains=True, with_pillar=True, preload_grains=True, preload_pillar=True, default_grains=None, default_pillar=None, cache_grains=True, cache_pillar=True, use_cached_grains=True, use_cached_pillar=True, use_existing_proxy=False, no_connect=False, jid=None, roster_opts=None, test_ping=False, tgt=None, tgt_type=None, preload_targeting=False, invasive_targeting=False, failhard=False, timeout=60, returner='', returner_config='', returner_kwargs=None, args=(), **kwargs)[source]

Invoke a Salt Execution Function that requires or invokes an NAPALM functionality (directly or indirectly).

minion_id:
The ID of the Minion to compile Pillar data for.
salt_function
The name of the Salt function to invoke.
preload_grains: True
Whether to preload the Grains before establishing the connection with the remote network device.
default_grains:
Dictionary of the default Grains to make available within the functions loaded.
with_grains: True
Whether to load the Grains modules and collect Grains data and make it available inside the Execution Functions. The Grains will be loaded after opening the connection with the remote network device.
preload_pillar: True
Whether to preload Pillar data before opening the connection with the remote network device.
default_pillar:
Dictionary of the default Pillar data to make it available within the functions loaded.
with_pillar: True
Whether to load the Pillar modules and compile Pillar data and make it available inside the Execution Functions.
use_cached_pillar: True
Use cached Pillars whenever possible. If unable to gather cached data, it falls back to compiling the Pillar.
use_cached_grains: True
Use cached Grains whenever possible. If unable to gather cached data, it falls back to collecting Grains.
cache_pillar: True
Cache the compiled Pillar data before returning.
cache_grains: True
Cache the collected Grains before returning.
use_existing_proxy: False
Use the existing Proxy Minions when they are available (say on an already running Master).
no_connect: False
Don’t attempt to initiate the connection with the remote device. Default: False (it will initiate the connection).
jid: None
The JID to pass on, when executing.
test_ping: False
When using the existing Proxy Minion with the use_existing_proxy option, can use this argument to verify also if the Minion is responsive.
arg
The list of arguments to send to the Salt function.
kwargs
Key-value arguments to send to the Salt function.

CLI Example:

salt-run proxy.salt_call bgp.neighbors junos 1.2.3.4 test test123
salt-run proxy.salt_call net.load_config junos 1.2.3.4 test test123 text='set system ntp peer 1.2.3.4'