DEV Community

Khadijah (Dana Ordalina)
Khadijah (Dana Ordalina)

Posted on

How to Install a Collection

Top comments (1)

Collapse
 
khadijah profile image
Khadijah (Dana Ordalina)

Once you have found the collection you want to install, it can be installed locally on the control node using

ansible-galaxy collection install <collection>
Enter fullscreen mode Exit fullscreen mode

For our example we’ll be installing the community.MongoDB collection, which can be found in Collections in the Community Namespace here. It can be installed using the following command:

ansible-galaxy collection install community.mongodb
Enter fullscreen mode Exit fullscreen mode

By default it will be installed into your ~/.ansible/collections folder, where it will be added to the stack. This is the default because in general it’s not good practice to include code from a third party in your repository.
Having said this, it is possible to specify different directory like ./collections to keep it with your repo using -p.

ansible-galaxy collection install community.mongodb -p ./collections
Enter fullscreen mode Exit fullscreen mode

After running the above command, you should now see the collections folder in your file tree.