3

I'm trying to install 20.04 with an auto install config file like this one:

user-data file:

version: 1
identity:
    hostname: hostname
    username: username
    password: $crypted_pass

But I want the installation process to ONLY ask for the hostname, and for everything else to be automated. I feel like this should be possible because the docs say it is almost infinitely configurable.

I am installing with pxeboot/tftp, here is my install lines similar to the quick-start guide:

kernel installers/ubuntu/20.04/vmlinuz
initrd installers/ubuntu/20.04/initrd
append root=/dev/ram0 ramdisk_size=1500000 ip=dhcp url=http://releases.ubuntu.com/20.04/ubuntu-20.04-live-server-amd64.iso autoinstall ds=nocloud-net;s=http://myserver/preseeds/20.04/

Here are some things I've tried:

identity in interactive-sections

This asks me for the language (why?) and all of the identity fields, also, the password is not pre-seeded

version: 1
interactive-sections:
    - identity
identity:
    hostname: hostname
    username: username
    password: $crypted_pass

remove hostname

This gives parsing error because hostname is required

version: 1
interactive-sections:
    - identity
identity:
    username: username
    password: $crypted_pass

2 Answers 2

2

A few options for possibly setting the hostname below. The first is the one I can propose which asks for the hostname. The others are ways you might provide it.

1. Interactive Sections

From AutomatedServerInstalls, you can mark a section as interactive. It also says that any values provided under interactive sections will be used as default values. Interactive sections may also prevent automatic reboot, but also make the locale section interactive if any sections are interactive.

It appears that you can set the identity section interactive. This may force you to agree to the username and password values, but they should be defaults.

The start of your autoinstall file might look like:

#cloud-init
version: 1
interactive-sections:
 - identity
identity:
    hostname: hostname
    username: username
    password: $crypted_pass

If using an interactive section, I believe you are prompted to reboot. Pressing Alt-F2 to get to another prompt may allow you to run a script or commands to set hostname.

2. Late Commands

There is also a late-commands section. An example from Ubuntu Server 20.04 autoinstall shows where you can issue commands towards the end of the install. Perhaps you can figure out how to modify the hostname automatically at the end.

  late-commands:
    - echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu
    - sed -ie 's/GRUB_CMDLINE_LINUX=.*/GRUB_CMDLINE_LINUX="net.ifnames=0 ipv6.disable=1 biosdevname=0"/' /target/etc/default/grub
    - curtin in-target --target /target update-grub2

3. user-data Section

Also in both of the links I referenced there is a user-data section. The documentation in AutomatedServerInstalls say that if you include this portion you do not need to include an identity section. Perhaps you can configure hostname in here, but you may have to setup users fully here as well. There is discussion of using this feature in this launchpad bug. The poster shares their auto-install config in this post, but I've got a part of it here for posterity.

  user-data:
    password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
    username: ubuntu
    hostname: ubuntu-server
    users:
      - gecos: ubuntu
        groups: [adm, cdrom, dip, plugdev, lxd, sudo]
        lock-passwd: false
        name: ubuntu
        passwd: <SOME_PASSWORD_STRING>
        shell: /bin/bash
        sudo: ALL=(ALL) NOPASSWD:ALL
        ssh_authorized_keys: 
          - ssh-rsa <SOME_RSA_KEY>
6
  • I am using pxeboot and inserting the preseed like they show here: wiki.ubuntu.com/FoundationsTeam/AutomatedServerInstalls/… with autoinstall ds=nocloud-net;s=http://server/location/of/preseeds/ May 26, 2020 at 2:57
  • I know it isn't what you asked for, but perhaps you can use DHCP to give the different hosts different user-data files and make it all automatic. From what I see you can only use the sections that are able to be interactive, and no scheme for ad-hoc prompts.
    – jtessier72
    May 27, 2020 at 11:52
  • How would I do that? Use their MAC address? I'm not sure how I get the info on which computer is being imaged to that computer? May 27, 2020 at 16:18
  • You could use their MAC address to hand out different configurations, or just change the config as you boot a different system. You could have a dir for each hostname you wanted, and change the s:server/loaction/of/preseeds per system. Just a thought.
    – jtessier72
    May 27, 2020 at 23:28
  • 1
    That sounds like an inefficient way to image a computer lab of 30 computers! May 28, 2020 at 6:13
0

If you fix the IP address by mac before PXE boot in DHCP, just add reverse dns record for that IP before starting PXE and that host takes this reverse record as its hostame during install. You can do this for all automatically installed clients. But you have to fix their address before PXE boot by mac addresses.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .