#StackBounty: #qemu #proxmox #terraform #coreos #cloud-init Cloud Init with Flatcar Linux — Configuration not applying when passing cu…

Bounty: 50

I’m using Telmate’s Terraform provider for Proxmox and trying to deploy Flatcar linux virtual machines using Cloud Init by passing files via cicustom. Based on their example, I have crafted the following Terraform file:

variable "pve_user" {
}
variable "pve_password" {
}
variable "pve_host" {
}

provider "proxmox" {
  pm_tls_insecure = true
  pm_api_url      = "https://SNIP/api2/json"
  pm_user         = "SNIP"
  pm_password     = "SNIP"
  pm_parallel     = 4
}

resource "null_resource" "cloud_init_config_files" {
  connection {
    type     = "ssh"
    user     = var.pve_user
    password = var.pve_password
    host     = var.pve_host
  }

  provisioner "file" {
    source      = "./templates/cloud-config.yml"
    destination = "/var/lib/vz/snippets/cloud-config.yml"
  }
}

resource "proxmox_vm_qemu" "k8s-masters" {
  depends_on = [
    null_resource.cloud_init_config_files
  ]

  count      = 1
  name       = "VM-${count.index}"
  clone      = "VM-Template"
  full_clone = true

  target_node = "192.168.20.10"
  pool        = "VM"

  cores   = 2
  sockets = 1
  memory  = 10240

  network {
    id     = 0
    model  = "virtio"
    bridge = "vmbr0"
    tag    = 50
  }

  disk {
    id           = 0
    type         = "scsi"
    size         = 30
    storage      = "Pool"
    storage_type = "zfspool"
    backup       = true
    iothread     = true
  }

  onboot = true
  agent  = 1

  os_type         = "cloud-init"
  ssh_user        = "core"
  cicustom  = "user=local:snippets/cloud-config.yml"
  ipconfig0 = "ip=192.168.50.10/24,gw=192.168.50.1"

  sshkeys = "ssh-rsa SNIP"
  ssh_private_key = <<EOF
-----BEGIN RSA PRIVATE KEY-----
SNIP
-----END RSA PRIVATE KEY-----
EOF
}

After running terraform apply, the VM is successfully created and Flatcar is bootstrapped. If you connect to the console via Proxmox, however, the VM shows that the IP Address is one received via DHCP instead of the one I provided. Furthermore, the SSH key does not work so I am unable to connect to the VM to troubleshoot.

If I comment out the cicustom line, and simply rely on ipconfig0 and the other normal options, the VM comes up and my SSH key does in fact work. However, the specified IP address is still not used; the VM just uses one provided by DHCP instead. Despite being able to access the VM, I still want to use a custom Cloud Init config file so I can have access to more powerful configuration options.

I’ve tried various combinations of my cloud-config.yml file. Including things as simple as:

hostname: test

to things more detailed like:

storage:
  files:
    - path: /opt/file1
      filesystem: root
      contents:
        inline: Hello, world!
      mode: 0644
      user:
        id: 500
      group:
        id: 501
passwd:
  users:
    - name: core
      ssh_authorized_keys:
        - ssh-rsa SNIP

Despite all of this, my SSH keys never work after I pass something to cicustom and, based on the fact that the hostname is never manipulated, I’m assuming Cloud Init just outright isn’t receiving the custom config file at all. I’ve tried passing in both Ignition and Container Linux Config formatted files.

Is Flatcar Linux broken with Proxmox/cicustom? Searching Google for things like "flatcar" "proxmox", "coreos" "proxmox", "container linux" "proxmox", "flatcar" "cicustom", etc don’t seem to turn up much results. I guess there aren’t a lot of people out there bridging Cloud Native operating systems with bare metal? hehehe

What does come up, however, is this interesting script. Lines 104-132 discuss creating a Flatcar/CoreOS template for Proxmox. So someone else has done this before, at least? Who knows if they passed in a custom cloud init config file afterwards?

Any ideas?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.