AnswerBun.com

Ask only for hostname in an Automated Server Install

Ask Ubuntu Asked by 43Tesseracts on January 13, 2021

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

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.

Answered by recap2000 on January 13, 2021

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>

Answered by jtessier72 on January 13, 2021

Add your own answers!

Related Questions

Ubuntu 20.04: Connect your online accounts

0  Asked on December 27, 2021 by wazil

 

xubuntu 18.04 vs 20.04: same font displayed differently

1  Asked on December 27, 2021 by straycoders

       

How to change kernel version in ubuntu?

1  Asked on December 27, 2021 by ajay-bodara

 

win 10 + Ubuntu 18.04 -> Lubuntu 20.04

1  Asked on December 27, 2021 by hibi_scrub

 

Could not connect to cran.stat.ucla.edu:80

1  Asked on December 27, 2021

   

transfering data from one cluster to another

1  Asked on December 27, 2021

   

Change critical battery level in ubuntu 20?

0  Asked on December 25, 2021 by abhishek-sharma

   

How to access my codeigniter folder in ubuntu?

2  Asked on December 25, 2021 by upendra-sharma

       

“System bootorder not found” after installation

2  Asked on December 25, 2021 by koppny-kovcs

     

HP EliteBook 8570p Ubuntu grub is not launched

1  Asked on December 25, 2021 by neven-v

       

Ubuntu 20.04 – No sound

11  Asked on December 25, 2021 by wkpro

       

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir