Issue: Fix “network os junipernetworks.junos.junos is not supported” error when using ansible_network_os=junipernetworks.junos.junos
With the transfer of Ansible support for Junos devices from the junipernetworks.junos collection to the new juniper.device collection, most modules were redirected using meta/runtime.yml. This ensured backward compatibility for playbooks that still invoked modules from junipernetworks.junos.
plugin_routing:
modules:
junos_command:
redirect: juniper.device.junos_command
This worked fine for modules because Ansible’s module loader honors plugin_routing.
But, when using inventory with:
[junos]
x.x.x.x
[junos:vars]
ansible_connection=ansible.netcommon.network_cli
ansible_network_os=junipernetworks.junos.junos
ansible_user=xxxxx
ansible_ssh_pass=xxxx
Running a playbook failed with:
playbook:
---
- name: Run junos
hosts: junos
gather_facts: false
tasks:
- name: Get available interfaces
junipernetworks.junos.junos_command:
commands:
- show version
register: interfaces_output
- name: Display available interfaces
ansible.builtin.debug:
var: interfaces_output.stdout_lines
- name: Run command module
junipernetworks.junos.junos_command:
commands:
- show configuration
register: output
Error:
"msg": "network os junipernetworks.junos.junos is not supported"
However, changing the inventory to ansible_network_os=juniper.device.junos, allowed the playbook to run successfully.
So, the root cause is how plugin resolution works in Ansible:
meta/runtime.yml plugin_routing* is only applied to:
- modules
- module_utils
- action plugins
- filter/lookup plugins
That’s why entries like:
junos_command:
redirect: juniper.device.junos_command
successfully redirect the module calls.
However, ansible_network_os is handled by connection plugins (network_cli, netconf).
When you set ansible_network_os=junipernetworks.junos.junos in inventory, the network_cli plugin, tries to find a cliconf and terminal plugin named exactly junipernetworks.junos.junos.
self.cliconf = cliconf_loader.get(self._network_os, self)
self._terminal = terminal_loader.get(self._network_os, self)
no redirect mechanism works here, no call into meta/runtime.yml, so the loader returns None, and network_cli errors with: network os junipernetworks.junos.junos is not supported
The fix in PR #767 - Juniper/ansible-junos-stdlib#767 adds plugins:
- junipernetworks/junos/plugins/cliconf/junos.py
- junipernetworks/junos/plugins/terminal/junos.py
Each plugin simply subclasses the real implementation from juniper.device.
Now, when network_cli does cliconf_loader.get("junipernetworks.junos.junos"), it finds a valid plugin and loads it successfully.
The same applies for terminal_loader.
This solves the reported issue and i have attached logs of successful run as well here.