#cloud-config
autoinstall:
  version: 1
  locale: en_US
  keyboard:
    layout: {{ config.keyboard_layout }}
  refresh-installer:
    update: false
  ssh:
    install-server: true
    allow-pw: true
    disable_root: true
    ssh_quiet_keygen: true
    allow_public_ssh_keys: true
  packages:
{% if config.ubuntu_version == 'ubuntu-20-04-server' %}
    - sudo
{% else %}
    - qemu-guest-agent
{% endif %}
  storage:
    layout:
      name: direct
    swap:
      size: 0
  user-data:
    package_upgrade: false
    timezone: {{ config.timezone }}
    users:
      - name: {{ config.ssh_username }}
        plain_text_passwd: 'pwd'
        groups: [adm, sudo]
        lock-passwd: false
        sudo: ALL=(ALL) NOPASSWD:ALL
        shell: /bin/bash
        ssh_authorized_keys:
          - {{ config.ssh_public_key }}
{% if config.ubuntu_version == 'ubuntu-20-04-server' %}
  late-commands:
    - curtin in-target -- apt-get update
    - curtin in-target -- apt-get install qemu-guest-agent
{% endif %}