image:
  distribution: almalinux

source:
  downloader: almalinux-http
  url: https://almalinux.savoirfairelinux.net
  keys:
  # RPM-GPG-KEY-AlmaLinux-8
  - |-
    -----BEGIN PGP PUBLIC KEY BLOCK-----

    xsFNBGUlFG8BEADc0kEC57b722MbPVkI8aoYFAEWM+lj084H26msZpAYVfW7fCi5
    S7g3n6htVdvvnB6MrJANitZgQhMyC7tchNQz5sjrFffasNkOoI5Q27PSrG676ILP
    diowPWfJkwrN0f0UcJsV3w5KBedvUXJnoa64lP/oBFkbz3SvUTqZFkSBzOfCTdXW
    bvpZonghgm/AEU8wqsdOitXU23Xn4fsPB7aULgR31jz3irnaUDFXUnNqoiQpU6JB
    P6WiFqN/IZMH95HW1WlMBGSOalSbQUlNEND3J0lxK2a33UBmTdR3aLyS+o9P8+7b
    Cdzbkrs1fXXVxxvlaQdSWBSjVULUZjKIZ+HtqhIaTiBELa7JHBEBbEZgNHpymmc8
    hIF6fdTbzbbYx9MbNmpzCcr+SKHubCdvZyX2FsWK1CHvYx6iPc9wcu4x9yh8MIfp
    KpLSJG1SaSCHbUdatpsOSQK2pbIN3THsvFrKPVssLrMgVjwp22Q3vMFL+ldq0vZ5
    6uIIiNRKrX2CKKrUy1kF7FjDNMx4riaCQHs5vp7qOttxv0E/X4Z9B4QZdC02H2Mq
    Ea5LoDxONutv+JMzWFyxIEQvbnfdDSu4QUDkn3H1WkBNmqTUwny5DSxZNjGB8a6P
    ISaIE+kN2pp5v9eB8Q4+4BxbU2G2/Jy/V6bFC8eLL+PIKodPKbpCqoPyGwARAQAB
    zSdBbG1hTGludXggT1MgOCA8cGFja2FnZXJAYWxtYWxpbnV4Lm9yZz7CwY8EEwEI
    ADkWIQS8Xt3K31AsB38Vgogq6B6KztcliwUCZSUUbwIbAwQLCQgHAyICAQQVCgkI
    BBYCAwECHgcCF4AACgkQKugeis7XJYvOeA/9E/hJwfd7UPtvsv+y7Wiei1NCt+OJ
    AzJQPjEzHJNmLAD157AHtpA2yZpB9GlRQkjRu40fn0It20mwjnl0j5oHF9HnQ+/H
    Qtiw9pwgNpZJaTe5YnzETbGqrrOVgWihkJyJhn42vtuirNu7pKJvWilRvz1a81JK
    i/okezXp1KBrgrxR/bG26c8k61AK6n/ExI1MoHZhyaAAebFqG8vTiWTuC2a4t7SD
    pxbzsn5CMuXqVY1gxIdiUGzgrXfSm5WgpSYEG01VN+VF885caPvtMHoLBy/pLGN3
    5TKp4pKiA9JGQxtlZLdO666UbpgbjoxFYxNZEwY3Tdx37zbsP4pHcaN8fOGbk5mG
    h8LwkjppPZzoXONyBfUJ+uHBEzRJEw4KtVRgaZZfCcojRvmyJB4TAM1SYkikaw8F
    0gi3OPRWtVdEogxP0XD/tTrPSKo7pTDEk17HIyKCU0KxF4ZSbxXFMeH5OZUQAQM4
    l7ECGNg3bVhXC66AHE72mz/PN39M2Z0Sww7GWYCf6IDhhkeTxYx+I7VW1Uo9ht5L
    i3ZRMbX/h6NBYTUaPJEx3fwixNv2+RtE3m4JIxg76xBOYGLyIRlaImWNGKTnGz5m
    IBRP5Vm7nRdFOOFhNz+iDIyq0LEyhGU7xCriFaL+ozXLiIzycidgTTZW3WfkHxlr
    ZEzov/wIBeoaIp8=
    =kNaC
    -----END PGP PUBLIC KEY BLOCK-----

  # RPM-GPG-KEY-AlmaLinux-9
  - |-
    -----BEGIN PGP PUBLIC KEY BLOCK-----

    mQINBGHmnykBEACuIcqcNYTmu2q58XI5NRZowdJGAxxs+6ExX7qsa4vbPp6St7lB
    JmLpwf5p6czIBhLL4b8E7zJpu57tVDo7Ejw6Hv584rbI8vw7pnMTe6XUFhMTL8FT
    lyAmn8xAIlcyM+SzshnxAc5b8E0p/egMonr3J1QnvMSfixMQ59GrmLVyece7Vv3J
    4fREh6k31kg7eQdEkzRQhRdO2KyxWYLR0A6haXSXVaiBOjFF7iUs7anlJSfeD3FO
    afPq0Ix8oWi+mUc4txkABMdsGpdkE/MHOwN90FB8EG5XVrdv3emm3yzKMMzb53Yd
    jcf0fovIeRloQyl9+CrVCnkBjFcIFBZZddsB43kM7eTflmAQ+tanOZ8OKBRPMtmI
    56b/vk31ozHUoST/NmjbEI5tu+QYCuFSZ++mC06qJg0Bkw821DTAsM7Kynuj7K2f
    WWQjlDL9ZsFifLqDXRymL+sn6g142hHQOa5KSHtT7cAcrm6L48gEL3fPntVSOU/H
    BlTnODiSSTIsIRNA7kBkbSP3wWoYC1JQPmNYbUtZ7va2uXNb9dGT2k7Ae0465WND
    wqRQJDxsr6TLYFpti+JRaOpSMNclXz4kRSP263Y4ZzQvkMGgSgwqg7JU00Uahk2p
    KTlJAA8AiaMBdShlo/QXvL29Lyg0Y5klq2HCNziJDupWhXto5j5pjixrpwARAQAB
    tCdBbG1hTGludXggT1MgOSA8cGFja2FnZXJAYWxtYWxpbnV4Lm9yZz6JAk4EEwEI
    ADgWIQS/GKwodheJCNbnEmfTbLhsuGs3FgUCYeafKQIbAwULCQgHAgYVCgkICwIE
    FgIDAQIeAQIXgAAKCRDTbLhsuGs3FrvnD/9X1wDM/C214t3UVsMVjTLdIJDGG+iU
    E7Uk7QGeyeNif19rRatzXUHBBGjiAwpxe2rkveWBHCHPSUKqsAR9Arv3nMKiaGfA
    0nomzDndLEDIgv35xzaU6OhX95mZzvj+9PThuxDxUnsNoA+7vGkaiRw+cyyDdTJQ
    bKwum8bx1gS8Kbqo9mqrMekQ4NHCodq9bb2hI6pAxlYa472QuwFAXFAzbE3LIMIK
    hzLkew7nxwP0txP/zzqPw4lYN38fg9AlHL2qgf0twCFO4N/ftkw25qwoiBhiwaWT
    Ca8Z9wUJx35Z/ufscbNrtRrIGYNXTDFJdGY/WxKDp7QsyOx/sclcsSksKoC/52tL
    2yFLQrMXsqnLjAQajA6adaeCAAwvp2/8VP8R65O4KMuKghMneCGwXVlVVYyRUXJD
    Kjg7EvmmMGuh/Lj2A/vj+mQMmlS2kAl0qOsK9DtUIA7Z9m98zI3UmN/5BMb/HdqW
    KADagOW9IPyo6IaSIT+A+7npTN1Y7m1aIrL1vsAKrus4MrCvAs1vYqzqIikv88Di
    EWYVFCWTsTWf7jxBCVTLn1Lr7Mj08i+7OgRgguQGpcnvKsbwq1v2whQrs+YKR9hP
    vVaW5DmGJ5brPykJUaQS6p5Esp1q3HBk0HbBxiiGIwGsKbLp0pKsk5TLzMIJwIG/
    lEolCV+fJ0P4nLkCDQRh5p8pARAAvXTL29arJ5Dl9FXVpE4Km1jJLaK2WfbQARJz
    ygQKps9QNqS1yz7C7mYdTtgRxeK2eqcX5oA83w3ppJ0DTsxfAkY3nqAXS8+QRORU
    ffSFvhdsU1G/qpvhX0Aq62gr4y1bkIMr9GlLq86uVKIQrNdmto4NDfQc1bDD5e4j
    KaNMmNLXxq/s67AxFW/yLchYYZ7cMqQd6Ab4lacqpGdYFIAkBkVMmj3GUSo+FLpl
    +4c50AZ8O0aB+xkrjch+4PoVyIpIC1IuqNYBYn2wMYFB414QY2iDopzpZXUhpCqx
    NP4Zyhl1noUcOtH/wUfH1JsIcYRn0ixWF6JnE9KmjpkqBuM2/4Ot/bl67iPiN/if
    vf3Z1kYjNPaszoMW3kmJj8MlBCSH9w6nQRG/eikihbeUDBB6rh2O7Dz8ltFqlt8N
    asbngRoNZMnWMnItRV67Fo0pfn/DZA8VvI029apE21sNp6l7MUa8Z2/I/PNq10E8
    rPMQM//k9y2kgxz52i6iCyesobPvun6UC4xuFoYKUTQMgKQgqOhyZ4evkepFhmHg
    Gzx+F8EmwN1FtxfNxfLtQZSUT3kxuUDizwpaH/LkSkRXpJOQyHJL6VBINNTjB4j1
    3+0jD+lCV6xIt88NYkGJL9rtKwZLQHSDPiI0ooCJ69GKy8SmSx04AwSsY67In1q8
    +FQjT20AEQEAAYkCNgQYAQgAIBYhBL8YrCh2F4kI1ucSZ9NsuGy4azcWBQJh5p8p
    AhsMAAoJENNsuGy4azcW0KkP/i0YLRv+pDiSC4034oboczAnNrzJnBhqTi9cUEGn
    Xpqvf/Zz3opqvRQiqZAgVcCtxfW+P9J3Vb/mBJ6OkR/jywAlY5il2dzK08YfVXmP
    cEf6RF4M0KNtlYJmPlnQCZjMJaisrPmYD3Yy8ER1qJ5JQZ7n0REHZCbBCqH8w+5r
    j4ohEHY7xXbd7+tvWTCk2MkHaide/UV/04WiO064AoZSUze/vaAx8Ll4AyFpxuIk
    ktXZXbq7MaVzqYYJptiRB6TljzMwIbblLm9A7T7YTA/1rNe12OhDT8VoR3gG2C/l
    Mtf37EmYq3QVqFlbj4+ouQWIiQmp5dQenH5ugf+Bob7IiENpxzF1cIu6wd4p5Y64
    3cdYUoxrjhsCM6W1lSqECoN8yXJnRTxpBwwm65SVk477KS2h77aJfa+v5UnBhpSt
    eVlAhs0A8Qp/hX3o7qMO1jWca3zdJwXppLlFEYTVaFUOUrc4Lhlbi0gAnn8aBwSx
    xF1r5GhPGIBzHtRgulwZkmS6VwtDMuC6KlrASu9f93D5gLZqVk22Oar9LpgCEACd
    8Gw/+BFbdANqo9IKmDrWf7k/YuEqZ3h+eoyKI/2z7dKh/fcVEydMTn3LB4nFRvSD
    AZ27tvC0IUXCUNx7iJdrD5kDsMhZRl5/dXbe539G4y2W00QYuJC0DpUvGdtOuaFx
    1WKL
    =jk2t
    -----END PGP PUBLIC KEY BLOCK-----

  # RPM-GPG-KEY-AlmaLinux-10
  - |-
    -----BEGIN PGP PUBLIC KEY BLOCK-----

    mQINBGaP6O8BEACvg8IlAxGayV8zOi9Ex+Pd8lrj2BrBzloG8ri84ORp9o8ojq7l
    ykKmIElHe11cQD2Lf/a4lcQQ4Ec3baiD786X6K2eVSlBEAnZMzfjDg8R63SfsBuu
    8Yk+lUyqlBrDnSDYaPruOAzLIz2r82ikIC1jDbipZsMFPFHPI4/hayyWxJ3oGxRe
    0mbtYLB9ElEKngt+/hfo7JLklakbznyIRuVEF3VrZb91XC6r/idqfJoNyBXSKidj
    z0IwqOhgkLUk84rzltDo3AzwGqusd7PEuhOmqinOhp0hMdXsztD4TVyhw82iXu/O
    onOAObZTZYfM6Z8btmDqkoo0aT+oPPCuZ3yC/caU9dhvCSXET/CGoXc3hL55u9PV
    qmcVm/mwvuEImEAvxVc0/dBzEUk+FwW8KsaN3HoUKrC4/NqgmaQz8/42np7u2j+B
    OOJ4hAckNEdWd8rB86CYN00sdxnvLBsp8V3IwEqXLhGOoBsagy61Z8hKCM+siOGn
    xmbbybgaLOs+DPlxt9LrtgLJHODwmD96oysUPJuA0lv8KMiSpId0tSpp9Wn/wHBG
    kRgxGYfzQu7WRvRZqQaleft1JTXXOjNzPur0RkJyb3yFwAoxpePyo/WrupM41OHW
    58cEqdC6riCnJcS4U84RLj+hwvufBVB7areQ75sETnKeyozZW+P16E1t/wARAQAB
    tChBbG1hTGludXggT1MgMTAgPHBhY2thZ2VyQGFsbWFsaW51eC5vcmc+iQJMBBMB
    CgA2FiEE7m23uY9b9e3Z2g3l3uXBHMKh5XIFAmaP6O8CGwMECwkIBwQVCgkIBRYC
    AwEAAh4FAheAAAoJEN7lwRzCoeVy32AP/A2+KI+JhmsxnactSptkAWGyAAf1YBWW
    Js2sc9OJdKj7uIkzszCx7c7VIVeF/VLijIYpM/zwUgir5S5SimzQmY+FumwbKIml
    K5RBsoSog22i7Edho0MLa1pa6qvnKS0nkl9DEcu8EbMUhucWbxGnCG/22EEMTrY+
    Si1IZNkDGtlBHHBKMC+STbqqTxtdy4tAd2NYwWh3sBIh6PF7T4NLRAugu7PZQr5K
    amS4z2lV3ebshGjieA0Zoznwh0AXgN0gZ/0pC/LXI25gcgtrvkCyL8Fe0AyZUMd8
    UvZXaRSsm3SkCUIlGjPrvuItn1D7tHmqVSCDKXDM2TqjfiRm1JF+2OFCBNvGz19V
    LxWd/Gf+0qw0dtKxRMKzGh0mxXY40hjtmYZulrPxhG5itNDjStovgrevM1HBsXs9
    ikrkOGQ0pFcqizTn4ZKAmMozEMuIuV89Vof2bBCg7pHT1FmXVdAaYJxb6a7A/CgN
    qHjoh8AxBiGw/Q2NM4YJlUVhHqqd+/lUG3WJqACNEnqSlZkYQ3HqNNaKhHVbD4mN
    q/g6v+f8aWWDZDsI6IAfbJUB+KPEnIvQJQleWuHrq7kcUMhEq3dwBMIoTVEHhUUr
    RQKToSEM1rN7PcanaXQM2gy141dS7tFLxhapG8ug75LkIUnEOpPMtUjvrU1ZELGq
    36vVHBB+dTDg
    =tJCw
    -----END PGP PUBLIC KEY BLOCK-----
  variant: minimal

targets:
  lxc:
    create_message: |
      You just created a {{ image.description }} container.
    config:
    - type: all
      before: 5
      content: |-
        lxc.include = LXC_TEMPLATE_CONFIG/almalinux.common.conf

    - type: user
      before: 5
      content: |-
        lxc.include = LXC_TEMPLATE_CONFIG/almalinux.userns.conf

    - type: all
      after: 4
      content: |-
        lxc.include = LXC_TEMPLATE_CONFIG/common.conf

    - type: user
      after: 4
      content: |-
        lxc.include = LXC_TEMPLATE_CONFIG/userns.conf

    - type: all
      content: |-
        lxc.arch = {{ image.architecture_kernel }}

files:
- name: hostname
  path: /etc/hostname
  generator: hostname

- name: hosts
  path: /etc/hosts
  generator: hosts

- path: /etc/machine-id
  generator: dump
  content: uninitialized

- path: /var/lib/dbus/machine-id
  generator: remove

- name: ifcfg-eth0
  path: /etc/sysconfig/network-scripts/ifcfg-eth0
  generator: dump
  templated: true
  content: |-
    DEVICE=eth0
    BOOTPROTO=dhcp
    ONBOOT=yes
    HOSTNAME=LXC_NAME
    TYPE=Ethernet
    MTU=
    DHCP_HOSTNAME=LXC_NAME
  types:
  - container

- name: ifcfg-eth0.incus
  path: /etc/sysconfig/network-scripts/ifcfg-eth0
  generator: template
  content: |-
    DEVICE=eth0
    BOOTPROTO=dhcp
    ONBOOT=yes
    HOSTNAME={{ container.name }}
    TYPE=Ethernet
    MTU=
    DHCP_HOSTNAME={{ container.name }}
    IPV6INIT=yes
  types:
  - container

- path: /etc/default/grub
  generator: dump
  content: |-
    # Set the recordfail timeout
    GRUB_RECORDFAIL_TIMEOUT=0
    # Do not wait on grub prompt
    GRUB_TIMEOUT=0
    # Set the default commandline
    GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} console=tty1 console=ttyS0"
    # Set the grub console type
    GRUB_TERMINAL=console
    # Disable os-prober
    GRUB_DISABLE_OS_PROBER=true
  types:
  - vm

- path: /etc/dracut.conf.d/incus.conf
  generator: dump
  content: |-
    add_drivers+=" virtio_scsi virtio_console sd_mod "
  types:
  - vm

- generator: fstab
  types:
  - vm

- name: 86-nm-unmanaged.rules
  path: /etc/udev/rules.d/86-nm-unmanaged.rules
  generator: dump
  content: |-
    ENV{ID_NET_DRIVER}=="veth", ENV{NM_UNMANAGED}="0"

