diff --git a/Documentation/Auto_install_ubuntu_iso.md b/Documentation/Auto_install_ubuntu_iso.md index 0ae59ef..03ad97d 100644 --- a/Documentation/Auto_install_ubuntu_iso.md +++ b/Documentation/Auto_install_ubuntu_iso.md @@ -38,8 +38,6 @@ mkdir source-files wget https://releases.ubuntu.com/jammy/ubuntu-22.04.5-live-server-amd64.iso ``` -From here on stay in the iso_files directory for all the rest of the commands. - ### Step 2: Extract the ISO contents Use 7z to unpack the ISO. It will extract MBR and EFI partition images automatically. @@ -60,9 +58,11 @@ cd .. Open **source-files/boot/grub/grub.cfg** and add the following menu entry above the existing ones (it should be the first menuentry option). -This option will be shown during the Booting process and be automatically selected in 30 seconds, if there is no input from the user. +This option will be shown during the Booting process as **Autoinstall Ubuntu Server** and be automatically selected in 30 seconds, if there is no input from the user. ![Booting Menu](../images/os-install/dell/BootMenu.png) +#### If the server configuration files (**user-data** and **meta-data**) needs to be local to the ISO, then use the below menuentry definition + ```bash menuentry "Autoinstall Ubuntu Server" { set gfxpayload=keep @@ -71,82 +71,78 @@ initrd /casper/initrd } ``` -Now, your grub.cfg file should look like ![this](../images/os-install/dell/GrubFile.png) +#### If the server configuration files (**user-data** and **meta-data**) are stored on a remote server, and be picked dynamically use the below menuentry definition, and make sure the web server is up and running and the files as accessible + +```bash +menuentry "Autoinstall Ubuntu Server" { +set gfxpayload=keep +linux /casper/vmlinuz quiet autoinstall ds=nocloud\;s=http://ip-address/path-to-server-folder/ --- +initrd /casper/initrd +} +``` + +Where the **server** folder contains the **user-data** and the **meta-data** files. ### Step 5: Create a directory for auto-install configuration files This directory will hold the user-data and meta-data files required to build the auto-install iso ```bash -mkdir source-files/server +mkdir server ``` -### Step 6: Add an empty meta-data file (cloud-init requires its presence) +### Step 6: Create a meta-data file (cloud-init requires its presence) under the server directory ```bash -touch source-files/server/meta-data +touch server/meta-data ``` -### Step 7: Create a user-data file +You can find the sample **meta-data** file [here](../ansible/iso_files/server/meta-data) + +### Step 7: Create a user-data file in the server directory This file will contain the auto-install user configuration. You can add your own settings here. -The below are the current settings(user-data) that we are using, you can refer to the Ubuntu Autoinstall documentation for more details. +You can refer to the Ubuntu Autoinstall documentation for more details. You can find the sample **user-data** file [here](../ansible/iso_files/server/user-data). + +Under the Identity section, we need to provide a hashed password, which can be done using the following commands ```bash -autoinstall: -version: 1 -early-commands: - - ["cat", "/autoinstall.yaml"] -refresh-installer: - update: yes -apt: - preserve_sources_list: false - mirror-selection: - primary: - - country-mirror - - uri: "http://archive.ubuntu.com/ubuntu" - arches: [i386, amd64] - - uri: "http://ports.ubuntu.com/ubuntu-ports" - arches: [s390x, arm64, armhf, powerpc, ppc64el, riscv64] - fallback: abort - geoip: true - sources: - git-ppa: - source: ppa:git-core/ppa -identity: - hostname: opi - password: "hashedpassword" - realname: opi - username: opi -keyboard: - layout: us - toggle: "" - variant: "" -locale: en_US -ssh: - allow-pw: true - authorized-keys: [] - install-server: true -storage: - layout: - name: lvm - match: - size: largest -late-commands: - - 'echo ''APT::Install-Recommends "false";'' >/target/etc/apt/apt.conf.d/02InstallRecommends' +openssl passwd -6 ``` -Under the Identity section, we need to provide a hashed password, which can be done using the following commands +This will prompt you to enter a password, which will be hashed and displayed. You can then update the **user-data**** file with the latest password using the below command ```bash -openssl passwd -6 +sed -i 's/password: ".*"/password: "<>"/' ~/lab/ansible/iso_files/server/user-data ``` -This will prompt you to enter a password, which will be hashed and displayed. You can then copy it to the autoinstall user-data file above. +**Note:** If the server configuration files need to be local to the ISO, then keep the **server** folder under the **source-files** directory. Else keep the **server** folder in the accessible remote server. ### Step 8: Generate the Custom Ubuntu 22.04 Autoinstall ISO +Make sure this is the directory structure before you run the below commands + +```plaintext +iso_files +├── ubuntu-22.04.5-live-server-amd64.iso +├── BOOT +├── source-files +│ ├── server +│ │ ├── meta-data +│ │ └── user-data +│ ├── boot +│ ├── └── grub +│ ├────── └── grub.cfg +│ ├── casper +│ ├── dists +│ ├── EFI +│ ├── install +│ ├── md5sum.txt +│ ├── pool +│ └── boot.catalog +``` + To generate the custom Ubuntu 22.04 autoinstall ISO, you can use the following command ```bash @@ -163,7 +159,7 @@ xorriso -as mkisofs -r \ -iso_mbr_part_type a2a0d0ebe5b9334487c068b6b72699c7 \ -c '/boot.catalog' \ -b '/boot/grub/i386-pc/eltorito.img' \ - -no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info \ +-no-emul-boot -boot-load-size 4 -boot-info-table --grub2-boot-info \ -eltorito-alt-boot \ -e '--interval:appended_partition_2:::' \ -no-emul-boot \ @@ -171,3 +167,11 @@ xorriso -as mkisofs -r \ ``` This will create a new autoinstall iso with the name: **ubuntu-22.04-autoinstall.iso**, that can be used for installation. + +### Subsequent Autoinstall ISO updates + +For updates to the Autoinstall ISO: + +If the server configuration files are local to the ISO, then update the configuration files (**user-data** and **meta-data** files) in Step 6 and Step 7, then run **xorriso** command in Step 8 to create an updated ISO. + +Else, if the server configuration files are stored on a remote server. All you need to do is just make the modifications to the **user-data** and the **meta-data** file in the remote server and re-install the OS using the same ISO. It will automatically pick the latest updates. diff --git a/ansible/iso_files/server/meta-data b/ansible/iso_files/server/meta-data new file mode 100644 index 0000000..0e2e0bf --- /dev/null +++ b/ansible/iso_files/server/meta-data @@ -0,0 +1 @@ +local-hostname: dh1 \ No newline at end of file diff --git a/ansible/iso_files/server/user-data b/ansible/iso_files/server/user-data new file mode 100644 index 0000000..6c0e5fe --- /dev/null +++ b/ansible/iso_files/server/user-data @@ -0,0 +1,41 @@ +autoinstall: +version: 1 +early-commands: + - ["cat", "/autoinstall.yaml"] +refresh-installer: + update: yes +apt: + preserve_sources_list: false + mirror-selection: + primary: + - country-mirror + - uri: "http://archive.ubuntu.com/ubuntu" + arches: [i386, amd64] + - uri: "http://ports.ubuntu.com/ubuntu-ports" + arches: [s390x, arm64, armhf, powerpc, ppc64el, riscv64] + fallback: abort + geoip: true + sources: + git-ppa: + source: ppa:git-core/ppa +identity: + hostname: opi + password: "hashedpassword" + realname: opi + username: opi +keyboard: + layout: us + toggle: "" + variant: "" +locale: en_US +ssh: + allow-pw: true + authorized-keys: [] + install-server: true +storage: + layout: + name: lvm + match: + size: largest +late-commands: + - 'echo ''APT::Install-Recommends "false";'' >/target/etc/apt/apt.conf.d/02InstallRecommends' \ No newline at end of file diff --git a/images/os-install/dell/GrubFile.png b/images/os-install/dell/GrubFile.png index 272f11d..f49057c 100644 Binary files a/images/os-install/dell/GrubFile.png and b/images/os-install/dell/GrubFile.png differ