-
-
Save dbkinghorn/c236aea31d76028b2b6ccdf6d3c6f07e to your computer and use it in GitHub Desktop.
| #cloud-config | |
| autoinstall: | |
| version: 1 | |
| refresh-installer: # start with an up-to-date installer | |
| update: yes | |
| interactive-sections: # Install groups listed here will wait for user input | |
| - storage | |
| storage: # should set the interactive default but doesn't seem to work?? | |
| layout: | |
| name: direct | |
| locale: en_US.UTF-8 | |
| keyboard: | |
| layout: us | |
| identity: # This is section you may want to add to interactive-sections (user name and password are ubuntu here) | |
| hostname: puget-000 | |
| password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0" | |
| username: ubuntu | |
| ssh: | |
| allow-pw: true | |
| install-server: true | |
| apt: | |
| sources: | |
| ignored1: # This is here to get the yaml formatting right when adding a ppa | |
| source: ppa:graphics-drivers/ppa | |
| packages: | |
| - build-essential | |
| - network-manager | |
| - dkms | |
| - emacs-nox | |
| - ubuntu-desktop-minimal | |
| package_update: true | |
| package_upgrade: true | |
| late-commands: | |
| # 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 | |
| # Write a script that can take care of some post install setup "late-commands" cannot be interactive unfortunately" | |
| # - | | |
| # cat <<EOF | sudo tee /target/etc/finish-install-setup.sh | |
| # #!/usr/bin/env bash | |
| # echo ************************* | |
| # echo **** Finish Setup **** | |
| # echo ************************* | |
| # echo 'Enter the hostname for this system: ' | |
| # read NEW_HOSTNAME | |
| # hostnamectl set-hostname \${NEW_HOSTNAME} | |
| # echo | |
| # echo 'Enter the timezone for this system: ' | |
| # echo 'America/Los_Angeles America/Denver America/Chicago America/New_York' | |
| # read NEW_TIMEZONE | |
| # timedatectl set-timezone \${NEW_TIMEZONE} | |
| # echo ************************* | |
| # echo | |
| # echo ************************* | |
| # echo 'Restarting to finish ...' | |
| # shutdown -r 3 | |
| # EOF | |
| # - curtin in-target --target /target chmod 744 /etc/finish-install-setup.sh | |
| - cp /target/cdrom/extras/Puget_Systems.png /target/usr/share/backgrounds/ | |
| user-data: # Commands here run during first boot (cannot be interactive) | |
| runcmd: | |
| # Install the NVIDIA driver from the ppa we setup earlier | |
| - [apt-get, update] | |
| - [apt-get, dist-upgrade, --yes] | |
| - [apt, autoremove, --yes] | |
| - [apt-get, install, --yes, nvidia-driver-470] #, --no-install-recommends] | |
| - [sudo, -u, ubuntu, dbus-launch, gsettings, set, org.gnome.desktop.background, picture-uri, file:///usr/share/backgrounds/Puget_Systems.png] | |
| # - | | |
| # #!/usr/bin/env bash | |
| # echo '' | |
| # echo '***************************************' | |
| # echo ' To complete install setup please run, ' | |
| # echo ' sudo /etc/finish-install-setup.sh' | |
| # echo '***************************************' | |
| # echo '' |
| #cloud-config | |
| autoinstall: | |
| version: 1 | |
| refresh-installer: # start with an up-to-date installer | |
| update: yes | |
| interactive-sections: # Install groups listed here will wait for user input | |
| - storage | |
| storage: # should set the interactive default but doesn't seem to work?? | |
| layout: | |
| name: direct | |
| locale: en_US.UTF-8 | |
| keyboard: | |
| layout: us | |
| identity: # This is section you may want to add to interactive-sections (user name and password are ubuntu here) | |
| hostname: puget-000 | |
| password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0" | |
| username: ubuntu | |
| ssh: | |
| allow-pw: true | |
| install-server: true | |
| apt: | |
| sources: | |
| ignored1: # This is here to get the yaml formatting right when adding a ppa | |
| source: ppa:graphics-drivers/ppa | |
| packages: | |
| - build-essential | |
| - network-manager | |
| - dkms | |
| - emacs-nox | |
| #- ubuntu-desktop-minimal^ | |
| package_update: true | |
| package_upgrade: true | |
| late-commands: | |
| # 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 | |
| # Write a script that can take care of some post install setup "late-commands" cannot be interactive unfortunately" | |
| # - | | |
| # cat <<EOF | sudo tee /target/etc/finish-install-setup.sh | |
| # #!/usr/bin/env bash | |
| # echo ************************* | |
| # echo **** Finish Setup **** | |
| # echo ************************* | |
| # echo 'Enter the hostname for this system: ' | |
| # read NEW_HOSTNAME | |
| # hostnamectl set-hostname \${NEW_HOSTNAME} | |
| # echo | |
| # echo 'Enter the timezone for this system: ' | |
| # echo 'America/Los_Angeles America/Denver America/Chicago America/New_York' | |
| # read NEW_TIMEZONE | |
| # timedatectl set-timezone \${NEW_TIMEZONE} | |
| # echo ************************* | |
| # echo | |
| # echo ************************* | |
| # echo 'Restarting to finish ...' | |
| # shutdown -r 3 | |
| # EOF | |
| # - curtin in-target --target /target chmod 744 /etc/finish-install-setup.sh | |
| - ls -l > /target/root/ls.out | |
| - pwd > /target/root/pwd.out | |
| - mount > /target/root/mount.out | |
| - touch afile | |
| - cp afile /target/root/ | |
| - ls -l / > /target/root/ls-root.out | |
| - ls -l /target > /target/root/ls-target.out | |
| - ls -l /target/cdrom > /target/root/ls-target-cdrom.out | |
| user-data: # Commands here run during first boot (cannot be interactive) | |
| runcmd: | |
| # Install the NVIDIA driver from the ppa we setup earlier | |
| - [apt-get, install, --yes, nvidia-driver-470, --no-install-recommends] | |
| - | | |
| #!/usr/bin/env bash | |
| echo '' | |
| echo '***************************************' | |
| echo ' To complete install setup please run, ' | |
| echo ' sudo /etc/finish-install-setup.sh' | |
| echo '***************************************' | |
| echo '' |
Ah!!! Great!!!
Thank you for your kind reply.
I will try with your suggestion and let you know.
I really appreciate it.
Thank you again!!!
Hello there,
I am currently building an autoinstall ISO using Ubuntu 22.04.3 LTS live server. A blog post by @dbkinghorn has been immensely helpful in this process. However, I have encountered an issue with the autoinstall script I created, specifically with regard to enabling autologin for the new user.
The purpose of this autoinstall is to run docker engine. I am in need of suggestions or assistance to resolve this issue. Below is my 'user-data' configuration:
#cloud-config
autoinstall:
version: 1
storage:
layout:
name: direct
partitions:
- name: primary
number: 1
size: 100%
type: ext4
wipe: superblock
preserve_layout: false
overwrite: true
filesystems:
- device: /dev/disk/by-id/*
format: ext4
label: ubuntu
locale: en_US.UTF-8
keyboard:
layout: us
identity:
hostname: ubuntu_machine
password: $6$NpdhCKROExJxGAP9$uJ/hKo9ON7VZ.nwC02p8yKHPFtEWz.aphNk7D1fDI7aUmtrXTN5i/QmDhtbCf0xNQEr/LTphOfdcgovbDwG8l.
username: ubuntu
ssh:
allow-pw: true
install-server: true
apt:
primary:
- arches: [default]
uri: http://us.archive.ubuntu.com/ubuntu/
packages:
- build-essential
- network-manager
- dkms
- vim
- git
- docker.io
- nodejs
- npm
- sqlite
package_update: true
package_upgrade: true
late-commands:
# 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
users:
- name: ubuntu
groups: docker
shell: /bin/bash
sudo: ALL=(ALL) NOPASSWD:ALL
autologin:
enable: true
user: root
I have been working on this problem for several weeks and would greatly appreciate any guidance or help. Thank you.
You probably still have a little more experimenting to do. Here are a couple of things to try;
-
You have the user 'ubuntu' already defined with a password (effectively the install root user'.) You might want to try setting up your auto-login user with at different name. (I'm not sure how this is done with a manual install. Maybe you want to do this in the identity section and not assign a password at all??)
-
If you want to have the user 'ubuntu' as the auto login user then you might have better luck in late-commands using curtin in-target --target to do the config change manually with system commands like usermod etc..
I don't have experience using auto login but I hope I'm giving you good advise on things to try. Best wishes --Don
@shubham-kshetre I had a kinda successful but disgusting method go get autologin working.
In late_commands add this:
# Create a service to run above script on bootup
- |
cat <<EOF | sudo tee /target/etc/systemd/system/setup_autologin.service
[Unit]
Description=Configure autologin for user "tester"
[Service]
Type=oneshot
ExecStart=/bin/bash -c "sed -i 's/# AutomaticLoginEnable = true/AutomaticLoginEnable = true/' /etc/gdm3/custom.conf && sed -i 's/# AutomaticLogin = user1/AutomaticLogin = tester/' /etc/gdm3/custom.conf && groupadd docker && usermod -aG docker tester && newgrp docker"
[Install]
WantedBy=multi-user.target
EOF
- curtin in-target --target /target chmod 0644 /etc/systemd/system/setup_autologin.service
- curtin in-target --target /target systemctl enable setup_autologin
Basically create a service that will run prior to the desktop loading. Problem is that you have to delete the service file post login.
Yes - indeed ...