Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Packer Autoinstall French Language & Keyboard Layout

I’m trying to make a Proxmox template using Packer and I’ve been struggling to make it choose the French Language.

Here’s a portion of my user-data file :

autoinstall:
  version: 1
  locale: fr_FR
  keyboard:
    layout: fr

It’s stuck in here:
enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I went through packer docs and couldn’t find any piece of documentation about that user-data file :/ Anyone knows where I can get this information please ?

>Solution :

Packer its self doesnt know or care what a user-data file is. That is something thats OS specific for example like in ubuntu https://ubuntu.com/server/docs/install/autoinstall-reference#user-data. Where as other OS like windows or RHEL might have a different method to setup a system. Using the ubuntu example the way I have done this previously is with a setup like below.

In my case I am using vsphere but the idea should work on other sources like AWS EBS etc. I also have a setup.sh script I run as part of the build to configure a few other things after the system is bootstrapped

/ubuntu20.04
  /config-files
    user-data
    meta-data
  /setup
    setup.sh
  template.pkr.hcl
  var.pkr.hcl

user-data

#cloud-config
autoinstall:
    version: 1
    early-commands:
        # Stop ssh for packer
        - sudo systemctl stop ssh
    locale: en_GB
    keyboard:
        layout: en
        variant: gb
# plus other stuff in my setup

setup.sh

#!/bin/bash

echo '> Cleaning all audit logs ...'
if [ -f /var/log/audit/audit.log ]; then
cat /dev/null > /var/log/audit/audit.log
fi
if [ -f /var/log/wtmp ]; then
cat /dev/null > /var/log/wtmp
fi
if [ -f /var/log/lastlog ]; then
cat /dev/null > /var/log/lastlog
fi

echo '> Cleaning apt-get ...'
apt-get clean
# Cleans the machine-id.
echo '> Cleaning the machine-id ...'
truncate -s 0 /etc/machine-id
rm /var/lib/dbus/machine-id
ln -s /etc/machine-id /var/lib/dbus/machine-id

template.pkr.hcl

source "vsphere-iso" "ubuntu" {

  cd_files = [
    "./config-files/user-data",
    "./config-files/meta-data"
  ]
  cd_label = "cidata"
  boot_order   = "disk,cdrom,floppy"
  boot_wait    = "3s"
  boot_command = [
    "<esc><esc><esc>",
    "<enter><wait>",
    "/casper/vmlinuz ",
    "root=/dev/sr0 ",
    "initrd=/casper/initrd ",
    "autoinstall ",
    "ds=nocloud-net;",
    "<enter>"
  ]
  shutdown_command = "echo '${var.ssh_password}' | sudo -S -E shutdown -P now"
  shutdown_timeout = "15m"

  #
  #some other stuff 
  #
}

build {
  sources = ["source.vsphere-iso.ubuntu"]

  provisioner "shell" {
    execute_command  = "echo '${var.ssh_password}' | {{.Vars}} sudo -S -E bash '{{.Path}}'"
    environment_vars = [
      "BUILD_USERNAME=${var.ssh_username}",
    ]
    scripts           = ["./setup/setup.sh"]
    expect_disconnect = true
  }
}

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading