Hot answers tagged

26 votes
Accepted

How to avoid interactive dialogs when running "apt-get upgrade -y" in Ubuntu 16.04 when packaging with Packer?

This sequence of commands works for me: apt-get update DEBIAN_FRONTEND=noninteractive apt-get upgrade -yq So, DEBIAN_FRONTEND=noninteractive is correct but you also need the -q flag. Source: https:/...
13 votes

How to avoid interactive dialogs when running "apt-get upgrade -y" in Ubuntu 16.04 when packaging with Packer?

Your problem is that grub file change adhere to ucf and not debconf, as per this incident on apt list you're not alone. As workaround I found this answer on askunbuntu. Removing the menu.lst from the ...
  • 11.1k
10 votes

Is it possible to locate the temp keypair generated by Packer?

First, make sure that packer runs in debug mode (packer build -debug ...), otherwise the temporary key will not be written to disk but will only be kept in memory. packer will store the key in its ...
9 votes
Accepted

What are reasons for using HashiCorp's packer to build docker images instead of using docker build?

Mainly the reason is to keep your image building steps intact if you get to move from docker to another image building system. Packer does support a bunch of providers (builders in packer ...
  • 11.1k
6 votes

Baking Immutable Images

An idea key to your question is that of immutable infrastructure, which is the idea that an image is built once, deployed many times, and never changed at runtime. If the contents of the image need to ...
6 votes
Accepted

How to remotely update AMI id in Jenkins EC2 plugin?

The PR you are linking to contains a link to a python script that does exactly this, since you can run that script from anywhere you can access your Jenkins server.
6 votes
Accepted

How should we automatically rebuild immutable infrastructure when new packages are available?

Part of adopting the Immutable Infrastructure Pattern is decomposing your system into small manageable pieces that can move through CI/CD Pipeline very quickly, this means that OS patches can be done ...
5 votes
Accepted

difference between packer and matchbox

You may use matchbox on a VM as you do on a baremetal machine, you won't be able to use packer on a baremetal machine ont he other hand as it doesn't handle any PXE boot option. That said, leveraging ...
  • 11.1k
5 votes
Accepted

How to run a CMD in a docker container that was created using Packer?

And then I start like this docker run -p 21:21 -it --rm 52c0b0362362 bash This would not work by design. When you run the image with the command above you are instructing Docker to overwrite the CMD ...
  • 371
3 votes

In the HashiCorp stack, where's the appropriate place to add users?

I am less familiar with what Azure offers, but other cloud providers offer a way to manage users external to the VMs the provide (normally IAM permissions). I would not bake user into the system but ...
3 votes

Ansible Remote provisioning not working in Docker container build

It appears that you are trying to run ansible locally inside the container but instead you are running it locally on the machine you use to run packer on(the provisioning one). To run ansible in ...
  • 251
3 votes

Is there an idiomatic way to create reusable Packer templates?

So far, I've taken to defining the default builders and provisioners we use, with user variables interpolated in where required, eg: "type": "amazon-ebs", "instance_type": "t2.micro", "ami_name": "...
  • 1,085
3 votes

Is there an idiomatic way to create reusable Packer templates?

Utilizing the HCL2 syntax is definitely the correct approach here. You can use the different building blocks to define different source blocks and then assign sources to the builders and even ...
  • 321
3 votes
Accepted

Storing Meta Data for Apps/tools

Problems with golden images are that you have to store a full system image with overhead of data which is not build-specific, and using conventions for configuration to make deploy process the same ...
3 votes

Force script to fail if "npm install" has network issues

Try piping your output to grep and then failing based off of the return code of grep: npm install 2>&1 | grep "Error: connect ETIMEDOUT" Per the grep documentation, the exit status is 0 if ...
  • 3,694
3 votes

In the HashiCorp stack, where's the appropriate place to add users?

I would agree with previous statements: avoid baking users into your base image with Packer. Likewise, you should avoid baking them with Terraform as well. Terraform does not provide a mechanism to ...
  • 1,382
3 votes

How to remotely update AMI id in Jenkins EC2 plugin?

Updated the python script from the PR above with: CSRF support to work better with Jenkins 2.x full support for private Jenkins jobs Also I wrote up some usage instructions.
  • 31
3 votes

How to avoid interactive dialogs when running "apt-get upgrade -y" in Ubuntu 16.04 when packaging with Packer?

To add to Philipp's answer, if you are using sudo then you need to make sure to set the DEBIAN_FRONTEND variable afterwards, like so: apt-get update sudo DEBIAN_FRONTEND=noninteractive apt-get ...
3 votes

Baking Immutable Images

Image generation and distribution quickly rises to O(n^2) or higher, and as terraform is explicitly focused on instantiation it relies on external provisioners for internal state. It will work at a ...
  • 366
3 votes
Accepted

How to download a VM image from GCP?

I don't know of a way to get the actual GCE VM images. But it's possible to export the images to GCS (as a tar.gz archive): If you need to move your Compute Engine boot disk data outside of your ...
3 votes

Cannot install Ansible

As it says, No such file or directory: 'gpg', so you probably need to install gnupg before adding the PPA repository: apt-get install gnupg
  • 716
3 votes

How do fail a Packer pipeline upon powershell provisioner pester test failure?

After resolving some syntax issues, I found the true cause of failing to throw the error. In my prior usage I was doing this through Inspec provisioner, which handled the exit codes. If you are ...
2 votes
Accepted

How does using packer and terraform in a CD pipeline compare to docker images built from git?

You're comparing apples with oranges according to your description. A strict comparison could be packer toward dockerfile, and/or terraform toward kubernetes yaml for example. Main difference between ...
  • 11.1k
2 votes

In the HashiCorp stack, where's the appropriate place to add users?

I avoid "baking" user accounts into my OS image with Packer unless there is an OS specific need for it. For example, a service or system account that is needed across all of my deployments. My ...
  • 738
2 votes

Is there an idiomatic way to create reusable Packer templates?

This is what source blocks are for in HCL2. I've been using this approach recently (define builder in a source block, then use it from various build blocks, filling in the variables as needed) and ...
  • 141
2 votes

Is there an idiomatic way to create reusable Packer templates?

Packer has taken an active decision not to build in such capabilities. This problem is much better solved by other tools such as jq, etc. We think the best way to leverage Packer is to wrap it if you ...
2 votes
Accepted

Understanding Vagrant virtual machine import

It looks like that there is a name conflict: The name of your virtual machine couldn't be set because VirtualBox is reporting another VM with that name already exists. Most of the time, this is ...
  • 12.8k
2 votes

Bridged network adapter for Packer + VirtualBox?

With a bridged adapter, your VM would get its IP from the host machine's network DHCP server. This would allow it to be pinged from your internal network. I'd also specify in your configuration that ...
1 vote

DevOps Newbie - How to automate windows infrastructure deployment?

The first thing I can recommend for you is to remove all of the manual steps in your deployment pipeline. DevOps is all about automating as much as possible to allow for fast, frequent, and safe ...
  • 3,053
1 vote

Packer and compressed ISO images

Packer doesn't support compression natively with iso_url, in this sample (Virtualbox builder) doc you can see that compression is not mentioned. So either you continue with your current solution, or ...

Only top scored, non community-wiki answers of a minimum length are eligible