# Ansible collection is installed but playbook can't find it.

**URL:** <https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147>\
**Category:** Ansible Project\
**Tags:** galaxy-ng\
**Created:** [December 22, 2021, 10:18pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147 "2021-12-22T22:18:13Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![nishant\_shah](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nishant\_shah](https://forum.ansible.com/u/nishant_shah)\
**Post date:** [December 22, 2021, 10:18pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/1 "2021-12-22T22:18:13Z")

</div>

Hi,

I am trying to run a simple ansible playbook to create a user in Juniper device.  
[junipernetworks.junos.junos\_user – Manage local user accounts on Juniper JUNOS devices — Ansible Documentation](https://docs.ansible.com/ansible/latest/collections/junipernetworks/junos/junos_user_module.html)

I have all the collection junipernetworks.junos installed-

**[root@localhost ansible-content]# ansible-galaxy collection list | grep juni**  
**junipernetworks.junos 2.8.0**  
**juniper.device 1.0.1**  
**junipernetworks.junos 2.8.0**

But everytime when I try to run the playbook, I get this error-  
**[root@localhost ansible-content]# ansible-playbook playbook-Create\_User.yml**  
**ERROR! ‘junipernetworks.junos.junos\_user’ is not a valid attribute for a Play**

**The error appears to be in ‘/home/ansible-content/playbook-Create\_User.yml’: line 2, column 3, but may**  
**be elsewhere in the file depending on the exact syntax problem.**

**The offending line appears to be:**

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [December 22, 2021, 10:21pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/2 "2021-12-22T22:21:55Z")

</div>

Hi,

> \*[root@localhost ansible-content]# cat playbook-Create\_User.yml----  
> name: Create new user account hosts: all #connection: local  
> junipernetworks.junos.junos\_user: name: ansibleusr role:  
> super-user state: present\*

you need to use the `tasks:` keyword and move the actual task into  
there. This is not a valid playbook (with or without collections).

Something like:

&nbsp;&nbsp;- hosts: all  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- junipernetworks.junos.junos\_user:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: ansibleusr  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;role: super-user  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: present

Cheers,  
Felix

---

<div class="post-metadata">

**Author:** ![nishant\_shah](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nishant\_shah](https://forum.ansible.com/u/nishant_shah)\
**Post date:** [December 22, 2021, 11:28pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/3 "2021-12-22T23:28:52Z")

</div>

THanks Felix for quick response. It is still giving an error **Method not found-**

**I updated my playbook-**  
[root@localhost ansible-content]# cat playbook-Create\_User.yml

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [December 23, 2021, 6:51am UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/4 "2021-12-23T06:51:16Z")

</div>

What is the output of

ansible --version

?

---

<div class="post-metadata">

**Author:** ![Nico\_Kadel-Garcia](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/nico_kadel-garcia/32/9998_2.png) [@Nico\_Kadel-Garcia](https://forum.ansible.com/u/Nico_Kadel-Garcia)\
**Post date:** [December 23, 2021, 3:32pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/5 "2021-12-23T15:32:05Z")

</div>

"ansible --version" no longer reports the version of the "ansible"  
plugin. The version of the software no longer has anything to do with  
the version of the pypo.org published tarball, it's confusing for  
everyone. To check this, use "pip list | grep ansible" or "pip3 list |  
grep ansible", depending on your operating system's base version of  
python.

&nbsp;&nbsp;&nbsp;&nbsp;ansible \< 2.10 actually contains the ansible software  
&nbsp;&nbsp;&nbsp;&nbsp;ansible \>= 2.10 does not contain the ansible software, the name is  
very confusing.

&nbsp;&nbsp;&nbsp;&nbsp;ansible-core \>= 2.10 actually contains the critical software but  
is published via a pypo.org tarball with a new name.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[https://github.com/ansible/ansible/](https://github.com/ansible/ansible/) no longer contains the  
tools for the "ansible" tarball at pypi.org  
&nbsp;&nbsp;&nbsp;&nbsp;That git repo now contains ansible-core source code  
&nbsp;&nbsp;&nbsp;&nbsp;To install ansible commands, use "pip install ansible-core"  
&nbsp;&nbsp;&nbsp;&nbsp;Nearly all python requirements need to reset their  
requirements.txt as "ansible-core" to get the working ansible python  
modules..

This is confusing as hell. I'd love to see the notes or minutes from  
whatever committee decided to do this, but I've asked and it is not  
available.

&nbsp;&nbsp;&nbsp;&nbsp;ansible \> 2.9,\< 4.0 not worth the cycles to a lot has been revised.

&nbsp;&nbsp;&nbsp;&nbsp;ansible \>= 4 is now purely a collection of ansible galaxy modules.  
A modest few of them were formerly in the basic ansible github repo.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[https://github.com/ansible-community/antsibull](https://github.com/ansible-community/antsibull) now contains  
the tools for building ansible tarballs for pip install  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[https://github.com/ansible-collections/](https://github.com/ansible-collections/) now contains the  
source for most of these ansible galaxy modules  
&nbsp;&nbsp;&nbsp;ansible \>= 4 does not contain the ansible software. It requires  
"ansible-core", which does.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The claim published with ansible releases that it "includes"  
the functional ansible tools is misleading, the correct preposition is  
"requires". The working software is actually in the "ansible-core"  
python module.  
&nbsp;&nbsp;&nbsp;&nbsp;ansible == 4 is huge, more than 400 MBytes of installed modules,  
including more than 100 distinct ansible galaxy modules, very few of  
which are commonly used and most of which are useful for most ansible  
servers.  
&nbsp;&nbsp;&nbsp;&nbsp;ansible \>= 4 modules all listed among python modules as  
"aws\_collections" , generally referenced by ansible using the ansible  
galaxy tools rather than as standard python modules.  
&nbsp;&nbsp;&nbsp;&nbsp;ansible \>= 4 modules are available individually with the "ansible  
galaxy" galaxy commands, installed individually and updated or  
reverted individually.  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The "ansible galaxy" command does not install individual  
modules in the same location, it publishes them in /usr/share rather  
than /usr/lib/python/

This is very confusing. Even Red Hat has not been able to keep their  
documentation consistent about this, and they bought ansible.com back  
in 2015. And the release announcements claiming that ansible-core is  
"included" make it more confusing.

As a user of ansible, someone who's set up several Ansible Tower and  
AWX servers myself, I'm game to support update paths. My RPM building  
tools for RHEL systems are available over at:

&nbsp;&nbsp;&nbsp;&nbsp;[https://github.com/nkadel/ansiblerepo/](https://github.com/nkadel/ansiblerepo/)

Nico Kadel-Garcia  
Email: nkadel@gmail.com

---

<div class="post-metadata">

**Author:** ![nishant\_shah](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nishant\_shah](https://forum.ansible.com/u/nishant_shah)\
**Post date:** [December 23, 2021, 5:36pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/6 "2021-12-23T17:36:38Z")

</div>

Hi guys,

Thanks for your response. Here is my Ansible version. It is showing the right location for the collection and I can see the collection junipernetworks.junos is there. While running the playbook it gives me a Method not found. So do you think it might be a bug with this version? If it is I am not going to spent too much time on it which I have already spend.

**[root@localhost ~]# ansible --version**  
[DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the controller starting with  
Ansible 2.12. Current version: 3.6.8 (default, Aug 12 2021, 07:06:15) [GCC 8.4.1 20200928 (Red Hat  
8.4.1-1)]. This feature will be removed from ansible-core in version 2.12. Deprecation warnings can be  
disabled by setting deprecation\_warnings=False in ansible.cfg.  
**ansible [core 2.11.7]**  
**config file = None**  
**configured module search path = [‘/root/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]**  
**ansible python module location = /usr/local/lib/python3.6/site-packages/ansible**  
**ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections**  
**executable location = /usr/local/bin/ansible**  
**python version = 3.6.8 (default, Aug 12 2021, 07:06:15) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)]**  
**jinja version = 2.10.1**  
**libyaml = True**

---

<div class="post-metadata">

**Author:** ![nishant\_shah](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nishant\_shah](https://forum.ansible.com/u/nishant_shah)\
**Post date:** [December 23, 2021, 6:53pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/7 "2021-12-23T18:53:36Z")

</div>

And here is the ansible and ansible-core version-

**[root@localhost ~]# pip3 list | grep ansible**  
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.  
**ansible (4.10.0)**  
**ansible-core (2.11.7)**

---

<div class="post-metadata">

**Author:** ![Rodrigues](https://avatars.discourse-cdn.com/v4/letter/r/8797f3/32.png) [@Rodrigues](https://forum.ansible.com/u/Rodrigues)\
**Post date:** [December 25, 2021, 12:16pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/8 "2021-12-25T12:16:15Z")

</div>

I like to store collections with the playbooks as then it makes sure they wont conflict with others. You can do that with ansible.cfg on your playbook folder.  
Then i also called them on my playbook, similar to this

---

<div class="post-metadata">

**Author:** ![elavarde](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@elavarde](https://forum.ansible.com/u/elavarde)\
**Post date:** [January 3, 2022, 9:18am UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/9 "2022-01-03T09:18:33Z")

</div>

I’m not a specialist in network automation but the docs state “Starting with Ansible 2.5 we recommend using connection: network\_cli or connection: netconf”. Did you try this? Adding more `-v` (up to 5) should also give you more hints on what might be wrong.

---

<div class="post-metadata">

**Author:** ![nishant\_shah](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nishant\_shah](https://forum.ansible.com/u/nishant_shah)\
**Post date:** [January 3, 2022, 6:07pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/10 "2022-01-03T18:07:04Z")

</div>

Thanks for your input. I tried like you said but it is still giving the same error. Can you please point out if I am doing anything wrong.

**- Create ansible.cfg in a working directory where the playbooks are-**

[root@ansiblectrl ansible-content]# cat ansible.cfg  
[defaults]  
**collections\_paths = /root/.ansible/collections**

**- Added collection informations in a playbook**

[root@ansiblectrl ansible-content]# cat playbook-CreateUsers.yml

---

<div class="post-metadata">

**Author:** ![nishant\_shah](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nishant\_shah](https://forum.ansible.com/u/nishant_shah)\
**Post date:** [January 3, 2022, 6:09pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/11 "2022-01-03T18:09:41Z")

</div>

Hi,

Yeah, I am using netconf over the SSH. I am able to update configuration on Juniper devices using roles. But somehow the Ansible can’t find the collection althought it is installed. I am trying to using collections over roles because collections has more varieties.

Thanks,  
Nish

---

<div class="post-metadata">

**Author:** ![Nico\_Kadel-Garcia](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/nico_kadel-garcia/32/9998_2.png) [@Nico\_Kadel-Garcia](https://forum.ansible.com/u/Nico_Kadel-Garcia)\
**Post date:** [January 3, 2022, 6:52pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/12 "2022-01-03T18:52:20Z")

</div>

Installed \*where\* ? How did you install it? With the "pip install"  
command as the root user?

Nico Kadel-Garcia

---

<div class="post-metadata">

**Author:** ![nishant\_shah](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nishant\_shah](https://forum.ansible.com/u/nishant_shah)\
**Post date:** [January 3, 2022, 7:56pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/13 "2022-01-03T19:56:47Z")

</div>

Yes, using pip and ansible-galaxy collection.

**[root@localhost ansible-content]# ansible-galaxy collection list | grep juni**  
**junipernetworks.junos 2.8.0**  
**juniper.device 1.0.1**  
**junipernetworks.junos 2.8.0**

---

<div class="post-metadata">

**Author:** ![elavarde](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@elavarde](https://forum.ansible.com/u/elavarde)\
**Post date:** [January 4, 2022, 1:26pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/14 "2022-01-04T13:26:44Z")

</div>

Perhaps I was unclear but from the look of it, you don’t have an issue finding the collection/module but you have an issue _within_ the module itself. You could try to get some more information using the ANSIBLE\_DEBUG environment variable, else I fear you’ll have to debug the module.

---

<div class="post-metadata">

**Author:** ![Hamza\_Bouabdallah](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@Hamza\_Bouabdallah](https://forum.ansible.com/u/Hamza_Bouabdallah)\
**Post date:** [January 4, 2022, 2:32pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/15 "2022-01-04T14:32:30Z")

</div>

aren’t you missing the “ **tasks:"** directive ? ^^”

just before your **" junipernetworks.junos.junos\_user: "**

---

<div class="post-metadata">

**Author:** ![nishant\_shah](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nishant\_shah](https://forum.ansible.com/u/nishant_shah)\
**Post date:** [January 5, 2022, 8:21pm UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/16 "2022-01-05T20:21:17Z")

</div>

I think it is actually finding the right collection but somehow the playbook is not running. Maybe the playbook I have is not right? Do you have a link to a doc to troubleshoot using the ANSIBLE\_DEBUG environment variable?

**It can see the ansible-doc for that specific collection which I am trying to use-**

**[root@ansiblectrl ansible-content]# ansible-doc-2.7 junipernetworks.junos.junos\_user**  
**\> JUNOS\_USER (/root/.ansible/collections/ansible\_collections/junipernetworks/junos/plugins/modules/junos\_user.py)**

**This module manages locally configured user accounts on remote network devices running the JUNOS operating system.**  
**It provides a set of arguments for creating, removing and updating locally defined accounts**

**\* This module is maintained by The Ansible Community**  
**OPTIONS (= is mandatory):**

**- active**  
**Specifies whether or not the configuration is active or deactivated**  
**[Default: True]**  
**type: bool**

**- aggregate**  
**The `aggregate' argument defines a list of users to be configured on the remote device. The list of users will be**  **compared against the current users and only changes will be added or removed from the device configuration. This**  **argument is mutually exclusive with the name argument.** **(Aliases: users, collection)[Default: (null)]**  **elements: dict**  **suboptions:**  **active:**  **description:**  **- Specifies whether or not the configuration is active or deactivated**  **type: bool**  **encrypted_password:**  **description:**  **- The `encrypted\_password’ argument set already hashed password for the user**  
**account on the remote system.**  
**type: str**  
**full\_name:**  
**description:**  
**- The `full_name' argument provides the full name of the user account to be created**  **on the remote device. This argument accepts any text string value.**  **type: str**  **name:**  **description:**  **- The `name’ argument defines the username of the user to be created on the system. This**  
**argument must follow appropriate usernaming conventions for the target device**  
**running JUNOS. This argument is mutually exclusive with the `aggregate' argument.**  **required: true**  **type: str**  **purge:**  **default: false**  **description:**  **- The `purge’ argument instructs the module to consider the users definition**  
**absolute. It will remove any previously configured users on the device with**  
**the exception of the current defined set of ag**

**Here is my Playbook that I am trying to run-**

**[root@ansiblectrl ansible-content]# cat playbook-CreateUsers.yml**

---

<div class="post-metadata">

**Author:** ![nishant\_shah](https://avatars.discourse-cdn.com/v4/letter/n/2bfe46/32.png) [@nishant\_shah](https://forum.ansible.com/u/nishant_shah)\
**Post date:** [January 8, 2022, 12:45am UTC](https://forum.ansible.com/t/ansible-collection-is-installed-but-playbook-cant-find-it/36147/17 "2022-01-08T00:45:23Z")

</div>

**Hey guys, I found the solution-**

The main issue was “junipernetworks.junos.junos\_user” is created by core Ansible team and not maintained by Juniper team members. Whereas “juniper.device” is created and maintained by Juniper team members which takes API as ansible\_connection=juniper.device.pyez . But that won’t work on junipernetworks.junos.junos\_user.

So the fix is to add following lines in inventory/host file.  
**ansible\_connection=ansible.netcommon.netconf**  
**ansible\_network\_os=junipernetworks.junos.junos**

Thanks to everyone who took the time to help.  
Solved 🙂
