Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packer and delegate_to: localhost #202

Open
SolomonHD opened this issue Nov 22, 2024 · 2 comments
Open

Packer and delegate_to: localhost #202

SolomonHD opened this issue Nov 22, 2024 · 2 comments

Comments

@SolomonHD
Copy link

Hello,

I have a play that requires I delegate_to localhost at a certain point to download files on the host and copy them to the remote. My logic works in molecule testing, but it always fails during a Packer run. Is there anything specific I need to do to enable localhost delegation?

@lbajolet-hashicorp
Copy link
Contributor

Hey @SolomonHD,

First of all I want to preface by stating that my knowledge of Ansible or the plugin is quite limited so apologies in advance if I misunderstand something in there.

When you say that the ansible run fails locally, could you share some information on what fails? Typically including a log generated from a failed build with PACKER_LOG=1 enabled in the environment would be best for us to understand what it is you're trying to do. It would also be best if you could share the template you're using to generate those logs, and other related information like the playbooks you're relying on.

Also from what you're saying here, if the goal is to locally get a file from a distant server, I would think you can do this outside of Ansible if this is a problem, through the shell-local provisioner for example.

@SolomonHD
Copy link
Author

Hi @lbajolet-hashicorp,

Essentially what I'm trying to do is run (via the ansible.builtin.command module) ansible-galaxy collection download on my local machine, because I'm downloading collections from a private GitHub instead of Ansible Galaxy and authentication is required. Then upload the collections to the provisioned target with the copy module, then use the unarchive module on the .tar.gz files. Simple logic and it works in my molecule tests as I said earlier.

What's happening with Packer is when I get to the sections of the playbook that should be delegated to localhost, they're still being ran on the provisioned target. So, the error messages I get are related to the wrong path for the ansible-galaxy binary, since I was hard coding it to my local's path.

One option is separating this part of the playbook out and running it in shell-local but I'd rather avoid that if there is another way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants