Closed 4r7if3x closed 1 month ago
Hey @4r7if3x 👋🏼
Please check the docs. You need to manually enable the Snippets content type on the datastore before uploading them.
Hey @4r7if3x 👋🏼
Please check the docs. You need to manually enable the Snippets content type on the datastore before uploading them.
oopsie, I missed that note... It would be great if it could be added to the guide too. Thanks for the quick response anyway.
@4r7if3x would you be up for opening an improvement PR? 🙂
The guide is located here. There are some conventions to be aware of, but it should be pretty straightforward.
@bpg Thanks. One more question, somewhat related... The user_account
object of initialization
adds the credentials to the Cloud-Init tab of the Proxmox VM, but the OS is installed with the default "ubuntu" user. In one of your examples, I can see you defined the user in the cloud-configs snippet instead, but I like the former method better. Shouldn't that work to my expectations?
@4r7if3x yes, the example from the guide works:
OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
OpenTofu will perform the following actions:
# proxmox_virtual_environment_download_file.ubuntu_cloud_image will be created
+ resource "proxmox_virtual_environment_download_file" "ubuntu_cloud_image" {
+ content_type = "iso"
+ datastore_id = "local"
+ file_name = (known after apply)
+ id = (known after apply)
+ node_name = "pve"
+ overwrite = true
+ overwrite_unmanaged = false
+ size = (known after apply)
+ upload_timeout = 600
+ url = "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
+ verify = true
}
# proxmox_virtual_environment_vm.ubuntu_vm will be created
+ resource "proxmox_virtual_environment_vm" "ubuntu_vm" {
+ acpi = true
+ bios = "seabios"
+ id = (known after apply)
+ ipv4_addresses = (known after apply)
+ ipv6_addresses = (known after apply)
+ keyboard_layout = "en-us"
+ mac_addresses = (known after apply)
+ migrate = false
+ name = "test-ubuntu"
+ network_interface_names = (known after apply)
+ node_name = "pve"
+ on_boot = true
+ protection = false
+ reboot = false
+ scsi_hardware = "virtio-scsi-pci"
+ started = true
+ stop_on_destroy = false
+ tablet_device = true
+ template = false
+ timeout_clone = 1800
+ timeout_create = 1800
+ timeout_migrate = 1800
+ timeout_move_disk = 1800
+ timeout_reboot = 1800
+ timeout_shutdown_vm = 1800
+ timeout_start_vm = 1800
+ timeout_stop_vm = 300
+ vm_id = (known after apply)
+ disk {
+ aio = "io_uring"
+ backup = true
+ cache = "none"
+ datastore_id = "local-lvm"
+ discard = "on"
+ file_format = (known after apply)
+ file_id = (known after apply)
+ interface = "virtio0"
+ iothread = true
+ path_in_datastore = (known after apply)
+ replicate = true
+ size = 20
+ ssd = false
}
+ initialization {
+ datastore_id = "local-lvm"
+ upgrade = (known after apply)
+ ip_config {
+ ipv4 {
+ address = "172.16.10.1/24"
+ gateway = "172.16.0.1"
}
}
+ user_account {
+ keys = [
+ "ssh-rsa REDACTED",
]
+ username = "notubuntu"
}
}
+ network_device {
+ bridge = "vmbr0"
+ enabled = true
+ firewall = false
+ mac_address = (known after apply)
+ model = "virtio"
+ mtu = 0
+ queues = 0
+ rate_limit = 0
+ vlan_id = 0
}
}
Plan: 2 to add, 0 to change, 0 to destroy.
proxmox_virtual_environment_download_file.ubuntu_cloud_image: Creating...
proxmox_virtual_environment_download_file.ubuntu_cloud_image: Still creating... [10s elapsed]
proxmox_virtual_environment_download_file.ubuntu_cloud_image: Still creating... [20s elapsed]
proxmox_virtual_environment_download_file.ubuntu_cloud_image: Still creating... [30s elapsed]
proxmox_virtual_environment_download_file.ubuntu_cloud_image: Still creating... [40s elapsed]
proxmox_virtual_environment_download_file.ubuntu_cloud_image: Creation complete after 46s [id=local:iso/jammy-server-cloudimg-amd64.img]
proxmox_virtual_environment_vm.ubuntu_vm: Creating...
proxmox_virtual_environment_vm.ubuntu_vm: Still creating... [10s elapsed]
proxmox_virtual_environment_vm.ubuntu_vm: Creation complete after 15s [id=100]
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
❯ ssh notubuntu@172.16.10.1
Warning: Permanently added '172.16.10.1' (ED25519) to the list of known hosts.
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.0-119-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Wed Sep 18 20:52:02 UTC 2024
System load: 0.97 Processes: 93
Usage of /: 7.4% of 19.20GB Users logged in: 0
Memory usage: 39% IPv4 address for eth0: 172.16.10.1
Swap usage: 0%
Expanded Security Maintenance for Applications is not enabled.
0 updates can be applied immediately.
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
notubuntu@test-ubuntu:~$
@bpg I realized that I cannot use user_account
and user_data_file_id
together. I used to do something like that in my shell script before switching to Terraform, so I thought I could do the same here.
Ah.. you used vendor data file in the script, but now user data file in the TF, which AFAIK overrides any other ciuser / cipassword settings.
Ah.. you used vendor data file in the script, but now user data file in the TF, which AFAIK overrides any other ciuser / cipassword settings.
Ah, right. I just found out there's a vendor_data_file_id
to use instead. All is good now, Thanks for your time!
I followed the Cloud-Init guide precisely, but I'm getting the following error:
What am I doing wrong?