auto

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2018 License: MIT Imports: 13 Imported by: 0

README

ISO Auto Command

This command helps create an auto installation media out of the original media. As of now, it supports Ubuntu 18.04 LTS server (using old installer) and Ubuntu 16.04 LTS server.

Flavor and Provider

As this command may potentially support other operating systems in the future. It leaves the option open using the concept of flavor. A flavor corresponds to a specific OS. As before, the two supported flavor is ubuntu/bionic64 and ubuntu/xenial64. A provider handles one or more flavor.

Bionic and Xenial

The provider that currently handles the ubuntu/bionic64 and ubuntu/xenial64 uses an external script and seed file to repack the installation media. The process is largely inspired by the ubuntu-unattended project.

The command accepts user input, uses those input to parse the preseed file and places it the workspace. The rest of the work is handed to the script. The script downloads the flavor image if necessary, mounts it and copies it to a new location where real changes are made. Then, the preseed file is copied in, updates the installation menu to accept the preseed file and repacks it as a new iso.

If preseed file is present, the script can be used directly:

$ sudo -s
$ chmod +x ./scripts/ubuntu-preseed.sh
$ ./scripts/ubuntu-preseed.sh \
    --seed=/tmp/imulab.seed \
    --flavor=bionic64 \
    --workspace=/tmp \
    --input=/tmp/ubuntu-18.04-lts.iso \
    --output=/tmp/ubuntu-autoinstall.iso \
    --bootable \
    --debug \
    --reuse
Parameter Shorthand Required Value
--seed -s yes path to preseed file
--flavor -v no {bionic64,xenial64}, default bionic64
--workspace -w yes directory to place temp files
--input -i no ubuntu.iso
--output -o no ubuntu-auto.iso
--bootable -b no {y,n}, default n
--reuse -r no {y,n}, default n. Whether to reuse assets.
--debug -d no {y,n}, default n. Whether to print debug messages.

The command is much easier to use if there's no preseed file:

$ sudo -s
$ homelab iso auto \
    --flavor=ubuntu/bionic64 \
    --workspace=/tmp \
    --input-iso=/tmp/ubuntu-18.04-lts.iso \
    --output-iso=/tmp/ubuntu-autoinstall.iso \
    --timezone=America/Toronto \
    --username=imulab \
    --password=s3cret \
    --hostname=test \
    --domain=home.local \
    --ip-address=192.168.100.30 \
    --net-mask=255.255.255.0 \
    --gateway=192.168.100.1 \
    --name-servers=8.8.8.8 \
    --usb-boot \
    --reuse \
    --debug \
    --output-format=json

The above command downloads a new Ubuntu 18.04 LTS server image, or reuses one from workspace if it exists. It then configures user account, network, and uses all disk as one volume. Makes the new image USB bootable and prints out debug messages in the process. Finally, a new image is placed at /tmp/ubuntu-auto.iso.

Parameters are described as follows:

Flag Required Default Content
--flavor no ubuntu/bionic64 Flavor of the OS. {ubuntu/bionic64, ubuntu/xenial64} is supported.
--workspace no /tmp Workspace of the command. All temp files and the resulting ISO is placed here.
--input-iso yes -- Path to the downloaded iso file
--output-iso yes -- Path to the converted iso file
--timezone no America/Toronto Timezone of the system
--username no imulab Username of the new user.
--password yes -- Password of the new user. Right now, the seed file does not crypt, and uses plain text.
--hostname yes -- Host name of the system
--domain no home.local Domain of the system
--ip-address no -- Ip address, if configuring fixed network. If not specified, all network related flags are ignored, installation will use DHCP.
--net-mask no 255.255.255.0 Net mask
--gateway no -- Gateway, required only if ip address is specified.
--name-servers no 8.8.8.8 Comma delimited DNS servers, required only if ip address is specified.
--usb-boot no false Whether to make the remastered ISO usb bootable.
--reuse no false Whether to reuse existing original ISO in the workspace. If false, will download new one every time.
--debug no false Whether to print debug messages.
--output-format no text Format for the print out. {text,json}

Note Ubuntu 18.04 LTS now uses Subiquity as the default Live Server installer. The original pressed file no longer works. Instead, Subiquity uses a mechanism of answers.yaml to prepare answers to all installation questions. The file is supposed to be placed in squashfs-root/subiquity_config/. The squashfs-root can be obtained by un-squashing casper/filesystem.squashfs using unsquashfs. When modification is done, re-squash it using mksquashfs. This process should work, however, the subiquity project didn't provide examples as to how to configure static network. Hence, as of now, we are using a CD image download of Ubuntu 18.04 LTS which still ships with the old installer.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoProvider = shared.ErrorFactory(10)("no-provider-error")
)

Functions

func NewIsoAutoCommand

func NewIsoAutoCommand() *cobra.Command

Types

type Payload added in v0.2.0

type Payload struct {
	ExtraArgs
	Flavor      string `json:"flavor"`
	InputIso    string `json:"input_iso"`
	OutputIso   string `json:"output_iso"`
	Workspace   string `json:"workspace"`
	UsbBoot     bool   `json:"usb_boot"`
	Reuse       bool   `json:"reuse"`
	Timezone    string `json:"timezone"`
	Username    string `json:"username"`
	Password    string `json:"-"`
	Hostname    string `json:"hostname"`
	Domain      string `json:"domain"`
	IpAddress   string `json:"ip_address"`
	NetMask     string `json:"net_mask"`
	Gateway     string `json:"gateway"`
	NameServers string `json:"name_servers"`
}

type Provider added in v0.2.0

type Provider interface {
	// Name of the provider
	Name() string
	// Returns true if the supplied flavor is supported by this provider for processing.
	SupportsFlavor(flavor string) bool
	// Returns true if all the underlying package dependencies have been met.
	CheckDependencies(payload *Payload) (bool, error)
	// Process the ISO to create an unattended installation media
	RemasterISO(payload *Payload) (string, error)
}

Provider for creating unattended iso.

type UbuntuPreseedProvider added in v0.2.0

type UbuntuPreseedProvider struct{}

func (*UbuntuPreseedProvider) CheckDependencies added in v0.2.0

func (p *UbuntuPreseedProvider) CheckDependencies(payload *Payload) (bool, error)

func (*UbuntuPreseedProvider) Name added in v0.2.0

func (p *UbuntuPreseedProvider) Name() string

func (*UbuntuPreseedProvider) RemasterISO added in v0.2.0

func (p *UbuntuPreseedProvider) RemasterISO(payload *Payload) (string, error)

func (*UbuntuPreseedProvider) SupportsFlavor added in v0.2.0

func (p *UbuntuPreseedProvider) SupportsFlavor(flavor string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL