Skip to content

Instantly share code, notes, and snippets.

@DrPsychick
Last active November 13, 2022 00:10
Show Gist options
  • Save DrPsychick/4d7ba61ec93aac83866616b0ea36588c to your computer and use it in GitHub Desktop.
Save DrPsychick/4d7ba61ec93aac83866616b0ea36588c to your computer and use it in GitHub Desktop.
Ubuntu autoinstall user-data for Ubuntu server build with Packer
#cloud-config
# https://ubuntu.com/server/docs/install/autoinstall-reference
autoinstall:
version: 1
refresh-installer:
update: yes
early-commands:
- systemctl stop ssh
locale: en_US.UTF-8
keyboard:
layout: us
apt:
preserve_sources_list: false
primary:
- arches: [amd64]
uri: "http://archive.ubuntu.com/ubuntu"
- arches: [default]
uri: "http://ports.ubuntu.com/ubuntu-ports"
geoip: true
storage:
version: 2
swap:
size: 0
# this is required for UEFI install, so reboot boots from disk, not CDROM
grub:
reorder_uefi: false
# https://curtin.readthedocs.io/en/latest/topics/storage.html#basic-layout
config:
- type: disk
id: disk0
ptable: gpt
path: /dev/vda
wipe: superblock-recursive
preserve: false
# partition
- type: partition
id: boot-partition
device: disk0
size: 512M
flag: boot
partition_type: EF00
wipe: superblock
preserve: false
# GPT requires this on the efi partition
grub_device: true
- type: partition
id: root-partition
device: disk0
size: 8G
# root x64
partition_type: 8300
wipe: superblock
preserve: false
- type: partition
id: data-partition
device: disk0
size: -1
# data
partition_type: 8300
wipe: superblock
preserve: false
# format:
- type: format
id: boot-partition-fs
volume: boot-partition
label: boot
fstype: fat
- type: format
id: root-partition-fs
volume: root-partition
label: root
fstype: ext4
- type: format
id: data-partition-fs
volume: data-partition
label: data
fstype: xfs
# mount:
- type: mount
id: boot-partition-mount
device: boot-partition-fs
path: /boot/efi
- type: mount
id: root-partition-mount
device: root-partition-fs
path: /
- type: mount
id: data-partition-mount
device: data-partition-fs
path: /data
identity:
hostname: ubuntu2204
username: ubuntu
# echo "packer" | openssl passwd -6 -stdin
password: $6$g0/WJj5hfgj0kXlg$AOPpDYcTN0QZL8xk2PI7VJlUsFTQb683mbS1yZvUZ1zjEx1KpCUP6ADkMEPOjYFUUp86KbmlFkdtO9vE8.mFQ0
ssh:
allow-pw: true
authorized-keys: []
install-server: true
network:
version: 2
ethernets:
eth:
match:
name: "en*"
dhcp4: yes
late-commands:
- "echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu"
- "chmod 440 /target/etc/sudoers.d/ubuntu"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment