Proxy Minion for Cisco NX OS Switches
The Cisco NX OS Proxy Minion uses the built in SSHConnection module in salt.utils.vt_helper
To configure the proxy minion:
proxy: proxytype: nxos host: 192.168.187.100 username: admin password: admin prompt_name: switch ssh_args: '-o PubkeyAuthentication=no' key_accept: True
(REQUIRED, this or prompt_name above, but not both) A regular expression that matches the prompt on the switch and any other possible prompt at which you need the proxy minion to continue sending input. This feature was specifically developed for situations where the switch may ask for confirmation. prompt_name above would not match these, and so the session would timeout.
Example:
dc01-switch-01#.*|\(y\/n\)\?.*
This should match
dc01-switch-01#
or
Flash complete. Reboot this switch (y/n)? [n]
If neither prompt_name nor prompt_regex is specified the prompt will be defaulted to
.+#$
which should match any number of characters followed by a # at the end of the line. This may be far too liberal for most installations.
The functions from the proxy minion can be run from the salt commandline using the salt.modules.nxos
execution module.
Add one or more config lines to the switch running config
salt '*' nxos.cmd add_config 'snmp-server community TESTSTRINGHERE group network-operator'
Note
For more than one config added per command, lines should be a list.
Check if passed password is the one assigned to user
Check if user is assigned a specific role on switch
salt '*' nxos.cmd check_role username=admin role=network-admin
Delete one or more config lines to the switch running config
salt '*' nxos.cmd delete_config 'snmp-server community TESTSTRINGHERE group network-operator'
Note
For more than one config deleted per command, lines should be a list.
Find all instances where the pattern is in the running command
salt '*' nxos.cmd find '^snmp-server.*$'
Note
This uses the re.MULTILINE regex format for python, and runs the regex against the whole show_run output.
Get roles that the username is assigned from switch
Get username line from switch
Get grains for proxy minion
Refresh the grains from the proxy device.
Required. Can be used to initialize the server connection.
Ping the device on the other end of the connection
Remove user from switch
salt '*' nxos.cmd remove_user username=daniel
Replace string or full line matches in switch's running config
If full_match is set to True, then the whole line will need to be matched as part of the old value.
salt '*' nxos.cmd replace 'TESTSTRINGHERE' 'NEWTESTSTRINGHERE'
Run command through switch's cli
Set users password on switch
salt '*' nxos.cmd set_password admin TestPass salt '*' nxos.cmd set_password admin \ password='$5$2fWwO2vK$s7.Hr3YltMNHuhywQQ3nfOd.gAPHgs3SOBYYdGT3E.A' \ encrypted=True
Assign role to username
salt '*' nxos.cmd set_role username=daniel role=vdc-admin
Shortcut to run show run on switch
salt '*' nxos.cmd show_run
Shortcut to run show ver on switch
salt '*' nxos.cmd show_ver
Disconnect
Return system information for grains of the NX OS proxy minion
salt '*' nxos.system_info
Remove role from username
salt '*' nxos.cmd unset_role username=daniel role=vdc-admin
© 2019 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltstack.com/en/latest/ref/proxy/all/salt.proxy.nxos.html