salt.grains.napalm
NAPALM Grains
- codeauthor
-
Mircea Ulinic <ping@mirceaulinic.net>
- maturity
-
new
- depends
-
napalm
- platform
-
unix
Dependencies
NAPALM proxy module
New in version 2016.11.0.
-
Returns the Operating System name running on the network device.
Example: junos, iosxr, eos, ios etc.
CLI Example - select all network devices running JunOS:
salt -G 'os:junos' test.ping
salt.grains.napalm.getos(proxy=None)
-
This grain is set by the NAPALM grain module only when running in a proxy minion. When Salt is installed directly on the network device, thus running a regular minion, the
host
grain provides the physical hostname of the network device, as it would be on an ordinary minion server. When running in a proxy minion,host
points to the value configured in the pillar:NAPALM proxy module
.Note
The diference between
host
andhostname
is thathost
provides the physical location - either domain name or IP address, whilehostname
provides the hostname as configured on the device. They are not necessarily the same.New in version 2017.7.0.
CLI Example:
salt 'device*' grains.get host
Output:
device1: ip-172-31-13-136.us-east-2.compute.internal device2: ip-172-31-11-193.us-east-2.compute.internal device3: ip-172-31-2-181.us-east-2.compute.internal
salt.grains.napalm.host(proxy=None)
-
Return the DNS information of the host. This grain is a dictionary having two keys:
A
AAAA
Note
This grain is disabled by default, as the proxy startup may be slower when the lookup fails. The user can enable it using the
napalm_host_dns_grain
option (in the pillar or proxy configuration file):napalm_host_dns_grain: true
New in version 2017.7.0.
CLI Example:
salt 'device*' grains.get host_dns
Output:
device1: A: - 172.31.9.153 AAAA: - fd52:188c:c068::1 device2: A: - 172.31.46.249 AAAA: - fdca:3b17:31ab::17 device3: A: - 172.31.8.167 AAAA: - fd0f:9fd6:5fab::1
salt.grains.napalm.host_dns(proxy=None)
-
Return the hostname as configured on the network device.
CLI Example:
salt 'device*' grains.get hostname
Output:
device1: edge01.yyz01 device2: edge01.bjm01 device3: edge01.flw01
salt.grains.napalm.hostname(proxy=None)
-
Returns the complete interfaces list of the network device.
Example: ['lc-0/0/0', 'pfe-0/0/0', 'xe-1/3/0', 'lo0', 'irb', 'demux0', 'fxp0']
CLI Example - select all devices that have a certain interface, e.g.: xe-1/1/1:
salt -G 'interfaces:xe-1/1/1' test.ping
Output:
edge01.yyz01: True edge01.maa01: True edge01.syd01: True edge01.del01: True edge01.dus01: True edge01.kix01: True
salt.grains.napalm.interfaces(proxy=None)
-
Returns the network device chassis model.
Example: MX480, ASR-9904-AC etc.
CLI Example - select all Juniper MX480 routers and execute traceroute to 8.8.8.8:
salt -G 'model:MX480' net.traceroute 8.8.8.8
salt.grains.napalm.model(proxy=None)
-
Return the connection optional args.
Note
Sensible data will not be returned.
New in version 2017.7.0.
CLI Example - select all devices connecting via port 1234:
salt -G 'optional_args:port:1234' test.ping
Output:
device1: True device2: True
salt.grains.napalm.optional_args(proxy=None)
-
Returns the chassis serial number.
Example: FOX1234W00F
CLI Example - select all devices whose serial number begins with FOX and display the serial number value:
salt -G 'serial:FOX*' grains.get serial
Output:
edge01.icn01: FOXW00F001 edge01.del01: FOXW00F002 edge01.yyz01: FOXW00F003 edge01.mrs01: FOXW00F004
salt.grains.napalm.serial(proxy=None)
-
Returns the uptime in seconds.
CLI Example - select all devices started/restarted within the last hour:
salt -G 'uptime<3600' test.ping
salt.grains.napalm.uptime(proxy=None)
-
Return the username.
New in version 2017.7.0.
CLI Example - select all devices using foobar as username for connection:
salt -G 'username:foobar' test.ping
Output:
device1: True device2: True
salt.grains.napalm.username(proxy=None)
-
Returns the network device vendor.
Example: juniper, cisco, arista etc.
CLI Example - select all devices produced by Cisco and shutdown:
salt -G 'vendor:cisco' net.cli "shut"
salt.grains.napalm.vendor(proxy=None)
-
Returns the OS version.
Example: 13.3R6.5, 6.0.2 etc.
CLI Example - select all network devices running JunOS 13.3R6.5 and return the model:
salt -G 'os:junos and version:13.3R6.5' grains.get model
Output:
edge01.bjm01: MX2000 edge01.sjc01: MX960 edge01.mrs01: MX480 edge01.muc01: MX240
salt.grains.napalm.version(proxy=None)
© 2021 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltproject.io/en/latest/ref/grains/all/salt.grains.napalm.html