Troubleshoot Ansible Collection and Module Errors When Managing Junos Devices
Problem
Description
During execution of an Ansible playbook, the control node generates an error that the
juniper.device collection was not found, that no action was detected in
the task, or that the module could not be resolved. For example:
ERROR! couldn't resolve module/action 'juniper.device.facts'. This often indicates a misspelling, missing collection, or incorrect module path.
or
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
Cause
The Ansible control node cannot locate the juniper.device collection and
associated modules.
Solution
The juniper.device collection is hosted on the Ansible Galaxy website. In
order to use the modules in the collection, you must install the collection on the Ansible
control node and also reference it in your playbook.
To install the juniper.device collection on the Ansible control node,
execute the ansible-galaxy collection install command, and specify
juniper.device.
user@ansible-cn:~$ ansible-galaxy collection install juniper.device
If you do not install the collection in the default location, you might need to define the path to it in your Ansible setup. For more information about installing collections and specifying the path, see the official Ansible documentation.
To use the juniper.device collection modules, reference the fully
qualified collection name when you execute a module. For example:
---
- name: Get Device Facts
hosts: junos-all
connection: local
gather_facts: no
tasks:
- name: Get device facts
juniper.device.facts:
savedir: "{{ playbook_dir }}"