Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cloud-init for proxmox-api-go #339 #1049

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

Tinyblargon
Copy link
Collaborator

@Tinyblargon Tinyblargon commented Jun 19, 2024

Makes terraform compatible with Telmate/proxmox-api-go#339.

Add ciupgrade property. (required work upstream)
fixes #997 (Tested)

When network is set in cicustom we continue with trying to get the ip. (required work upstream)
fixes #1011

searchdomain, nameserver, ipconfig0-15 can now be removed. (required work upstream)
fixes #1042 (Tested)

restart VM when `ciupgrade` is set from `false` to `true` and the VM is running
@Tinyblargon
Copy link
Collaborator Author

Currently broken for PVE versions lower than 8.0.0 Telmate/proxmox-api-go#344

@maksimsamt
Copy link
Contributor

@Tinyblargon,
Maybe it makes sense to release this change in rc4?

@Tinyblargon Tinyblargon merged commit fee4a3d into Telmate:master Jul 26, 2024
1 check passed
@gbrackley
Copy link

@Tinyblargon I'm getting the following warning with v3.0.1-rc4:

╷
│ Warning: Cloud-init is enabled but no IP config is set
│
│   with module.flatcar_sample.proxmox_vm_qemu.proxmox_flatcar_vm[0],
│   on ..\..\main.tf line 73, in resource "proxmox_vm_qemu" "proxmox_flatcar_vm":
│   73: resource "proxmox_vm_qemu" "proxmox_flatcar_vm" {
│
│ Cloud-init is enabled in your configuration but no static IP address is set, nor is the DHCP option enabled
╵

I have a configuration that does have a network configuration, but no cloud-init (I'm using ignition/butane).

Looking at the code, it appear that the warning is in response to a cloud-init without a network configuration. The abridged code reads:

    if config.CloudInit != nil {
		... < various other stuff deleted> ...
				return primaryIPs{}, diag.Diagnostics{diag.Diagnostic{
					Severity: diag.Warning,
					Summary:  "Cloud-init is enabled but no IP config is set",
					Detail:   "Cloud-init is enabled in your configuration but no static IP address is set, nor is the DHCP option enabled"}}
			}
		}
	}

The new code for initialising conf.CloudInit reads:

CloudInit:      mapToSDK_CloudInit(d),

The function mapToSDK_CloudInit doesn't seem to have a code path that returns nil. This means the warning will be reported regardless of there is a cloud-init configured. Am I missing something? Is this by design?

@Tinyblargon
Copy link
Collaborator Author

Tinyblargon commented Sep 2, 2024

@gbrackley By design, a warning about the network configuration is given when the following is true:

There is a cloud-init disk.
A network adapter is configured.
Cloud-init network config is missing.
skip_ipv4 && skip_ipv6 are false.

@gbrackley
Copy link

There is a cloud-init disk.

This is the condition I am unclear on. As mentioned above, I don't have a cloud-init disk referenced by the VM. Looking at the tfstate and the vm configuration (below), I can see that cipassword is being round tripped to a non-empty value (but not set by me) - I'm assuming that an empty string is being crypted.

What is it in this configuration that says there is a cloud-init disk? I am reluctant to falsely call bug, but it looks like the function to map the configuration doesn't take into account that there is no cloud-init and returns an empty cloud-init rather than a nil cloud init. The warning code looks for a nil cloud-init rather than an empty cloud-init.

tfstate partial

 "attributes": {
            "additional_wait": 5,
            "agent": 1,
            "agent_timeout": null,
            "args": "-fw_cfg name=opt/org.flatcar-linux/config,file=/etc/pve/local/ignition/990.ign",
            "automatic_reboot": true,
            "balloon": 0,
            "bios": "ovmf",
            "boot": "order=scsi0",
            "bootdisk": "",
            "ci_wait": null,
            "cicustom": null,
            "cipassword": "",
            "ciupgrade": false,
            "ciuser": "",
            "clone": "flatcar-production-qemu-stable-3815.2.2",
            "clone_wait": 0,
            "cores": 2,
            "cpu": "host",

example vm config

/etc/pve/local/qemu-server/990.cfg

#An example **Flatcar** Linux VM provisioned using Terraform.
#
#
#A VM provisioned with Terraform from template flatcar-production-qemu-stable-3815.2.2 on 2024-09-02T07%3A20%3A36Z
#
### Configuration
#
#```
#hook-script%3A local%3Asnippets/cloudinit-to-ignition
#cloud-init%3A local%3Aiso/tf-ci-flatcar-terraform.example.com.iso
#```
agent: 1
args: -fw_cfg name=opt/org.flatcar-linux/config,file=/etc/pve/local/ignition/990.ign
balloon: 0
bios: ovmf
boot: order=scsi0
cicustom:
cipassword: $5$HZnpXPaJ$9pQx4StDbUZQb1VHh1UBAARYSenktKfUxIVw77Y5yZ.
ciupgrade: 0
cores: 2
cpu: host
efidisk0: local:903/base-903-disk-0.raw/990/vm-990-disk-0.qcow2,efitype=4m,pre-enrolled-keys=1,size=128K
hookscript: local:snippets/multi-hookscript.pl
hotplug: network,disk,usb
kvm: 1
memory: 1024
meta: creation-qemu=8.0.2,ctime=1716094446
name: flatcar-terraform.example.com
net0: virtio=00:cd:83:00:7b:c0,bridge=vmbr0,tag=109
numa: 0
onboot: 1
ostype: l26
protection: 0
scsi0: local:990/vm-990-disk-2.raw,replicate=0,size=8694M
scsihw: virtio-scsi-single
serial0: socket
smbios1: uuid=768b2424-7d77-4c93-a722-a4e2e2bd675e
sockets: 1
sshkeys: %0A
startup: order=999
tablet: 1
tags: example;flatcar;terraform
vmgenid: e71bc271-bd7c-4c00-8909-e29c12a12f74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants