Skip to content

Instantly share code, notes, and snippets.

@Ruchip16
Created August 30, 2025 19:17
Show Gist options
  • Save Ruchip16/c2c5ea7783f70c76e54b873bf6a62136 to your computer and use it in GitHub Desktop.
Save Ruchip16/c2c5ea7783f70c76e54b873bf6a62136 to your computer and use it in GitHub Desktop.
fix_network_os_error in junipernetworks.junos.junos collection in ansible-junos-stdlib

Issue: Fix “network os junipernetworks.junos.junos is not supported” error when using ansible_network_os=junipernetworks.junos.junos

Background

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.

Example redirect in meta/runtime.yml:

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.


Explanation

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

Why adding the plugins works here?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment