Sometimes, there’s a package that must be installed on a node; sadly, this is one of those times. So, now I need to run Packer in a gitlab pipeline.
The expected result would be that the pipeline could be put on a schedule and fresh AMIs would be ready every moring for testing.
Here’s what I’ve done so far:
- Packer config runs locally: pass
- AWS Auth: pass
- Packer config runs in the pipeline without provisioner: pass
- Packer config runs in the pipeline with Bash provisioner: pass
- Packer config runs in the pipeline with Ansible provisioner: fail (with image:(latest|full))
Pipeline output:
...
$ packer --version
Packer v1.11.2
$ packer init .
Installed plugin github.com/hashicorp/ansible v1.1.1 in "/root/.config/packer/plugins/github.com/hashicorp/ansible/packer-plugin-ansible_v1.1.1_x5.0_linux_amd64"
Installed plugin github.com/hashicorp/amazon v1.3.2 in "/root/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.3.2_x5.0_linux_amd64"
$ packer build aws-amazonlinux.pkr.hcl
Error: Failed preparing provisioner-block "ansible" ""
on aws-amazonlinux.pkr.hcl line 23:
(source code not available)
1 error(s) occurred:
* Error running "ansible-playbook --version": exec: "ansible-playbook":
executable file not found in $PATH
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1
Is there an official container image with packer+ansible?
In the .gitlab-ci.yml
config, only one image can be called out: Packer OR Ansible.
In this case, of course both Packer AND Ansible would be required.
I see a lot of very creative solutions out there that all make me think I’m missing something very simple - so thought I’d ask before rebuilding a world that already existed.
In the case there is no image to support these requirements, would there be a community recommendation on a course of action?
More looking for what should be done (an elegant solution), rather than what could be done(sketchy stuff I’ve found so far).
TIA