Autoinstall-generator - tool to help with creation of autoinstall files based on preseed

Greetings all!

We’ve done some work lately to make it a bit easier to transition from Debian Installer to Subiquity. Those of you using preseed files may be interested in the new tool autoinstall-generator, available now as a Snap.

This work is being released with basic functionality in place - we know more things can be done here, and wanted to release and collect feedback.

In particular, it is understood that the preseed format supports things such as partitioning and network handling in more complicated ways than autoinstall-generator supports today.

Usage:

usage: autoinstall-generator.py [-h] [-c] [-d] [-V] infile [outfile]

positional arguments:
  infile         Debian install preseed file, or a dash to read stdin
  outfile        Subiquity autoinstall yaml

optional arguments:
  -h, --help     show this help message and exit
  -c, --cloud    output in cloud-config format
  -d, --debug    include commented out debug output explaining the conversions
                 performed
  -V, --version  show version and exit

Examples:

autoinstall-generator my-preseed.txt my-autoinstall.yaml

This basic usage will convert the preseed file to the autoinstall format.

autoinstall-generator my-preseed.txt my-cloud-config.yaml --cloud

This usage will convert the preseed file to the cloud-config format with the autoinstall data contained within the autoinstall section. Depending on how the data will be loaded to the installer, it may be needed in autoinstall or in cloud-config formats.

autoinstall-generator my-preseed.txt my-autoinstall.yaml --debug

This usage adds debug information to the end of the yaml in the form of comments.

The debug output looks like this:

#   4:   Directive: d-i debian-installer/locale string en_US
#        Mapped to: locale: en_US

This represents a single-line directive that was recognized and mapped to an Autoinstall equivalent. The ‘4’ indicates that the directive was found on line 4 of the input.

#   7: Unsupported: d-i debian-installer/language string en

Other directives are known to be unsupported, and are marked as such.

#  52:   Directive: d-i netcfg/get_ipaddress string 192.168.1.42
#  53:         And: d-i netcfg/get_netmask string 255.255.255.0
#        Mapped to: network:
#                     ethernets:
#                       any:
#                         addresses:
#                         - 192.168.1.42/24
#                         match:
#                           name: en*
#                     version: 2

Some directives get combined into a single section, such as the two netcfg items above.

# 436:   Directive: pkg-a pkg-a/my-q boolean false                                                                                   
# 437:         And: pkg-b pkg-a/my-other-q boolean true                                                                              
#        Mapped to: debconf-selections: |                                                                                            
#                     pkg-a pkg-a/my-q boolean false                                                                                 
#                     pkg-b pkg-a/my-other-q boolean true                                                                            

It will also pass along directives believed to be out of scope for the installer to the debconf-selections section. Note that the above are just fake examples and not real debconf selections.

An introduction to the autoinstall format can be found at https://ubuntu.com/server/docs/install/autoinstall. See also the quickstart guide and the Autoinstall file format reference.

I look at this as a work in progress so please share your thoughts.

Github: https://github.com/canonical/autoinstall-generator

Bugs & Feature requests: feel free to discuss below, or report on launchpad.

5 Likes

Can you input a kickstart config and convert it as well?

No kickstart support at this point - it’s something we’ve considered though.

1 Like

Does this tool also create the autoinstall files without the need for a already created preseed file?

No, autoinstall-generator assumes you’re bringing in preseed files and converts them, it won’t create autoinstalls from scratch. What you’re talking is something we have a design for but haven’t scheduled yet called autoinstall-editor.

I appreciate the feedback @andrewm659.

2 Likes

I am trying to follow your documentation without success.
/snap/bin/autoinstall-generator uefi.seed eufi.yaml
usage: autoinstall-generator [-h] [-c] [-d] [-V] infile [outfile]
autoinstall-generator: error: argument outfile: can’t open ‘eufi.yaml’: [Errno 13] Permission denied: ‘eufi.yaml’
me@USFRYLNCN16MMKF:/media/me/disk2/local_repo/cubic$ /snap/bin/autoinstall-generator uefi.seed eufi.yaml --debug
usage: autoinstall-generator [-h] [-c] [-d] [-V] infile [outfile]
autoinstall-generator: error: argument outfile: can’t open ‘eufi.yaml’: [Errno 13] Permission denied: ‘eufi.yaml’
mer@USFRYLNCN16MMKF:/media/me/disk2/local_repo/cubic$ /snap/bin/autoinstall-generator uefi.seed eufi.yaml --cloud
usage: autoinstall-generator [-h] [-c] [-d] [-V] infile [outfile]
autoinstall-generator: error: argument outfile: can’t open ‘eufi.yaml’: [Errno 13] Permission denied: ‘eufi.yaml’

Any idea what is wrong?

Sounds like we need to tweak some permissions on the snap.
@mikefrygm - If you write your outfile to a different directory, does that work better?

I have tried two different directories and also with sudo. Same error.

yeah, for /media you want to add the removable-media plug (note though that this is not auto-connected and usually also not granted easily for auto-connecting by the snap reviewers so users would still have to run snap connect autoinstall-generator:removable-media to make use of it)

looking at the snap it has the home plug auto-connected … so all of the excuting users home dir as well as ~/snap/autoinstall-generator/current and~/snap/autoinstall-generator/common should be accessible by the tool (note that sudo will mess this setup up and you would need to point to /root)

1 Like

@ogra - thanks for the tips on plugs, I need to look into that more. Though it sounds like removable-media is a more esoteric plug and I might not want to if the user still has to take manual steps.

@mikefrygm - would you try writing our output file to $HOME?

I have moved my uefi.seed to $HOMEDIR. My command is /snap/bin/autoinstall-generator uefi.seed uefi.yaml

Output:
> Traceback (most recent call last):
> File “/snap/autoinstall-generator/64/usr/bin/autoinstall-generator”, line 56, in
> sys.exit(main())
> File “/snap/autoinstall-generator/64/usr/bin/autoinstall-generator”, line 47, in main
> out = convert_file(infile, args)
> File “/snap/autoinstall-generator/64/lib/python3.6/site-packages/autoinstall_generator/merging.py”, line 212, in convert_file
> validate_yaml(result_dict)
> File “/snap/autoinstall-generator/64/lib/python3.6/site-packages/autoinstall_generator/merging.py”, line 167, in validate_yaml
> jsonschema.validate(tree, schema)
> File “/snap/autoinstall-generator/64/usr/lib/python3/dist-packages/jsonschema/validators.py”, line 541, in validate
> cls(schema, *args, **kwargs).validate(instance)
> File “/snap/autoinstall-generator/64/usr/lib/python3/dist-packages/jsonschema/validators.py”, line 130, in validate
> raise error
> jsonschema.exceptions.ValidationError: ‘hostname’ is a required property
>
> Failed validating ‘required’ in schema[‘properties’][‘identity’]:
> {‘additionalProperties’: False,
> ‘properties’: {‘hostname’: {‘type’: ‘string’},
> ‘password’: {‘type’: ‘string’},
> ‘realname’: {‘type’: ‘string’},
> ‘username’: {‘type’: ‘string’}},
> ‘required’: [‘username’, ‘hostname’, ‘password’],
> ‘type’: ‘object’}
>
> On instance[‘identity’]:
> {‘password’: ‘$6$jm5wpqj7$47TOjpgCmeYWMHZmpI2esB7PxHCPYu.UD05lNW9N1s7SZD4WcM6EO0ybE0isYa11rbpS7B7OUlXUFAd5GaiwC/’,
> ‘realname’: ‘General Motors’,
> ‘username’: ‘gmuser’}

Well that error is not terribly helpful!

Your example is complaining that the ‘identity’ field is missing a value for ‘hostname’ in the resulting autoinstall data. But it doesn’t show the autoinstall data to really know this.

I’ve pushed a fix to the beta channel. You can pick that up with the command

snap refresh --beta autoinstall-generator

With this fixed version it should give you some better data. And the above crash is now softened to a warning that should look like:

# Warning: resulting autoinstall is missing required data
# 'hostname' is a required property