packer-plugin-ansible icon indicating copy to clipboard operation
packer-plugin-ansible copied to clipboard

ansible-local provisioner installs galaxy roles to <staging dir>/galaxy_roles/ but does not add that to Ansible's role path

Open isuftin opened this issue 3 years ago • 4 comments

Overview of the Issue

The latest Packer 1.8.3 is using the latest release of this plugin. It seems like the latest release of this plugin via ansible-local now installs roles to /galaxy_roles/...

But when running a playbook via ansible-local, that path is not included in the Ansible role paths

Packer 1.8.3 with error:

...
2022-08-04T20:46:12Z:     amazon-ebs: - downloading role 'ntp', owned by geerlingguy
2022-08-04T20:46:13Z:     amazon-ebs: - downloading role from https://github.com/geerlingguy/ansible-role-ntp/archive/2.3.1.tar.gz
2022-08-04T20:46:13Z:     amazon-ebs: - extracting geerlingguy.ntp to /tmp/packer-provisioner-ansible-local/62ec2e12-8f77-0531-c4d6-e3bb20d3ec92/galaxy_roles/geerlingguy.ntp
2022-08-04T20:46:13Z:     amazon-ebs: - geerlingguy.ntp (2.3.1) was installed successfully
...

2022-08-04T20:46:37Z:     amazon-ebs: TASK [ntp | Set variables for ntp role] ****************************************
2022-08-04T20:46:37Z:     amazon-ebs: ok: [127.0.0.1]
2022-08-04T20:46:37Z:     amazon-ebs:
2022-08-04T20:46:37Z:     amazon-ebs: TASK [ntp | Set up NTP] ********************************************************
2022-08-04T20:46:37Z:     amazon-ebs: ERROR! the role 'geerlingguy.ntp' was not found in /tmp/packer-provisioner-ansible-local/62ec2e12-8f77-0531-c4d6-e3bb20d3ec92/roles:/home/ec2-user/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/tmp/packer-provisioner-ansible-local/62ec2e12-8f77-0531-c4d6-e3bb20d3ec92
2022-08-04T20:46:37Z:     amazon-ebs: 
2022-08-04T20:46:37Z:     amazon-ebs: The error appears to be in '/tmp/packer-provisioner-ansible-local/62ec2e12-8f77-0531-c4d6-e3bb20d3ec92/site.yml': line 29, column 15, but may
2022-08-04T20:46:37Z:     amazon-ebs: be elsewhere in the file depending on the exact syntax problem.
2022-08-04T20:46:37Z:     amazon-ebs: 
2022-08-04T20:46:37Z:     amazon-ebs: The offending line appears to be:
2022-08-04T20:46:37Z:     amazon-ebs: 
2022-08-04T20:46:37Z:     amazon-ebs:       ansible.builtin.include_role:
2022-08-04T20:46:37Z:     amazon-ebs:         name: geerlingguy.ntp
2022-08-04T20:46:37Z:     amazon-ebs:               ^ here

Packer 1.8.2 working as expected:

...
2022-07-22T21:15:24Z:     amazon-ebs: - downloading role 'ntp', owned by geerlingguy
2022-07-22T21:15:26Z:     amazon-ebs: - downloading role from https://github.com/geerlingguy/ansible-role-ntp/archive/2.3.1.tar.gz
2022-07-22T21:15:27Z:     amazon-ebs: - extracting geerlingguy.ntp to /tmp/packer-provisioner-ansible-local/62db122b-92aa-f998-3a08-88fa0c876275/roles/geerlingguy.ntp
2022-07-22T21:15:27Z:     amazon-ebs: - geerlingguy.ntp (2.3.1) was installed successfully
...
2022-07-22T21:16:00Z:     amazon-ebs: TASK [ntp | Set up NTP] ********************************************************
2022-07-22T21:16:00Z:     amazon-ebs:
2022-07-22T21:16:00Z:     amazon-ebs: TASK [geerlingguy.ntp : Include OS-specific variables.] ************************
2022-07-22T21:16:00Z:     amazon-ebs: ok: [127.0.0.1]
2022-07-22T21:16:00Z:     amazon-ebs:
2022-07-22T21:16:00Z:     amazon-ebs: TASK [geerlingguy.ntp : Set the ntp_driftfile variable.] ***********************
2022-07-22T21:16:00Z:     amazon-ebs: ok: [127.0.0.1]
2022-07-22T21:16:00Z:     amazon-ebs:
...

...

Reproduction Steps

Configuration to run ansible-local:

{
      "type": "ansible-local",
      "playbook_dir": "ansible_playbook",
      "playbook_files": ["ansible_playbook/site.yml"],
      "galaxy_file": "ansible_playbook/requirements.yml",
}

Galaxy file:

- src: geerlingguy.ntp
  version: 2.3.1

site.yml:

---
- name: EC2 Provisioning
  hosts: all
  tasks:
    - name: ntp | Set up NTP
      ansible.builtin.include_role:
        name: geerlingguy.ntp
        apply:
          become: true

Remote system's ansible.cfg:

[defaults]
log_path = /var/log/ansible.log
ansible_python_interpreter = /bin/python3
nocows = True
fact_caching = jsonfile
fact_caching_connection = /tmp/facts_cache
fact_caching_timeout = 7200

Remote system is a AWS Marketplace RHEL 8 - ami-08970fb2e5767e3b8 Remote system has Python3.6 and Ansible 4.10.0 installed

Plugin and Packer version

1.8.3

Is no one else getting this?

isuftin avatar Aug 04 '22 21:08 isuftin

@QDespeisseTalan your attached log shows your api key, remove it.

GuilhermeFAC avatar Sep 16 '24 18:09 GuilhermeFAC

We get this information from the config.openshift.io/Ingress resource in [ibm.mas_devops.suite_dns : cloudflare : Get cluster subdomain] task:

From the logs can see that in this cluster it reports:

    spec:
      domain: apps.65e73b7612697b001299b3e7.cloud.techzone.ibm.com
      loadBalancer:
        platform:
          type: ''

I don't think there's any way we can know that a cluster has non-standard DNS setup OOTB, e.g. in this case needing router-default subdomain prefixed. We would have to add an override for this, e.g. supporting an OCP_HOSTNAME to manually override the default behaviour, which would allow the role to function on clusters where the cluster domain does not resolve to the cluster.

durera avatar Jan 18 '25 23:01 durera