- name: network
  path: /etc/sysconfig/network
  generator: dump
  templated: true
  content: |-
    NETWORKING=yes
    HOSTNAME=LXC_NAME

- name: network.incus
  path: /etc/sysconfig/network
  generator: template
  content: |-
    NETWORKING=yes
    HOSTNAME={{ container.name }}

- name: meta-data
  generator: cloud-init
  variants:
  - cloud

- name: network-config
  generator: cloud-init
  content: |-
    {% if config_get("user.network-config", "") == "" %}version: 1
    config:
      - type: physical
        name: {% if instance.type == "virtual-machine" %}enp5s0{% else %}eth0{% endif %}
        subnets:
          - type: {% if config_get("user.network_mode", "") == "link-local" %}manual{% else %}dhcp{% endif %}
            control: auto
          - type: dhcp6
            control: auto{% else %}{{ config_get("user.network-config", "") }}{% endif %}
  variants:
  - cloud

- name: user-data
  generator: cloud-init
  variants:
  - cloud

- name: vendor-data
  generator: cloud-init
  variants:
  - cloud

- generator: incus-agent
  types:
  - vm

packages:
  manager: yum
  update: true
  cleanup: true
  sets:
  - packages:
    - cronie
    - cronie-noanacron
    - curl
    - glibc-langpack-en
    - glibc-locale-source
    - hostname
    - initscripts
    - iproute
    - openssh-clients
    - passwd
    - policycoreutils
    - rootfiles
    - rsyslog
    - sudo
    - vim-minimal
    action: install

  - packages:
    - dhclient
    action: install
    releases: # dhclient is not available in 10
    - 8
    - 9

  - packages:
    - network-scripts
    action: install
    types:
    - container
    variants:
    - default
    releases:
    - 8

  - packages:
    - NetworkManager
    action: install
    types:
    - vm
    variants:
    - default

  - packages:
    - cloud-init
    - NetworkManager
    action: install
    variants:
    - cloud

  - packages:
    - NetworkManager
    action: install
    types:
    - container
    releases:
    - 9
    - 10
    variants:
    - default

  - packages:
    - cloud-utils-growpart
    action: install
    types:
    - vm
    variants:
    - cloud

  - packages:
    - shim
    action: install
    types:
    - vm

  - packages:
    - kernel
    action: install
    types:
    - vm

  - packages:
    - grub2-efi-x64
    action: install
    types:
    - vm
    architectures:
    - x86_64
    - x86_64_v2

  - packages:
    - grub2-efi-aarch64
    action: install
    types:
    - vm
    architectures:
    - aaarch64

