From 25f7fe6f3a28fa05ff20b490036ffd6898138211 Mon Sep 17 00:00:00 2001 From: Fabio Bento Luiz Date: Fri, 23 Jun 2023 23:30:53 +0200 Subject: [PATCH] initial --- README.md | 17 +++++++++ test.txt | 0 user-data | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 README.md delete mode 100644 test.txt create mode 100644 user-data diff --git a/README.md b/README.md new file mode 100644 index 0000000..487ace4 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# CloudInit with partition configuration for Ubuntu 22.04 LTS +It is possible to find some examples of CloudInit configuration on the documentation, but it can get hairy when it comes to configure the partitions and disk layout with `autoinstall`. + +In my scenario, I have some machines with 500 GB SSD and I'd like to have 20% for the OS and 80% as a raw partition without file system usin the `autoinstall` for a full unattended installation. + +After many tries, I've found a tip to do one installation manually (with a bootable pendrive for example) and do the all the partitioning configuration with the installation wizard. I will generate the `user-data` file necessary to replicate the same installation with CloudInit on the other machines. + +At the end of the manual installation, it will ask to reboot/proceed, **dont do that**. At the top right corner, you can find a `Help` menu where you can access a shell console. + +The file `/var/log/installer/autoinstall-user-data` holds all your choices from the installation wizard in a CloudInit format (it is the `user-data` file). You can export it to a TMP file sharing like [file.io](https://www.file.io/about): + +```bash +curl -F "file=@/var/log/installer/autoinstall-user-data" https://file.io +{"success":true,"key":"2ojE41","link":"https://file.io/2ojE41","expiry":"14 days"} +``` + +Then you can use or adapt it to further installations. diff --git a/test.txt b/test.txt deleted file mode 100644 index e69de29..0000000 diff --git a/user-data b/user-data new file mode 100644 index 0000000..6b212cb --- /dev/null +++ b/user-data @@ -0,0 +1,108 @@ +#cloud-config +autoinstall: + version: 1 + locale: en_US + keyboard: + layout: us + user-data: + # generate hostname dinamically - see 'early-commands' section + hostname: HOSTNAME_TO_REPLACE + timezone: Europe/Berlin + # ask user to change password after first login, pass never expires, default user 'ubuntu', pass 'ubuntu' + chpasswd: + expire: false + list: + - ubuntu:ubuntu + # Replace HOSTNAME_TO_REPLACE by srv-n, where n is an auto-increment counter + early-commands: + - sed -i -e "s/HOSTNAME_TO_REPLACE/node-$(curl -s http://192.168.10.1:8080/cgi-bin/counter.py)/" /autoinstall.yaml + # do not show the fingerprints of the authorized keys on the console + resize_rootfs: false + storage: + config: + - ptable: gpt + path: /dev/nvme0n1 + wipe: superblock + preserve: false + name: '' + grub_device: false + type: disk + id: disk-nvme0n1 + match: + size: largest + - device: disk-nvme0n1 + size: 1127219200 + wipe: superblock + flag: boot + number: 1 + preserve: false + grub_device: true + offset: 1048576 + type: partition + id: partition-6 + - fstype: fat32 + volume: partition-6 + preserve: false + type: format + id: format-4 + - device: disk-nvme0n1 + size: 107374182400 + wipe: superblock + number: 2 + preserve: false + grub_device: false + offset: 1128267776 + type: partition + id: partition-7 + - fstype: ext4 + volume: partition-7 + preserve: false + type: format + id: format-5 + - path: / + device: format-5 + type: mount + id: mount-5 + - device: disk-nvme0n1 + size: 1073741824 + wipe: superblock + flag: swap + number: 3 + preserve: false + grub_device: false + offset: 108502450176 + type: partition + id: partition-8 + - fstype: swap + volume: partition-8 + preserve: false + type: format + id: format-6 + - path: '' + device: format-6 + type: mount + id: mount-6 + - device: disk-nvme0n1 + size: 390530596864 + number: 4 + preserve: false + grub_device: false + offset: 109576192000 + type: partition + id: partition-9 + - path: /boot/efi + device: format-4 + type: mount + id: mount-4 + swap: + size: 0 +no_ssh_fingerprints: false + ssh_authorized_keys: + - ssh-rsa + - ssh-rsa + # enable ssh + ssh: + install-server: true + allow-pw: false + # do not print ssh host keys on the console + emit_keys_to_console: false \ No newline at end of file -- 2.45.2