This task plugin uses nornir-napalm napalm_cli task to send multiple commands to devices pre-processing commands accordingly.

Pre-processing includes:

  • Check and if any - retrieve per-host commands from host’s inventory data["__task__"]["commands"] or from["__task__"]["filename"]

  • If command is a multi-line string, split it to individual lines or form a list with single command

  • Iterate over commands list and remove empty strings

  • Iterate over commands and replace new_line_char with \n new line

Next, if interval argument provided commands send one by one to device using napalm_cli task plugin sleeping for given interval between commands. If interval argument is not provided, all commands sent at once.


napalm_send_commands sample usage

Code to invoke napalm_send_commands task:

from nornir_salt.plugins.tasks import napalm_send_commands

output =
    commands=["show run", "show clock"]

Task napalm_send_commands returns Nornir results object with individual tasks names set equal to commands sent to device.

API Reference

nornir_salt.plugins.tasks.napalm_send_commands.napalm_send_commands(task: nornir.core.task.Task, commands=None, interval=None, new_line_char: str = '_br_', split_lines: bool = True)

Nornir Task function to send show commands to devices using napalm_cli task plugin.

Per-host commands can be provided using host’s object data attribute with __task__ key with value set to dictionary with commands key containing a list of or a multiline string of commands to send to device, e.g.:


["ping source", "show clock"]

Alternatively, __task__ can contain filename key with commands string to send to device.

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

  • interval – (int) interval between sending commands, default None

  • new_line_char – (str) characters to replace in commands with new line \n before sending command to device, default is _br_, useful to simulate enter key

  • split_lines – (bool) if True split multiline string to commands, send multiline string to device as is otherwise

Return result

Nornir result object with task results named after commands