geerlingguy / packer-boxes

Jeff Geerling's Packer build configurations for Vagrant boxes.

Home Page:https://app.vagrantup.com/geerlingguy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How and where are roles: geerlingguy.* obtained?

basictheprogram opened this issue · comments

If you have the time can you explain to me how Ansible knows where to get your geerlingguy.* roles?

For example in shared/main.yml I see these roles

  roles:
    - role: geerlingguy.nfs

    - role: geerlingguy.packer_rhel
      when: ansible_os_family == 'RedHat'

    - role: geerlingguy.packer-debian
      when: ansible_os_family == 'Debian'

Looking in the shared/requirements.yml I do not see any hostname or url.

In ubuntu2004/box-config.json I see the ansible-local variables playbook_file and galaxy_file so it hints that the role is coming from Galaxy.

    {
      "type": "ansible-local",
      "playbook_file": "../shared/main.yml",
      "galaxy_file": "../shared/requirements.yml"
    }

Does the version of Ansible downloaded from the ppa (scripts/ansible.sh) have defaults on where to look for your roles?

I am trying to build on your work for VMware Fusion and installing the official Ansible release from Ubuntu 20.04 (https://packages.ubuntu.com/focal/ansible) with apt (not with pip or from ppa) and the official package does not know how to retrieve your roles.

==> vmware-iso: ERROR! the role 'geerlingguy.java' was not found in /tmp/packer-provisioner-ansible-local/5eb730dc-7a87-341c-c2c7-3ee2f6c3842e/roles:/home/vagrant/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/tmp/packer-provisioner-ansible-local/5eb730dc-7a87-341c-c2c7-3ee2f6c3842e
==> vmware-iso: 
==> vmware-iso: The error appears to be in '/tmp/packer-provisioner-ansible-local/5eb730dc-7a87-341c-c2c7-3ee2f6c3842e/testing.yml': line 12, column 7, but may
==> vmware-iso: be elsewhere in the file depending on the exact syntax problem.
==> vmware-iso: 
==> vmware-iso: The offending line appears to be:
==> vmware-iso: 
==> vmware-iso:   roles:
==> vmware-iso:     - role: geerlingguy.java
==> vmware-iso:       ^ here

I am still a user of Ansible 2.9 and not familiar with Galaxy and Collections and example/ansible.cfg from the devel branch in GitHub does not have references to any of this information so I’m looking for assistance.

Thank you.

@basictheprogram - Packer itself should be picking up the role requirements and installing them in the correct path so Ansible running in the VM can use them; see these lines https://github.com/geerlingguy/packer-boxes/blob/master/ubuntu2004/box-config.json#L16-L20

If that is not the case, then something seems incorrect in the Packer configuration, or the playbook you're using, maybe. It seems like you're using a playbook testing.yml which I don't think comes from this repository.

The geerlingguy.java role is not referenced in this project at all, so it seems that may be something you're adding to your testing.yml playbook? If so, you need to make sure you're also adding the requirement for it to the requirements.yml file in the shared directory (assuming you are using the same kind of layout as this project uses). Otherwise, Packer's invocation of ansible-galaxy install -r ../shared/requirements.yml will not install the geerlingguy.java role inside the VM when it is building it.

testing.yml

---
    - hosts: all
      gather_facts: yes
      tasks:
        - ping:

I think the advise about the requirements.yml will help. Let me play around with that. Thank you for your assistance.

You're welcome!