Skip Ubuntu updates...
 
Notifications
Clear all

Skip Ubuntu updates in Packer builds to avoid SSH timeout error

1 Posts
1 Users
0 Reactions
222 Views
Brandon Lee
Posts: 395
Admin
Topic starter
(@brandon-lee)
Member
Joined: 14 years ago

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.

image

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.