network

Collection of task plugins to work with networks. Primarily useful for testing DNS, host connectivity etc.

Sample usage

Code to invoke network task plugins:

from nornir import InitNornir
from nornir_salt.plugins.tasks import network

nr = InitNornir(config_file="config.yaml")

# resolve host's hostname
answers = nr.run(
    task=network,
    call="resolve_dns"
)

API reference

nornir_salt.plugins.tasks.network.network(task, call, **kwargs) nornir.core.task.Result

Dispatcher function to call one of the functions.

Parameters
  • call – (str) nickname of function to call

  • kwargs – (dict) function key-word arguments

Returns

call function execution results

Call functions:

  • resolve_dns - resolve hostname DNS

nornir_salt.plugins.tasks.network.resolve_dns(task, servers: Union[list, str] = None, use_host_name: bool = False, timeout: float = 2.0, ipv4: bool = True, ipv6: bool = False) nornir.core.task.Result

Function to resolve host’s hostname A and AAAA records.

dnspython package need to be installed for this function to work:

pip install dnspython
Parameters
  • server – list or comma separated string of IP addresses or FQDNs of DNS servers to use

  • use_host_name – if True resolves host’s name instead of host’s hostname

  • timeout – number of seconds to wait for response from DNS server

  • ipv4 – resolve ‘A’ record

  • ipv6 – resolve ‘AAAA’ record

Returns

returns a list of resolved addresses