-
Hello, Glad to find this awesome provider! 🚀 I created a Proxmox 8.1.3 environment. And then, I'm trying to create some virtual machine Terraform and the provider. I created an virtual machine template using ubuntu-22.04-server-cloudimg-amd64.img: wget https://cloud-images.ubuntu.com/releases/22.04/release-20240126/ubuntu-22.04-server-cloudimg-amd64.img
# Create an virtual machine with the cloudimg
qm create 9000 --name "ubuntu-2204-cloudinit-template" --memory 1024 --cores 1 --net0 virtio,bridge=vmbr0
qm importdisk 9000 ubuntu-22.04-server-cloudimg-amd64.img local-lvm
qm set 9000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9000-disk-0
qm set 9000 --boot c --bootdisk scsi0
qm set 9000 --ide2 local-lvm:cloudinit
qm set 9000 --serial0 socket --vga serial0
qm set 9000 --agent enabled=1
# Convert it to template
qm template 9000 And then, I created the role and user for terraform in the proxmox: pveum role add TerraformProv -privs "Datastore.AllocateSpace Datastore.Audit Pool.Allocate Sys.Audit Sys.Console Sys.Modify VM.Allocate VM.Audit VM.Clone VM.Config.CDROM VM.Config.Cloudinit VM.Config.CPU VM.Config.Disk VM.Config.HWType VM.Config.Memory VM.Config.Network VM.Config.Options VM.Migrate VM.Monitor VM.PowerMgmt SDN.Use"
pveum user add terraform-prov@pve --password Test123456
pveum aclmod / -user terraform-prov@pve -role TerraformProv At last, I created the terraform configuration file: provider "proxmox" {
pm_api_url = "https://192.168.2.150:8006/api2/json"
pm_user = "terraform-prov@pve"
pm_password = "Test123456"
pm_debug = true
pm_log_levels = {
_default = "debug"
_capturelog = ""
}
}
resource "proxmox_vm_qemu" "ubuntu-test" {
count = 1
vmid = 100
name = "ubuntu-test"
desc = "Ubuntu test vm"
# Valid nodes: proxmox-1, proxmox-2
target_node = "proxmox-1"
clone = "ubuntu-2204-cloudinit-template"
agent = 1
os_type = "ubuntu"
bios = "ovmf"
cores = 32
sockets = 1
cpu = "EPYC-v3"
memory = 8192
scsihw = "virtio-scsi-pci"
bootdisk = "scsi0"
# Disk settings
disks {
scsi {
scsi0 {
disk {
size = 500
storage = "local-lvm"
}
}
}
}
# Network settings
network {
model = "virtio"
bridge = "vmbr0"
}
ipconfig0 = "gw=192.168.2.1,ip=192.168.2.152/24"
nameserver = "192.168.2.240 223.5.5.5 223.6.6.6"
cloudinit_cdrom_storage = "local-lvm"
# User settings
ciuser = "test"
# cipassword = "test123456"
sshkeys = file("/root/.ssh/id_rsa.pub")
} But when I executed {"data":null}: timestamp="2024-01-31T18:19:47.996+0800"
2024-01-31T18:19:47.996+0800 [INFO] provider.terraform-provider-proxmox_v3.0.1-rc1: 2024/01/31 18:19:47 [DEBUG][initConnInfo] check ip result error 500 Configuration file 'nodes/proxmox-1/qemu-server/100.conf' does not exist: timestamp="2024-01-31T18:19:47.996+0800"
2024-01-31T18:19:53.000+0800 [INFO] provider.terraform-provider-proxmox_v3.0.1-rc1: 2024/01/31 18:19:53 >>>>>>>>>> REQUEST:
GET /api2/json/nodes/proxmox-1/qemu/100/agent/network-get-interfaces HTTP/1.1
Host: 192.168.2.150:8006
User-Agent: Go-http-client/1.1
Accept: application/json
Authorization: PVEAuthCookie=PVE:terraform-prov@pve:65BA19FC::kcqOj2Lj6ImvU3Ti/8CjktV8pArTHGio798MtHSDGWX0AB2BsJWSMdIJjbmY7BuBvGcfmBrXGe2OJWPr4rAbxU861xhgOGK0/4B8k++ga1qr+FDSf/tlVes4gvrirKJmQS1iVAdean3ZNoOwQezec3Zf48ndJOpR1+74DDl7+NXsN8Izj0M6a00OZyNtvFgyNoc1T/irvWC59YT+g7zsKqT32JKyUuY/xMocrWunLtTSXNKmpNu6dapKx3TmVJs6qdoFXfRwN0w6wQgxW+EmkrsnXhX3AsxT4oZS4BAkRneAZiRion2nUOPC3ISC69fiXcbYeTIbbjIr81S/IFQJkA==
CSRFPreventionToken: 65BA19FC:oOUf0AKZ3gHDTcu2kkyzal3Do5SqUHaMAqIDW7MGEe0
Accept-Encoding: gzip
: timestamp="2024-01-31T18:19:53.000+0800"
2024-01-31T18:19:53.013+0800 [INFO] provider.terraform-provider-proxmox_v3.0.1-rc1: 2024/01/31 18:19:53 <<<<<<<<<< RESULT:
HTTP/1.1 500 Configuration file 'nodes/proxmox-1/qemu-server/100.conf' does not exist
Connection: close
Content-Length: 13
Cache-Control: max-age=0
Content-Type: application/json;charset=UTF-8
Date: Wed, 31 Jan 2024 10:19:53 GMT
Expires: Wed, 31 Jan 2024 10:19:53 GMT
Pragma: no-cache
Server: pve-api-daemon/3.0
{"data":null}: timestamp="2024-01-31T18:19:53.013+0800"
2024-01-31T18:19:53.013+0800 [INFO] provider.terraform-provider-proxmox_v3.0.1-rc1: 2024/01/31 18:19:53 [DEBUG][initConnInfo] check ip result error 500 Configuration file 'nodes/proxmox-1/qemu-server/100.conf' does not exist: timestamp="2024-01-31T18:19:53.013+0800"
proxmox_vm_qemu.k8s-master[0]: Still creating... [20m30s elapsed] I tried to change the Since the ubuntu cloud image does not contain any default user and password, how can I enable the qemu-guest-agent service of the virtual machine? Any help? Really appreciate! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I tried to clone it with root@proxmox-1:~# qm create 100 --name "ubuntu-2204-cloudinit" --memory 2048 --net0 virtio,bridge=vmbr0 --cores 2 --sockets 1
root@proxmox-1:~# qm importdisk 100 ubuntu-22.04-server-cloudimg-amd64.img local-lvm
importing disk 'ubuntu-22.04-server-cloudimg-amd64.img' to VM 100 ...
Logical volume "vm-100-disk-0" created.
transferred 0.0 B of 2.2 GiB (0.00%)
transferred 22.5 MiB of 2.2 GiB (1.00%)
transferred 45.3 MiB of 2.2 GiB (2.01%)
transferred 67.8 MiB of 2.2 GiB (3.01%)
transferred 90.3 MiB of 2.2 GiB (4.01%)
transferred 113.5 MiB of 2.2 GiB (5.04%)
...
transferred 2.2 GiB of 2.2 GiB (100.00%)
transferred 2.2 GiB of 2.2 GiB (100.00%)
Successfully imported disk as 'unused0:local-lvm:vm-100-disk-0'
root@proxmox-1:~# qm set 100 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-100-disk-0
update VM 100: -scsi0 local-lvm:vm-100-disk-0 -scsihw virtio-scsi-pci
root@proxmox-1:~# qm set 100 --boot c --bootdisk scsi0 --agent 1
update VM 100: -agent 1 -boot c -bootdisk scsi0
root@proxmox-1:~# qm set 100 --ide2 local-lvm:cloudinit
update VM 100: -ide2 local-lvm:cloudinit
Logical volume "vm-100-cloudinit" created.
ide2: successfully created disk 'local-lvm:vm-100-cloudinit,media=cdrom'
generating cloud-init ISO
root@proxmox-1:~# qm template 100
Renamed "vm-100-disk-0" to "base-100-disk-0" in volume group "pve"
Logical volume pve/base-100-disk-0 changed.
WARNING: Combining activation change with other commands is not advised.
root@proxmox-1:~# qm clone 100 101 --name ubuntu-2204-instance-01
create full clone of drive ide2 (local-lvm:vm-100-cloudinit)
Logical volume "vm-101-cloudinit" created.
create linked clone of drive scsi0 (local-lvm:base-100-disk-0)
Logical volume "vm-101-disk-0" created.
root@proxmox-1:~# qm set 101 --memory 4096
update VM 101: -memory 4096
root@proxmox-1:~# qm set 101 --ciuser testuser --cipassword 123456 --sshkey /root/.ssh/id_rsa.pub
update VM 101: -cipassword <hidden> -ciuser testuser -sshkeys ssh-rsa%20AAA...xmox-1%0A
root@proxmox-1:~# qm set 101 --ipconfig0 ip=192.168.2.152/24,gw=192.168.2.1
update VM 101: -ipconfig0 ip=192.168.2.152/24,gw=192.168.2.1
root@proxmox-1:~# qm start 101
generating cloud-init ISO
root@proxmox-1:~# ssh [email protected]
The authenticity of host '192.168.2.152 (192.168.2.152)' can't be established.
ED25519 key fingerprint is SHA256:O6GlJqR5aLOn/BX2Bi+b+QHV3Zxmzy5AlHT9vopRPks.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.2.152' (ED25519) to the list of known hosts.
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.0-92-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Thu Feb 1 02:34:13 UTC 2024
System load: 0.591796875 Processes: 112
Usage of /: 84.8% of 1.96GB Users logged in: 0
Memory usage: 14% IPv4 address for eth0: 192.168.2.152
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
Last login: Thu Feb 1 02:34:14 2024
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
testuser@ubuntu-2204-instance-01:~$ exit |
Beta Was this translation helpful? Give feedback.
#922