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
Ansible provisioner does not work and no artifacts are created. #20
Comments
Hi @MiyamotoTa, thanks for reporting this! Could you share part of your Packer image configuration? It looks like you're using the Shell provisioner, rather than the Ansible (local) provisioner (see here) - any specific reason for this? |
Hi, @ksatirli I uploaded the example.pkr.hcl file to gist. Let me know if I can give you any other information. The reason for using the Shell provisioner is not really necessary, as the packer quick start was still there. |
@ksatirli I've always understood that you need to install Ansible on the machine you're running packer on to use the ansible provisioner. It is not installed in either the base packer docker image or the docker image created for this action therefor it doesn not exist in in the container hence the In addition, there are many ansible modules that require additional python libraries to be pre-installed on the machine running the ansible playbook. This is another complication. |
I'm having the same issue even though I'm installing the pip package from GitHub action
|
@oba11 The packer GitHub action runs inside a docker container that runs inside the GitHub Action runner instance. You're workflow is installing Ansible in the runner instance but since packer runs inside Docker inside your runner packer cannot access your Ansible installation. I worked around this myself by creating my own Docker based action inside our packer repo and using the code in this repo as a base and then editing the Dockerfile to also install ansible and any libs we need. I'm not sure how else you would be able to work around this limitation. |
I'm having the same issue. |
That was my experience. |
@ksatirli I'm curious is there a reason the packer team is going the route of running packer inside a container instead of creating an action similar to the |
Hi, any updates on this issue ? |
I've been solving this issue by updating the docker images, you can use the forked version here https://github.com/pintu-crypto/packer-github-actions the changes of the docker images can be checked here 2pai/docker-hub-images@a533128 or if you want to build the image by yourself |
Ah ! Saw your reply too late :) I ended up doing this : - run: 'sudo apt-get install -y ansible'
shell: bash
# NB: will only work with ubuntu 20.04
- uses: myci-actions/add-deb-repo@10
with:
repo: deb [arch=amd64] https://apt.releases.hashicorp.com focal main
keys-asc: https://apt.releases.hashicorp.com/gpg
update: true
install: packer
- name: Validate Template
uses: hashicorp/packer-github-actions@master
with:
command: validate
arguments: -syntax-only
target: infra/packer
- run: 'packer init .'
- run: 'packer build somefile.pkr.hcl' |
Thanks for this. I am rolling with my own, but your Fork gave me the inspiration I needed :) |
Hi all, I figured out a work-around. It worked for me I am not sure. How far it will help the rest. This is the github-actions i created for my purpose.
|
Above I am using a docker image in which the packer and ansible is installed. This method will reduce the execution time compared to installing the packer and ansible in the runner. You can build your own docker image (publicly available) and mention it in the yaml script. Dockerfile:
|
Hi! I create this PR with the fix and include others #52 |
This action does not currently support the ansible-provisioner See hashicorp/setup-packer#20
this issue is not solved yet :) |
Heads up for anyone dealing with this. Packer and Ansible are now included software in the default GitHub actions Ubuntu runners so you should be able to just call packer to complete your builds. If your using Windows it looks like there is packer but not Ansible so you would need to install that on the runner before running your build. |
Expected Behavior
Able to build AMI using the ansible provisioner.
Current Behavior
Ansible provisioner does not work, and no artifacts are created.
Steps to Reproduce
The build that is executed on GitHubActions using the Ansible provider always fails.
Environment
1.) Link to a Gist of your Workflow configuration:
https://gist.github.com/MiyamotoTa/705b18449165f7472f42382adfe4807c
2.) Any other relevant environment information:
Running the same code on a local machine can build the AMI.
Local packer version: v1.7.2
The text was updated successfully, but these errors were encountered: