Skip Ubuntu updates...
 
Notifications
Clear all

Skip Ubuntu updates in Packer builds to avoid SSH timeout error

1 Posts
1 Users
0 Reactions
170 Views
Brandon Lee
(@brandon-lee)
Posts: 341
Member Admin
Topic starter
 

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.

 
Posted : 24/02/2024 10:50 am