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
The functions from the proxy minion can be run from the salt commandline using
the salt.modules.nxos
execution module.
salt.proxy.nxos.
add_config
(lines)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.
salt.proxy.nxos.
check_password
(username, password, encrypted=False)Check if passed password is the one assigned to user
salt.proxy.nxos.
check_role
(username, role)Check if user is assigned a specific role on switch
salt '*' nxos.cmd check_role username=admin role=network-admin
salt.proxy.nxos.
delete_config
(lines)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.
salt.proxy.nxos.
find
(pattern)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.
salt.proxy.nxos.
remove_user
(username)Remove user from switch
salt '*' nxos.cmd remove_user username=daniel
salt.proxy.nxos.
replace
(old_value, new_value, full_match=False)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'
salt.proxy.nxos.
set_password
(username, password, encrypted=False, role=None, crypt_salt=None, algorithm='sha256')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
salt.proxy.nxos.
set_role
(username, role)Assign role to username
salt '*' nxos.cmd set_role username=daniel role=vdc-admin