Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

Troubleshooting Junos PyEZ (junos-eznc) Install Errors for Ansible Modules

 

Problem

Description:

During execution of a juniper.device module or a Juniper.junos module, the Ansible control node generates an error that junos-eznc is not installed. For example:

or

Cause

The Juniper Networks Ansible modules in the juniper.device collection and Juniper.junos role use the Junos PyEZ Python library to perform operations on devices running Junos OS. Ansible generates this error if the library is not installed or if Ansible can’t locate the library. Ansible might fail to locate the library, for example, if you install Ansible in a virtual environment or under a Python installation in a non-standard system location and Ansible is searching for the library in a different location like the default system location.

Solution

Install Junos PyEZ on the Ansible control node and update any necessary environment variables. See https://github.com/Juniper/py-junos-eznc#installation for more information.

If you run Ansible using a Python installation in a virtual environment or a non-standard system location, you must:

  • Install Junos PyEZ under the desired Python installation (in the virtual environment or non-standard system location, as appropriate).

  • Specify the path to the Python interpreter—for example, by setting the interpreter_python variable in the Ansible configuration file or by defining the ansible_python_interpreter variable for the appropriate devices in the Ansible inventory file.

    For more information, see Interpreter Discovery in the official Ansible documentation.

To verify that Junos PyEZ is successfully installed on the control node, launch the Python interactive shell using the same Python installation that you use for Ansible operations. Then import the jnpr.junos package.

(venv) user@ansible-cn:~/MyProjects/Ansible$ python3

If you successfully import the jnpr.junos package and there is no error message, then Junos PyEZ is installed on the Ansible control node. If you still see the same error message when you execute the Ansible module, make sure you have specified the correct location for the Python interpreter in your Ansible environment.

Note

You can verify the Python installation that Ansible uses by executing your Ansible playbook with the -vvv option and reviewing the log messages.