UncleNUC Wiki

Second chance for NUCs

User Tools

Site Tools


lab:ansible_virtualbox_autoboot_linux:customize_user-data_for_ubuntu_unattended_install

This is an old revision of the document!


Customize user-data for Ubuntu Unattended Install

A custom “user-data” file is required for an unattended installation of Ubuntu. We will create this template file for use in our Ansible playbook to Generate Custom Unattended Ubuntu Install ISO.

FIXME The file below is in development

user-data
#cloud-config
autoinstall:
  version: 1
  storage:
    layout:
      name: lvm
      match:
        size: largest
  locale: en_US.UTF-8
  keyboard:
    layout: us
  identity:
    hostname: ubuntu-server
    username: user
    password: "$6$ryx4qBcSL3V1qKaU$UVKN5KO0gwjUqha0OQkGX8CL/Dbp3NCPo52vEvXO1/2s3NkFcvw540HPWc1g6/7UFEmYEbeRXFdttuguFsvj00" # VMware1!
    #create hash: mkpasswd --method=SHA-512
  ssh:
    install-server: yes
    allow-pw: true
  apt:
    primary:
      - arches: [default]
        uri: http://us.archive.ubuntu.com/ubuntu/
  packages:
    - build-essential
    - network-manager
    - dkms
    - emacs-nox
  package_update: true
  package_upgrade: true
  late-commands:
    - echo 'user ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu # Allow user to run sudo without password
    # Changing from networkd to NetworkManager
    # move existing config out of the way
    - find /target/etc/netplan/ -name "*.yaml" -exec sh -c 'mv "$1" "$1-orig"' _ {} \;
    # Create a new netplan and enable it
    - |
      cat <<EOF | sudo tee /target/etc/netplan/01-netcfg.yaml
      network:
        version: 2
        renderer: NetworkManager
      EOF
    - curtin in-target --target /target netplan generate
    - curtin in-target --target /target netplan apply
    - curtin in-target --target /target systemctl enable NetworkManager.service

NEXT:

PREVIOUS: install_oracle_virtualbox_using_ansible

lab/ansible_virtualbox_autoboot_linux/customize_user-data_for_ubuntu_unattended_install.1705432866.txt.gz · Last modified: 2024/01/16 19:21 by user