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__"]["commands"] or["__task__"]["filename"] locations, use configuration provided by config argument otherwise

  • If 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, if batch argument given, pushes commands in batches

  • If commit argument provided, perform configuration commit if device supports it

  • If commit_final_delay argument provided, wait for a given timer and perform final commit

  • Exit device configuration mode and return configuration results


Sample Usage

Code to invoke pyats_send_config task:

from nornir_salt.plugins.tasks import pyats_send_config

output =
    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.

  • config – (str or list) configuration string or list of commands to send to device

  • kwargs – (dict) any additional **kwargs for device connection configure method

Return result

Nornir result object with task execution results

Device configure method supports below additional arguments that can be passed via **kwargs:

  • 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