pyats_send_config
This task plugin relies on Genie device conection config
method
to send configuration commands to devices over SSH or Telnet.
This task plugin applies device configuration following this sequence:
Retrieve and use, if any, per-host configuration rendered by SaltStack from host’s inventory data
task.host.data["__task__"]["commands"]
ortask.host.data["__task__"]["filename"]
locations, use configuration provided byconfig
argument otherwiseIf configuration is a multi-line string, split it to a list of commands
Check if device in enable mode, if not enter device enabled mode if device supports it
Push configuration commands to device using
send_config_set
Netmiko connection’s method, ifbatch
argument given, pushes commands in batchesIf
commit
argument provided, perform configuration commit if device supports itIf
commit_final_delay
argument provided, wait for a given timer and perform final commitExit device configuration mode and return configuration results
Dependencies:
PyATS library required
Genie library required
Sample Usage
Code to invoke pyats_send_config
task:
from nornir_salt.plugins.tasks import pyats_send_config
output = nr.run(
task=pyats_send_config,
commands=["interface loopback 0", "description 'configured by script'"]
)
pyats_send_config
returns Nornir results object with task name set
to pyats_send_config
and results containing configuration commands
applied to device.
API Reference
- nornir_salt.plugins.tasks.pyats_send_config.pyats_send_config(task: nornir.core.task.Task, config: str = None, **kwargs)
Salt-nornir Task function to send configuration to devices using
nornir_netmiko.tasks.pyats_send_config
plugin.Device
configure
method does not support specifying connection to use to send configuration via.- Parameters
config – (str or list) configuration string or list of commands to send to device
kwargs – (dict) any additional
**kwargs
for device connectionconfigure
method
- Return result
Nornir result object with task execution results
Device
configure
method supports below additional arguments that can be passed via**kwargs
:- Parameters
timeout – Timeout value in sec, Default Value is 30 sec
error_pattern – list of regex to detect command errors
target – Target RP where to execute service, for DualRp only
lock_retries – retry times if config mode is locked, default is 0
lock_retry_sleep – sleep between retries, default is 2 sec
bulk – If False, send all commands in one sendline, If True, send commands in chunked mode, default is False
bulk_chunk_lines – maximum number of commands to send per chunk, default is 50, 0 means to send all commands in a single chunk
bulk_chunk_sleep – sleep between sending command chunks, default is 0.5 sec