How to Install Salt for Junos OS
You can use Salt version 3001 (Sodium) or later to manage devices running Junos OS. The Salt master can manage devices running Junos OS through a Salt proxy minion, which can run on either the Salt master or a separate server. You must have one proxy minion per managed device, and each proxy minion requires approximately 40 MB to 100 MB of RAM.
The general installation process is:
On each device running Junos OS:
Enable NETCONF over SSH.
Configure the user account and authentication method that Salt will use to connect to the device.
On the Salt master:
Install Salt and its dependencies.
Define the proxy configuration for each managed device.
Start the salt-master process.
On each Junos proxy minion server:
Install Junos PyEZ and the
jxmlease
andyamlordereddictloader
Python modules.Install Salt and its dependencies, if the server is separate from the Salt master.
Start the Junos proxy minion process for each managed device.
On the Salt master, accept the keys for each Junos proxy minion.
(Optional) Enable the Junos syslog engine (for Salt).
The following sections provide details for each part of the installation process for a server running Ubuntu 18.04. If you are running a different operating system, use the commands appropriate for your OS. We recommend using Python 3.
Configure the Device Running Junos OS
The Junos proxy minion accesses the NETCONF server on devices running Junos OS using the SSH protocol and standard SSH authentication mechanisms. To establish an SSHv2 connection with a device running Junos OS, you must ensure that the following requirements are met:
The NETCONF service over SSH is enabled on each device where a NETCONF session will be established.
The client application has a user account and can log in to each device where a NETCONF session will be established.
The login account used by the client application has an SSH public/private key pair or a text-based password configured.
The client application can access the public/private keys or text-based password.
If you are using SSH keys to authenticate with the device running Junos OS and the keys do not already exist, generate the public and private SSH key pair for the desired user on the proxy minion server, and provide any required or desired options, for example:
saltuser@minion:~$ cd ~/.ssh saltuser@minion:~/.ssh$ ssh-keygen -t rsa -b 2048 Generating public/private rsa key pair. Enter file in which to save the key (/home/saltuser/.ssh/id_rsa): id_rsa_salt Enter passphrase (empty for no passphrase): ***** Enter same passphrase again: *****
To configure the device running Junos OS:
For information about enabling NETCONF on a device running Junos OS and satisfying the requirements for establishing an SSH session, see the NETCONF XML Management Protocol Developer Guide.
See Also
Set Up the Salt Master
The Salt master is the main control server that manages one or more nodes, or minions. SaltStack recommends installing a Salt master on a dedicated management server or virtual machine (VM). You must install Salt Release 3001 (Sodium) or later to manage devices running Junos OS.
To install and configure a Salt master:
Set Up the Junos Proxy Minion Server
You must install the following software on a proxy minion server that will manage devices running Junos OS:
Salt software
Juniper Network’s Junos PyEZ library
jxmlease
andyamlordereddictloader
Python modules
The Junos proxy minion uses the Junos PyEZ library to connect to the device’s NETCONF server and perform management tasks.
If you run the Salt master and Junos proxy minions on the same server, the minion hostname in this section will be identical to the Salt master hostname in the previous section.
To set up a Junos proxy minion on either the Salt master server or a separate server:
The proxy minion connects to the Salt master and sends its public key. The Salt master must accept the key before the Salt master and proxy minion can communicate.
Authorize the Proxy Minion Keys on the Salt Master
Salt uses public keys for authentication with the Salt master process. By default, the Salt master does not authorize any minion or proxy minion keys. You must accept the keys before you can manage the corresponding devices.
You can accept the keys manually, as described in this section.
Alternatively, if you know that the incoming keys do not pose a security
threat, for example, if the salt-master and salt-proxy processes run
on the same server, you can include the auto_accept: True
option in the Salt master configuration
file to accept all incoming keys automatically. For security purposes,
this option is disabled by default.
To list and accept the pending keys:
Verify the Connection to the Managed Device
After accepting the keys on the Salt master, call the test.ping
execution function to ping the proxy minion over the message bus
and verify that the minion is up and communicating. You can specify
a target minion or use '*'
to ping all
minions.
The following example pings the device running Junos OS that is associated with the Junos proxy minion router1.
saltuser@salt-master:~$ sudo salt 'router1' test.ping router1: True
The following example pings all minions that the Salt master manages:
saltuser@salt-master:~$ sudo salt '*' test.ping router1: True router2: True
The following example uses the junos.cli
function to issue the show version
command on the specified
device running Junos OS:
saltuser@salt-master:~$ sudo salt 'router1' junos.cli 'show version' router1: ---------- message: Hostname: router1 Model: mx104 Junos: 18.4R1.8 JUNOS Base OS boot [18.4R1.8] JUNOS Base OS Software Suite [18.4R1.8] JUNOS Crypto Software Suite [18.4R1.8] JUNOS Packet Forwarding Engine Support (TRIO) [18.4R1.8] JUNOS Web Management [18.4R1.8] JUNOS Online Documentation [18.4R1.8] JUNOS SDN Software Suite [18.4R1.8] JUNOS Services Application Level Gateways [18.4R1.8] JUNOS Services COS [18.4R1.8] JUNOS Services Jflow Container package [18.4R1.8] JUNOS Services Stateful Firewall [18.4R1.8] JUNOS Services NAT [18.4R1.8] JUNOS Services RPM [18.4R1.8] JUNOS Services SOFTWIRE [18.4R1.8] JUNOS Services Captive Portal and Content Delivery Container package [18.4R1.8] JUNOS Macsec Software Suite [18.4R1.8] JUNOS Services Crypto [18.4R1.8] JUNOS Services IPSec [18.4R1.8] JUNOS DP Crypto Software Software Suite [18.4R1.8] JUNOS py-base-powerpc [18.4R1.8] JUNOS py-extensions-powerpc [18.4R1.8] JUNOS jsd [powerpc-18.4R1.8-jet-1] JUNOS Kernel Software Suite [18.4R1.8] JUNOS Routing Software Suite [18.4R1.8] out: True
If you encounter the error 'junos' __virtual__
returned False: The junos or dependent module could not be loaded:
junos-eznc or jxmlease or yamlordereddictloader or proxy could not
be loaded
, the Junos proxy minion server might not
have Junos PyEZ or the jxmlease
or yamlordereddictloader
modules installed, or the Junos
proxy minion process might not be running or it can’t authenticate
with the device.
(Optional) Configure the Junos Syslog Engine
The Junos syslog engine (for Salt) can be used for event-based state management of devices running Junos OS. When you enable the Junos syslog engine, it listens for syslog events, extracts the event information, translates it to Salt format, and publishes it on the Salt event bus. To enable the Junos syslog engine, you must configure the Junos syslog engine on the Salt master, and you must also configure the device running Junos OS to send syslog events to the configured port on the Salt server.
The Junos syslog engine can also run on the proxy minion server.
To enable the Junos syslog engine on the Salt master:
To configure the device running Junos OS to send syslog events to the host on which the Junos syslog engine is running:
Configure the hostname or IP address of the server on which the Junos syslog engine is running, and configure the port on which it is listening.
[edit] saltuser@router1# set system syslog host salt-master.example.com port 9999
Configure the types of events to send.
To send all events, configure
any any
to indicate all facilities and all message severity levels.[edit] saltuser@router1# set system syslog host salt-master.example.com any any
To send only specific events, configure the facility and message severity level of the events to capture, for example:
[edit] saltuser@router1# set system syslog host salt-master.example.com kernel info saltuser@router1# set system syslog host salt-master.example.com security any
Commit the configuration.
[edit] saltuser@router1# commit