Packer: Packer v1.6.3 Bug in Ansible Provisioner - Ansible Galaxy forces use of Collections

Created on 28 Sep 2020  ยท  4Comments  ยท  Source: hashicorp/packer

There seems to be a bug with the Ansible provisioner introduced by PR 9903. This new code forces the galaxy command to run twice, once with roles and once with collections. If no collections are provided, I get:

Executing Ansible Galaxy
ERROR! Expecting requirements file to be a dict with the key 'collections' that contains a list of collections to install

Problem seems to be in these lines.

bug provisioneansible-remote track-internal

Most helpful comment

In case anyone encounters this before the 1.6.5 release and needs a quick solution, just include both in your requirements-file:

# requirements.yml
---
collections: []
roles:
  - name: docker
    src: https://github.com/geerlingguy/ansible-role-docker
    version: '2.9.0'
...

All 4 comments

Hi there - thanks for reaching out. Quickly looking at the source you pointed out I agree that those lines may be the issue. I think if those lines are moved into their respective guard clause the provisioner should work as expected.

    if p.config.RolesPath != "" {
        roleArgs = append(roleArgs, "-p", filepath.ToSlash(p.config.RolesPath))
           if roleInstallError := p.invokeGalaxyCommand(roleArgs, ui, comm); roleInstallError != nil {
         return roleInstallError
               }
    }

         // Similar logic for the CollectionsPath; if set then run the command
        ...
    return nil

Would you like to open a PR and get the credit for the commit, or would you prefer a maintainer do it for you?

Yeah, that sounds good. I'll go ahead and put in the PR.

In case anyone encounters this before the 1.6.5 release and needs a quick solution, just include both in your requirements-file:

# requirements.yml
---
collections: []
roles:
  - name: docker
    src: https://github.com/geerlingguy/ansible-role-docker
    version: '2.9.0'
...

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings