Feb 24, 2024 10:50 am
One of the problems I have ran into with Packer building from a CI/CD pipeline using GitLab is the pipeline would fail due to the enormous amount of time it would take to apply updates. The pipeline would fail.
A quick way to avoid installing updates is to disable the ability for the build to pull updates. In your user-data http file, you can use the following snippet:
early-commands:
- |
echo $(dig +short geoip.ubuntu.com | grep -v '\.$' | head -1) geoip.ubuntu.com >>/etc/hosts
sed -i '/^nameserver /d' /etc/resolv.conf
In context, you can place it here (under the apt section and before the users section).
#cloud-config
autoinstall:
version: 1
apt:
fallback: offline-install
geoip: true
preserve_sources_list: false
primary:
- arches: [amd64, i386]
uri: http://gb.archive.ubuntu.com/ubuntu
- arches: [default]
uri: http://ports.ubuntu.com/ubuntu-ports
early-commands:
- |
echo $(dig +short geoip.ubuntu.com | grep -v '\.$' | head -1) geoip.ubuntu.com >>/etc/hosts
sed -i '/^nameserver /d' /etc/resolv.conf
users:
- default
- name: ubuntu
lock_passwd: false
Let me know if you guys have run into this before or if you have a better way to work around this.

