3
---
roles:
    -
        name: Aplyca.S3fs
    -
        name: badpacketsllc.aws_cli
        version: v1.0.3
    -
        name: geerlingguy.nodejs
        version: 5.1.1
    -
        name: geerlingguy.filebeat
        version: 3.0.2
    -
        name: geerlingguy.pip
        version: 2.0.0

collections:
    -   name: nginxinc.nginx_core
        version: 0.1.3

Result

ansible-galaxy install -r galaxy.yml -p ./roles
[WARNING]: - Aplyca.S3fs (master) is already installed - use --force to change version to unspecified
- badpacketsllc.aws_cli (v1.0.3) is already installed, skipping.
- geerlingguy.nodejs (5.1.1) is already installed, skipping.
- geerlingguy.filebeat (3.0.2) is already installed, skipping.
- geerlingguy.pip (2.0.0) is already installed, skipping.

This is my file and this is the command I run to install roles and collections.

ansible-galaxy install -r galaxy.yml -p ./roles

I am using Ansible 2.9.13

I don't see what is wrong in my file, here is the official doc. https://docs.ansible.com/ansible/latest/user_guide/collections_using.html

---
roles:
  # Install a role from Ansible Galaxy.
  - name: geerlingguy.java
    version: 1.9.6

collections:
  # Install a collection from Ansible Galaxy.
  - name: geerlingguy.php_roles
    version: 0.9.3
    source: https://galaxy.ansible.com
tom10271
  • 4,222
  • 5
  • 33
  • 62

1 Answers1

2

To install both roles and collections at the same time with one command, run the following:

ansible-galaxy install -r galaxy.yml

Installing both roles and collections from the same requirements file will not work when specifying a custom collection or role install path. In this scenario the collections will be skipped and the command will process each like ansible-galaxy role install would.

Then you need install collections with this command

ansible-galaxy collection install -r galaxy.yml -p ./roles

Documentation:

https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#install-multiple-collections-with-a-requirements-file

gary lopez
  • 1,823
  • 7
  • 15
  • Here is the official document - To install both roles and collections at the same time with one command, run the following: `ansible-galaxy install -r requirements.yml` I think it is likely a bug, your command is to bypass the limit only – tom10271 Nov 12 '20 at 06:39
  • You're right, To install both roles and collections at the same time with one command, run the following: `ansible-galaxy install -r requirements.yml` but there is a note: Installing both roles and collections from the same requirements file will not work when specifying a custom collection or role install path. In this scenario the collections will be skipped and the command will process each like `ansible-galaxy role install` would. Link: https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#install-multiple-collections-with-a-requirements-file I'll edit my anwer. – gary lopez Nov 12 '20 at 13:59