actions:
- trigger: post-unpack
  action: |-
    #!/bin/sh
    # Make sure we have our template targets
    touch /etc/hosts
    touch /etc/hostname

- trigger: post-unpack
  action: |-
    #!/bin/sh
    # Generate machine-id in order for the kernel stuff to be configured properly
    systemd-machine-id-setup
  types:
  - vm

- trigger: post-packages
  action: |-
    #!/bin/sh
    set -eux

    # Disable SELinux
    mkdir -p /selinux
    echo 0 > /selinux/enforce

    # Disable loginuid in PAM stack
    sed -i '/^session.*pam_loginuid.so/s/^session/# session/' /etc/pam.d/*

    # Set default locale
    localedef -i en_US -f UTF-8 en_US.UTF-8
    echo 'LANG=en_US.utf8' > /etc/locale.conf

    # Disable first boot wizard
    systemctl mask systemd-firstboot.service

- trigger: post-files
  action: |-
    #!/bin/sh
    set -eux

    # Regenerate initramfs
    kver=$(ls /boot/initramfs-*.img | sed -r 's#.*initramfs-(.+)\.img#\1#')
    dracut --kver "${kver}" -f

    target="$(readlink -f /etc/grub2-efi.cfg)"
    grub2-mkconfig -o "${target}"

    sed -i "s#root=[^ ]*#root=${DISTROBUILDER_ROOT_UUID}#g" "${target}"
  types:
  - vm
  releases:
  - 8

- trigger: post-files
  action: |-
    #!/bin/sh
    set -eux
    kver=$(ls /boot/initramfs-*.img | sed -r 's#.*initramfs-(.+)\.img#\1#')
    target=/boot/efi/EFI/almalinux/grub.cfg

    # Create grub.cfg file
    grub2-mkconfig -o "${target}"
    sed -i "s#root=[^ ]*#root=${DISTROBUILDER_ROOT_UUID}#g" "${target}"

    # Update files in /boot/loader/entries/. `grubby` needs to be run after
    # `grub2-mkconfig` as the latter overwrites files in /boot/loader/entries/.
    grubby --update-kernel=/boot/vmlinuz-${kver} --args="root=${DISTROBUILDER_ROOT_UUID} ro"

    # Regenerate initramfs
    dracut --kver "${kver}" -f
  types:
  - vm
  releases:
  - 9

- trigger: post-files
  action: |-
    #!/bin/sh
    set -eux

    # Track down the kernel
    kver=$(basename /boot/initramfs-*.img | sed -r 's#initramfs-(.+)\.img#\1#' | head -n1)
    if [ -z "$kver" ]; then
      echo "No initramfs found in /boot!" >&2
      exit 1
    fi

    kernel_path=$(find /boot -name "vmlinuz-${kver}" || true)
    if [ -z "$kernel_path" ]; then
      echo "Kernel image /boot/vmlinuz-${kver} not found!" >&2
      ls -l /boot >&2
      exit 1
    fi

    # Track down the root disk
    root_dev=$(df / | tail -n1 | awk '{print $1}')
    if [ -b "$root_dev" ]; then
      root_uuid=$(blkid -s UUID -o value "$root_dev")
      if [ -z "$root_uuid" ]; then
        echo "Failed to get UUID for $root_dev" >&2
        exit 1
      fi
    else
      echo "Error: Root device $root_dev not found!" >&2
      exit 1
    fi

    # Re-generate the initrd
    . /etc/os-release
    GRUB_ENTRY_NAME="${NAME} ${VERSION} ${kver}"
    dracut --kver "${kver}" -f --no-hostonly --add-drivers "virtio_scsi virtio_console sd_mod ext4 virtio_blk virtio_pci scsi_mod" --install "blkid"


    # Track down the EFI partition
    disk_dev=$(lsblk -no pkname "$root_dev" | head -n1)
    if [ -z "$disk_dev" ]; then
      echo "Failed to find disk device for $root_dev" >&2
      exit 1
    fi
    disk_dev="/dev/$disk_dev"

    efi_part="${disk_dev}p1"
    if [ ! -b "$efi_part" ]; then
      echo "EFI partition $efi_part not found!" >&2
      exit 1
    fi

    # Generate the grub configuration
    mkdir -p /mnt/efi
    mount "$efi_part" /mnt/efi

    mkdir -p /mnt/efi/EFI/almalinux
    cat > "/mnt/efi/EFI/almalinux/grub.cfg" <<EOF
    set timeout=5
    set default=0

    menuentry '${GRUB_ENTRY_NAME}' {
        set root=(hd0,gpt2)
        linux /boot/vmlinuz-${kver} root=UUID=${root_uuid} ro console=tty1 console=ttyS0
        initrd /boot/initramfs-${kver}.img
    }

    menuentry 'UEFI Firmware Settings' {
        fwsetup
    }
    EOF

    umount /mnt/efi
    mkdir -p /boot/grub2
    touch /boot/grub2/grubenv
  types:
  - vm
  releases:
  - 10

- trigger: post-files
  action: |-
    #!/bin/sh
    set -eux

    systemctl enable NetworkManager.service
  types:
  - vm
  variants:
  - default

- trigger: post-files
  action: |-
    #!/bin/sh
    set -eux

    mkdir -p /etc/NetworkManager/conf.d/
    printf "[main]\ndhcp=internal\n" > /etc/NetworkManager/conf.d/dhcp-client.conf

    systemctl enable NetworkManager.service
  types:
  - container
  variants:
  - default
  releases:
  - 10

- trigger: post-files
  action: |-
    #!/bin/sh
    set -eux

    mkdir -p /etc/NetworkManager/conf.d/
    printf "[main]\ndhcp=dhclient\n" > /etc/NetworkManager/conf.d/dhcp-client.conf

    systemctl enable NetworkManager.service
  types:
  - container
  variants:
  - default
  releases:
  - 9

- trigger: post-files
  action: |-
    #!/bin/sh
    set -eux

    systemctl enable network
  types:
  - container
  variants:
  - default
  releases:
  - 8
