### Post-Install Script for Language Packs (`postinstall.sh`) Source: https://context7.com/canonical/autoinstall-desktop/llms.txt A shell script to be executed during the `late-commands` phase of autoinstall. This example installs English language packs. It can be extended to support additional locales. ```sh #!/bin/sh # Install language packs for English. # check-language-support outputs the correct package names for the locale. apt install -y $(check-language-support -l en) # To support additional locales, repeat for each language code, e.g.: # apt install -y $(check-language-support -l fr) # Deploy and run via autoinstall.yaml late-commands: # - wget -O /target/postinstall.sh http://192.168.0.2/postinstall.sh # - curtin in-target -- bash /postinstall.sh # - rm /target/postinstall.sh ``` -------------------------------- ### Core Autoinstall Configuration (`autoinstall.yaml`) Source: https://context7.com/canonical/autoinstall-desktop/llms.txt Defines the automated Ubuntu Desktop installation process, including packages, snaps, user identity, storage, and late-stage commands for system conversion. Ensure the password hash is generated using `mkpasswd --method=SHA-512`. ```yaml #cloud-config autoinstall: # Required field for Subiquity Autoinstall format version: 1 # Install the full Ubuntu Desktop package set packages: - ubuntu-desktop # Default snaps shipped on a 22.04 Ubuntu Desktop system snaps: - name: firefox - name: gnome-3-38-2004 - name: gtk-common-themes - name: snap-store - name: snapd-desktop-integration # Default user account — generate the password hash with: # mkpasswd --method=SHA-512 (from the 'whois' package) identity: realname: '' username: ubuntu password: '' hostname: ubuntu-desktop # Use a flat (non-LVM) partition layout storage: layout: name: direct # Select the HWE kernel used by Ubuntu Desktop early-commands: - echo 'linux-generic-hwe-22.04' > /run/kernel-meta-package # Optional: apt proxy if the target has no direct internet access # proxy: http://192.168.0.1:3142 late-commands: # Enable graphical boot splash - >- curtin in-target -- sed -i /etc/default/grub -e 's/GRUB_CMDLINE_LINUX_DEFAULT=".*"/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/' - curtin in-target -- update-grub # Switch network management from netplan/systemd-networkd to NetworkManager - rm /target/etc/netplan/00-installer-config*yaml - >- printf "network:\n version: 2\n renderer: NetworkManager" \ > /target/etc/netplan/01-network-manager-all.yaml # Remove filesystem tools irrelevant to the 'direct' storage layout - >- curtin in-target -- apt-get remove -y btrfs-progs cryptsetup* lvm2 xfsprogs # Remove server-only packages not present on a standard Desktop - >- curtin in-target -- apt-get remove -y ubuntu-server ubuntu-server-minimal binutils byobu curl dmeventd finalrd gawk kpartx mdadm ncurses-term needrestart open-iscsi openssh-server sg3-utils ssh-import-id sssd thin-provisioning-tools vim tmux sosreport screen open-vm-tools motd-news-config lxd-agent-loader landscape-common htop git fonts-ubuntu-console ethtool # cloud-init is required for first-boot tasks — keep it - curtin in-target -- apt-get install -y cloud-init # Clean up orphaned dependencies - curtin in-target -- apt-get autoremove -y # Optional: run a custom post-install script hosted on a web server # - wget -O /target/postinstall.sh http://192.168.0.2/postinstall.sh # - curtin in-target -- bash /postinstall.sh # - rm /target/postinstall.sh ``` -------------------------------- ### Autoinstall Without Default User Source: https://context7.com/canonical/autoinstall-desktop/llms.txt Append this snippet to `autoinstall.yaml` to defer user creation to the first boot. This triggers GNOME Initial Setup for user, region, and option configuration. ```yaml # Remove the entire `identity:` section from autoinstall.yaml, # then append this snippet to defer user creation to first boot. user-data: # An empty users list tells cloud-init (and Subiquity) not to create # any user, which triggers gnome-initial-setup on first login. users: [''] # Full example autoinstall.yaml (identity section omitted): # # #cloud-config # autoinstall: # version: 1 # packages: # - ubuntu-desktop # storage: # layout: # name: direct # early-commands: # - echo 'linux-generic-hwe-22.04' > /run/kernel-meta-package # user-data: # users: [''] ``` -------------------------------- ### Configure Landscape Registration in User Data Source: https://github.com/canonical/autoinstall-desktop/blob/main/README.md Use cloud-init's Landscape support to register the installed system. Ensure a user-data section is present and provide the correct URL for the Landscape message system and ping. ```yaml user-data: landscape: client: url: "https://landscape.canonical.com/message-system" ping_url: "http://landscape.canonical.com/ping" … ``` -------------------------------- ### Autoinstall without Default User Source: https://github.com/canonical/autoinstall-desktop/blob/main/README.md This configuration inhibits user creation, prompting for user setup on first boot via Gnome Initial Setup. Remove the 'identity' section and add this 'user-data' entry. ```yaml # This inhibits user creation, which for Desktop images means that # gnome-initial-setup will prompt for user creation on first boot. user-data: users: [''] ``` -------------------------------- ### Install Language Packs Script Source: https://github.com/canonical/autoinstall-desktop/blob/main/README.md This shell script installs language packs for English. It uses `check-language-support` to determine the necessary packages. ```sh #!/bin/sh # Install language packs for English apt install -y $(check-language-support -l en) ``` -------------------------------- ### Configure PXE Boot Default File Source: https://github.com/canonical/autoinstall-desktop/blob/main/README.md Create the pxelinux.cfg/default file to specify the kernel, initrd, and boot parameters for the autoinstall process. Ensure the APPEND line is on a single line and URLs point to your web server. ```shell DEFAULT install LABEL install KERNEL vmlinuz INITRD initrd APPEND root=/dev/ram0 ramdisk_size=1500000 ip=dhcp cloud-config-url=http://192.168.0.2/autoinstall.yaml url=http://192.168.0.2/ubuntu-22.04.1-live-server-amd64.iso autoinstall ``` -------------------------------- ### Download and Place pxelinux.0 Source: https://github.com/canonical/autoinstall-desktop/blob/main/README.md Download the pxelinux.0 binary using wget and move it to the TFTP root directory. ```shell wget http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/current/legacy-images/netboot/pxelinux.0 mv pxelinux.0 /srv/tftp/ ``` -------------------------------- ### Autoinstall Desktop Configuration Source: https://github.com/canonical/autoinstall-desktop/blob/main/README.md This is a complete autoinstall.yaml configuration for Ubuntu Desktop. Adjust the 'identity' section for user details and password hash. Ensure apt access for necessary packages. ```yaml #cloud-config autoinstall: # version is an Autoinstall required field. version: 1 # This adds the default ubuntu-desktop packages to the system. # Any desired additional packages may also be listed here. packages: - ubuntu-desktop # This adds the default snaps found on a 22.04 Ubuntu Desktop system. # Any desired additional snaps may also be listed here. snaps: - name: firefox - name: gnome-3-38-2004 - name: gtk-common-themes - name: snap-store - name: snapd-desktop-integration # User creation can occur in one of 3 ways: # 1. Create a user using this `identity` section. # 2. Create users as documented in cloud-init inside the user-data section, # which means this single-user identity section may be removed. # 3. Prompt for user configuration on first boot. Remove this identity # section and see the "Installation without a default user" section. identity: realname: '' username: ubuntu # A password hash is needed. `mkpasswd --method=SHA-512` can help. # mkpasswd can be found in the package 'whois' password: '' hostname: ubuntu-desktop # Subiquity will, by default, configure a partition layout using LVM. # The 'direct' layout method shown here will produce a non-LVM result. storage: layout: name: direct # Ubuntu Desktop uses the hwe flavor kernel by default. early-commands: - echo 'linux-generic-hwe-22.04' > /run/kernel-meta-package # The live-server ISO does not contain some of the required packages, # such as ubuntu-desktop or the hwe kernel (or most of their depdendencies). # The system being installed will need some sort of apt access. # proxy: http://192.168.0.1:3142 late-commands: # Enable the boot splash - >- curtin in-target -- sed -i /etc/default/grub -e 's/GRUB_CMDLINE_LINUX_DEFAULT=".*"/GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"/' - curtin in-target -- update-grub # Let NetworkManager handle network - rm /target/etc/netplan/00-installer-config*yaml - >- printf "network:\n version: 2\n renderer: NetworkManager" > /target/etc/netplan/01-network-manager-all.yaml # Remove default filesystem and related tools not used with the suggested # 'direct' storage layout. These may yet be required if different # partitioning schemes are used. - >- curtin in-target -- apt-get remove -y btrfs-progs cryptsetup* lvm2 xfsprogs # Remove other packages present by default in Ubuntu Server but not # normally present in Ubuntu Desktop. - >- curtin in-target -- apt-get remove -y ubuntu-server ubuntu-server-minimal binutils byobu curl dmeventd finalrd gawk kpartx mdadm ncurses-term needrestart open-iscsi openssh-server sg3-utils ssh-import-id sssd thin-provisioning-tools vim tmux sosreport screen open-vm-tools motd-news-config lxd-agent-loader landscape-common htop git fonts-ubuntu-console ethtool # Keep cloud-init, as it performs some of the installation on first boot. - curtin in-target -- apt-get install -y cloud-init # Finally, remove things only installed as dependencies of other things # we have already removed. - curtin in-target -- apt-get autoremove -y # A postinstall script may optionally be used for further install # customization. Deploy this postinstall.sh script on the webserver. # - wget -O /target/postinstall.sh http://192.168.0.2/postinstall.sh # - curtin in-target -- bash /postinstall.sh # - rm /target/postinstall.sh # Additional cloud-init configuration affecting the target # system can be supplied underneath a user-data section inside of # autoinstall. # user-data: # … ``` -------------------------------- ### PXELinux Default Boot Menu Source: https://context7.com/canonical/autoinstall-desktop/llms.txt The PXELINUX boot menu configuration that directs booting machines to load the Ubuntu live-server kernel and initrd. Ensure IP addresses match your web server. ```conf # /srv/tftp/pxelinux.cfg/default # The APPEND line and everything after it must be on a SINGLE line. # Replace the IP addresses with those of your web server. DEFAULT install LABEL install KERNEL vmlinuz INITRD initrd APPEND root=/dev/ram0 ramdisk_size=1500000 ip=dhcp cloud-config-url=http://192.168.0.2/autoinstall.yaml url=http://192.168.0.2/ubuntu-22.04.1-live-server-amd64.iso autoinstall # Required files in /srv/tftp/: # pxelinux.0 — wget http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/current/legacy-images/netboot/pxelinux.0 # vmlinuz — cp /mnt/casper/vmlinuz /srv/tftp/ # initrd — cp /mnt/casper/initrd /srv/tftp/ # ldlinux.c32 — apt install syslinux-common && cp /usr/lib/syslinux/modules/bios/ldlinux.c32 /srv/tftp/ # # Mount the ISO first: # mount ubuntu-22.04.1-live-server-amd64.iso /mnt ``` -------------------------------- ### Mount Live Server ISO Source: https://github.com/canonical/autoinstall-desktop/blob/main/README.md Mount the Ubuntu Live Server ISO image to access its contents for copying kernel and initrd files. ```shell mount ubuntu-22.04.1-live-server-amd64.iso /mnt ``` -------------------------------- ### Copy Boot Files to TFTP Root Source: https://github.com/canonical/autoinstall-desktop/blob/main/README.md Copy the kernel (vmlinuz), initrd, and ldlinux.c32 files from the mounted ISO and system packages to the TFTP root directory for netboot. ```shell cp /mnt/casper/{vmlinuz,initrd} /srv/tftp/ apt install syslinux-common cp /usr/lib/syslinux/modules/bios/ldlinux.c32 /srv/tftp/ ``` -------------------------------- ### Dnsmasq PXE/TFTP Configuration Source: https://context7.com/canonical/autoinstall-desktop/llms.txt Configure `dnsmasq` for PXE network booting by setting up DHCP and TFTP services. Adjust interface names and DHCP ranges to match your network environment. ```conf # /etc/dnsmasq.d/pxe.conf # Replace with the actual NIC name (e.g., eth0, ens3) interface=,lo bind-interfaces dhcp-range=,192.168.0.100,192.168.0.200 dhcp-boot=pxelinux.0 enable-tftp tftp-root=/srv/tftp # Setup steps: # apt install dnsmasq # mkdir -p /srv/tftp # # copy this file to /etc/dnsmasq.d/pxe.conf # systemctl restart dnsmasq.service ``` -------------------------------- ### Configure dnsmasq for Netboot Source: https://github.com/canonical/autoinstall-desktop/blob/main/README.md Configure dnsmasq to serve netboot binaries. This involves setting up network interfaces, DHCP ranges, and TFTP root directories. Ensure the dnsmasq service is restarted after configuration. ```shell interface=,lo bind-interfaces dhcp-range=,192.168.0.100,192.168.0.200 dhcp-boot=pxelinux.0 enable-tftp tftp-root=/srv/tftp ``` -------------------------------- ### Python Script for Documentation Generation Source: https://context7.com/canonical/autoinstall-desktop/llms.txt A Python 3 script to generate `README.md` from `README.md.in`. It inlines referenced config files and removes preprocessor comments, keeping documentation synchronized with configuration. ```python #!/usr/bin/python3 # Usage: python3 build_doc.py README.md.in ../README.md import sys infile = sys.argv[1] # e.g., README.md.in outfile = sys.argv[2] # e.g., ../README.md def readlines(filename): with open(filename, 'r') as fp: return fp.readlines() with open(outfile, 'w') as fp: for line in readlines(infile): tokens = line.split(' ') if tokens[0] == '#include': # Inline the referenced file, skipping lines starting with '##' filename = tokens[1].split('"')[1] for includeline in readlines(filename): if not includeline.startswith('##'): fp.write(includeline) elif tokens[0] == '%%': # Strip preprocessor-only comment lines from output continue else: fp.write(line) # Build via Makefile: # cd src && make # builds ../README.md # cd src && make test # verifies README.md is up to date (used in CI) ``` -------------------------------- ### Autoinstall Landscape Registration Source: https://context7.com/canonical/autoinstall-desktop/llms.txt Append this `user-data` snippet to `autoinstall.yaml` to register the system with Canonical Landscape. Ensure your Landscape account details are populated. ```yaml # Append to autoinstall.yaml under an existing user-data section. # Populate all fields with values from your Landscape account. user-data: landscape: client: url: "https://landscape.canonical.com/message-system" ping_url: "http://landscape.canonical.com/ping" # account_name: "my-org" # registration_key: "secret" # computer_title: "ubuntu-desktop-01" # log_level: "info" # Reference: man landscape-config # https://cloudinit.readthedocs.io/en/latest/topics/modules.html#landscape ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.