Troubleshoot Ansible Collection, Role, 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 or Juniper.junos
role was
not found, that no action was detected in the task, or that the module
could not be resolved. For example:
ERROR! the role 'Juniper.junos' was not found in /usr/share/ansible/roles:/etc/ansible/roles ...
or
ERROR! no action detected in task. This often indicates a misspelled module name, or incorrect module path.
or
ERROR! couldn't resolve module/action 'facts'. This often indicates a misspelling, missing collection, or incorrect module path.
Cause
The Ansible control node cannot locate the juniper.device
collection or the Juniper.junos
role and associated modules.
Solution
The juniper.device
collection
and Juniper.junos
role are hosted on the
Ansible Galaxy website. In order to use the modules in the collection
or role, you must install the collection or role 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:~$ sudo ansible-galaxy collection install juniper.device
To install the Juniper.junos
role on the Ansible control node, execute the ansible-galaxy
install
command, and specify Juniper.junos
.
user@ansible-cn:~$ sudo ansible-galaxy install Juniper.junos
If you do not install the collection or role in the default location, you might need to define the path to it in your Ansible setup. For more information about installing collections and roles 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 }}"
To use the Juniper.junos
role
modules, you must include the role in the playbook play. For example:
--- - name: Get Device Facts hosts: junos-all connection: local gather_facts: no roles: - Juniper.junos tasks: - name: Get device facts juniper_junos_facts: savedir: "{{ playbook_dir }}"