#cloud-config
autoinstall:
  version: 1
  identity:
    hostname: vagrant
    username: vagrant
    password: '$6$rounds=4096$5CU3LEj/MQvbkfPb$LmKEF9pCfU8R.dA.GemgE/8GT6r9blge3grJvdsVTMFKyLEQwzEF3SGWqAzjawY/XHRpWj4fOiLBrRyxJhIRJ1'
  early-commands:
    # otherwise packer tries to connect and exceed max attempts:
    - systemctl stop ssh.service
    - systemctl stop ssh.socket
  ssh:
    install-server: yes
    allow-pw: yes
  late-commands:
      - 'sed -i "s/dhcp4: true/&\n      dhcp-identifier: mac/" /target/etc/netplan/00-installer-config.yaml'
      - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/vagrant
      # Enable hyper-v daemons only if using hyper-v virtualization
      - if [ $(virt-what) == "hyperv" ]; then apt-get update && apt-get install -y hyperv-daemons linux-tools-$(uname -r) linux-cloud-tools-$(uname -r) linux-cloud-tools-common cifs-utils && systemctl enable hypervvssd && systemctl enable hypervkvpd && systemctl start hypervvssd && systemctl start hypervkvpd; fi