image image image image image

On This Page

Salt is a different approach to infrastructure management, founded on the idea that high-speed communication with large numbers of systems can open new capabilities. This approach makes Salt a powerful multitasking system that can solve many specific problems in an infrastructure.

The backbone of Salt is the remote execution engine, which creates a high-speed, secure and bi-directional communication net for groups of systems. On top of this communication system, Salt provides an extremely fast, flexible, and easy-to-use configuration management system called Salt States.

For a list of Salt’s Napalm supported modules, please refer to the NAPALM-Onyx github repository.

Installing SaltStack on CentOS 7

  1. Install Salt packages: 

    curl -L https://bootstrap.saltstack.com -o install_salt.sh
    sudo sh install_salt.sh -P -M
    yum install -y salt-master salt-minion salt-ssh salt-syndic salt-cloud salt-api
  2. Install the Napalm library.

    yum install epel-release
    yum install -y python-pip
    yum install libxml2-devel libxslt-devel zlib-devel gcc openssl-devel libffi-devel python-devel
    pip install pyzmq --install-option="--zmq=bundled"
    pip install napalm

Configuring Salt

  1. Open the /etc/salt/master file.
  2. Replace #interface: 0.0.0.0 with interface: <machine_ip>.
  3. Replace #hash_type: md5 with hash_type: sha256.
  4. Find file_roots and pillar_rootsand and add the following lines below them:
  5. Save and quit by entering: wq
  6. Restart the Salt-master file:

    sudo systemctl start salt-master.service
    sudo systemctl enable salt-master.service

Configuring the Salt-minion File

After the installation, modify the /etc/salt/minion configuration file as below:

  1. Open the /etc/salt/minion file.
  2. Replace #master: salt with master: 10.99.0.10.
  3. Replace #hash_type: md5 with: hash_type: sha256.
  4. Save and quit by entering: wq
  5. Restart and enable Salt-minion.

    sudo systemctl start salt-minion.service

Configuring the Proxy

  1. Run /etc/salt/proxy.
  2. Find the below attributes and fill them out as shown below:

Creating the pillar Directory

  1. Create a pillar directory under /etc/salt.

    mkdir -r /etc/salt/pillar
  2. Go to the /etc/salt/pillar directory

  3. Create the top.sls file inside this directory.

    Per each switch, insert the following information:

    DEVICE_ID

    DEVICE_SLS_FILENAME

  4. Create a new file: [DEVICE_SLS_FILENAME].sls
    Insert the following information into the above file: 

    proxy:
    	proxytype: napalm
    	driver: [DRIVER]
    	host: [HOSTNAME]
    	username: [USERNAME]
    	passwd: [PASSWORD]

    Example:

    proxy:
    	proxytype: napalm
    	driver: onyx_ssh
    	host: 10.209.37.247
    	username: admin
    	passwd: admin
       propt_name: switch20
       ssh_args:‘-0 PubkeyAuthentication=no’
  5. Restart Salt on the server in order to use the new configuration
    systemctl stop salt-minion 
    systemctl stop salt-master 
    systemctl stop salt-proxy@<switch_name>
    systemctl start salt-master 
    systemctl start salt-minion 
    systemctl start salt-proxy@<switch_name>

Running Onyx Salt Commands on the Server

The following Salt command can be used:

  1. Check if the switch is connected to the server running the Salt master:

    salt onyx1 net.connected 
  2. Run any command on the switch using net.cli (example: using “show version”):

    salt onyx1 net.cli 'show version'
  3. Get the switch mac address:

    salt onyx1 net.mac  
  4. Get the switch arp table:

    salt onyx1 net.arp  
  5. Get switch information (uptime, vendor, os-version, etc):

    salt onyx1 net.facts  
  6. Get the switch interfaces details:

    salt onyx1 net.interfaces