Vhtforums
AI Assistant
Skip Ubuntu updates...
 
Notifications
Clear all

Skip Ubuntu updates in Packer builds to avoid SSH timeout error

1 Posts
1 Users
0 Reactions
1,727 Views
Brandon Lee
Posts: 682
Admin
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@brandon-lee)
Member
Joined: 16 years ago
[#214]

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.