Score:0

Autoinstall local repository

mh flag
Utz

I have my own ISO based on Ubuntu 22.04 that I generated myself. Here is my Autoinstall -

#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: foo-ubuntu
    password: "ToReplace"
    username: abcabc
  source:
    id: ubuntu-server-minimal
  early-commands:
  - cat /cdrom/casper/install-sources.yaml | awk 'NR>1 && /^-/{exit};1' > /run/my-sources.yaml
  - mount -o ro,bind /run/my-sources.yaml /cdrom/casper/install-sources.yaml
  late-commands:
    - cp -r /cdrom/copy_to_iso/ /target/opt/
  user-data:
    runcmd:
      - |
        mkdir -vp /opt/INIT/
        mv -v /opt/copy_to_iso/upgrade_or_install_packages/ /opt/
        mv -v /opt/copy_to_iso/foo_installation/* /opt/INIT/ 
        mv -v /opt/copy_to_iso/abc_scripts /opt/abc_scripts
        rm -rvf /opt/copy_to_iso
        bash -x /opt/abc_scripts/copy_system_files.sh
        bash -x /opt/abc_scripts/setup_system_config.sh install_mode

During early-commands and late-commands, I have a local repository with all the needed packages under /cdrom/copy_to_iso/packages. During the user-data section, the location is /opt/packages.

When I install the ISO on a server without an internet connection, the installation ends perfectly well, and all the necessary packages are installed. On the other hand, when I install the ISO on a server with internet connection, I see in the logs that it found a more up-to-date package externally in the internet, and it makes the section of installing the packages from /opt/packages fail.

I saw some related questions on the internet, but I wish to make all the sections in autoinstall work only with my local repository. Here is something that I tried -

how to disable unattended-upgrades during autoinstall (user-data, cloud-config)

Please look on "alternate option to use your local mirror". My problem is that I don't work with http in my local repository, but with "file".

I tried -

#cloud-config
autoinstall:
  apt:
  disable_components: [restricted,multiverse]
  disable_suites: [backports,security]
    primary:
    - arches:
      - default
      uri: file:///cdrom/copy_to_iso/packages/

and also file:/cdrom/copy_to_iso/packages/ - nothing works, and it still installs packages from external repositories.

How should I write it in my case?

Score:1
mh flag
Utz

I managed to disable auto updates by disabling network as a part of the autoinstall:

network:
  ethernets: {}
  version: 2

In late-commands I add the following content to /etc/netplan/50-cloud-init.yaml -

network:
  ethernets:
    ens160:
      dhcp4: true
      dhcp6: false

then I run netplan apply and my machine has network.

xbufu avatar
cn flag
Hi! Would it be possible for you to post your user-data file? I'm getting errors in the autoinstall when it tries to set up SSH. Would really appreciate it :)
Score:0
jp flag

This autoinstall configuration might work for you

#cloud-config
autoinstall:
  apt:
    disable_components: [restricted,multiverse]
    disable_suites: [backports,security]
    primary:
    - arches:
      - amd64
      - i386
      uri: http://archive.ubuntu.com/ubuntu
    - arches:
      - default
      uri: http://ports.ubuntu.com/ubuntu-ports
    preferences:
      - package: "*"
        pin: "release a=jammy-updates"
        pin-priority: 200
  late-commands:
    - |
      rm /target/etc/apt/preferences.d/90curtin.pref
      true

This will configure apt using a standard mirror without the given components and suites.

The preferences configuration will disable any updates. More technically, packages from the jammy repository will be preferred over the packages from the jammy-updates repository. This might prevent the problem of finding a more up-to-date package on the Internet. The late-commands will delete this preference configuration so that it will only affect the installation.

It is hard to say how to use your custom repository without knowing more about it. The uri looks reasonable, but even if it does work during installation the installed system will have a broken apt configuration because /cdrom/copy_to_iso/packages will not exist. This could potentially be fixed with more late-commands.

Utz avatar
mh flag
Utz
Thank you, but it didn't work for me. It installed more up-to-date packages during the installation. Look at my answer, it fixed the issue I faced.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.