I have a large Ansible script that I won't post in full here because its nested, and just too much extra stuff to read across multiple files for most users to care. In short, it should create a new VM based off a small configuration file that contains basic info like VMid, and which qcow2 image to use to build, and then the major lifting is covered in DRY Ansible code.
Some things you may need to know. `optimus` is a large local ssd zfs store on the server called proxmox01. The Ansible script downloads new cloudinit-images, converts them to qcow2, and stores them there. I can use this storage to create images from the GUI. I use `optimus` as it is the largest drive on proxmox01. If I put the images on root, I become dangerously low on space.
The issue I am having, is buiding the VMs because every time I try to execute the script, it fails at the build with one of two errors (see below) reading the qcow2 images off of the local disk.
In case you are wondering, it is based off of this blog post and youtube video:
https://www.techtutorials.tv/sections/promox/automate-vm-creation-on-proxmox-with-ansible/
The particular part of the code I am having issues with is in two parts below, You can see a number of comments as I have been trying to work through this issue:
The variables file I have been modifying contains the following:
The problem with the main script is that when the script tries to use the `image_true_path` if it resolves to `local:/optimus/lib/vz/images/0/` Then I get the following error - and I have 4 different qcow2 images in the directory, but they all fail in this same way:
When on the server itself if I do an ls:
Whereas, if I change the `image_true_path` to resolve to `/optimus/lib/vz/images/0/` I instead get the following error:
I have googled this extensively, and come up with some posts on this very forum, but none seem to really explain why this is failing. I checked the API key, and I should have full permissions to this with the API key, and yet it still fails.
Relevant threads:
Some things you may need to know. `optimus` is a large local ssd zfs store on the server called proxmox01. The Ansible script downloads new cloudinit-images, converts them to qcow2, and stores them there. I can use this storage to create images from the GUI. I use `optimus` as it is the largest drive on proxmox01. If I put the images on root, I become dangerously low on space.
The issue I am having, is buiding the VMs because every time I try to execute the script, it fails at the build with one of two errors (see below) reading the qcow2 images off of the local disk.
In case you are wondering, it is based off of this blog post and youtube video:
https://www.techtutorials.tv/sections/promox/automate-vm-creation-on-proxmox-with-ansible/
The particular part of the code I am having issues with is in two parts below, You can see a number of comments as I have been trying to work through this issue:
YAML:
# Create VMs
- name: Create VMs
proxmox_kvm:
api_user: '{{api_user}}'
api_token_id: '{{api_token_id}}'
api_token_secret: '{{api_token_secret}}'
api_host: '{{api_host}}'
node: '{{item.node}}'
name: '{{item.name}}'
vmid: '{{item.vmid}}'
vga: serial0
tags: '{{item.tags}}'
net: '{"net0":"virtio,bridge={{linux_bridge}},tag={{item.vlan}},firewall=1"}'
serial: '{"serial0":"socket"}'
scsihw: virtio-scsi-single
# This is probably where the drive is breaking on creation drive_storage should be replaced with a variable
# that references optimus for node 1 so change drive_storage to a var like optimus_storage
# from vars:
# image_storage: local
# image_true_path: '/var/lib/vz/images/0/'
scsi:
scsi0: '{{drive_storage}}:0,import-from={{image_true_path}}{{item.image_file}},format={{drive_format}},iothread=1'
# scsi0: '{{drive_storage}}:0,import-from={{image_true_path}}{{item.image_file}},format={{drive_format}},iothread=1'
ide:
ide2: '{{drive_storage}}:cloudinit'
ostype: 'l26'
# Remaining Redacted for readability
The variables file I have been modifying contains the following:
YAML:
api_host: '{{inventory_hostname}}'
drive_storage: freenas
#drive_storage: optimus
drive_format: qcow2
snippets_storage: local
snippets_path: '/var/lib/vz/snippets/'
image_storage: local
#image_true_path: '/var/lib/vz/images/0/'
#image_true_path: 'local:/var/lib/vz/images/0/'
# below probably optimus, not local?
#image_true_path: '/optimus/lib/vz/images/0/'
image_true_path: 'local:/optimus/lib/vz/images/0/'
linux_bridge: vmbr20
The problem with the main script is that when the script tries to use the `image_true_path` if it resolves to `local:/optimus/lib/vz/images/0/` Then I get the following error - and I have 4 different qcow2 images in the directory, but they all fail in this same way:
failed: [proxmox01] (item={'name': 'Rockman', 'vmid': 112, 'node': 'proxmox01', 'image_file': 'Rocky-8-GenericCloud-Base.latest.x86_64.qcow2', 'cores': 2, 'memory': 1024, 'vlan': 20, 'ipv4mode': 'static', 'ipv4_address': '10.20.0.112/23', 'ipv4_gateway': '192.168.1.1', 'state': 'new', 'tags': ['rocky_linux', 'ansible_generated', 'vlan20']}) => {"ansible_loop_var": "item", "changed": false, "item": {"cores": 2, "image_file": "Rocky-8-GenericCloud-Base.latest.x86_64.qcow2", "ipv4_address": "10.20.0.112/23", "ipv4_gateway": "192.168.1.1", "ipv4mode": "static", "memory": 1024, "name": "Rockman", "node": "proxmox01", "state": "new", "tags": ["rocky_linux", "ansible_generated", "vlan20"], "vlan": 20, "vmid": 112}, "msg": "creation of qemu VM Rockman with vmid 112 failed with exception=500 Internal Server Error: unable to parse directory volume name '/optimus/lib/vz/images/0/Rocky-8-GenericCloud-Base.latest.x86_64.qcow2'", "vmid": 112}When on the server itself if I do an ls:
root@proxmox01:~# ls -alh /optimus/lib/vz/images/0/Rocky-8-GenericCloud-Base.latest.x86_64.qcow2 -rw-r--r-- 1 root root 2.0G Nov 12 08:55 /optimus/lib/vz/images/0/Rocky-8-GenericCloud-Base.latest.x86_64.qcow2Whereas, if I change the `image_true_path` to resolve to `/optimus/lib/vz/images/0/` I instead get the following error:
failed: [proxmox01] (item={'name': 'Rockman', 'vmid': 112, 'node': 'proxmox01', 'image_file': 'Rocky-8-GenericCloud-Base.latest.x86_64.qcow2', 'cores': 2, 'memory': 1024, 'vlan': 20, 'ipv4mode': 'static', 'ipv4_address': '10.20.0.112/23', 'ipv4_gateway': '192.168.1.1', 'state': 'new', 'tags': ['rocky_linux', 'ansible_generated', 'vlan20']}) => {"ansible_loop_var": "item", "changed": false, "item": {"cores": 2, "image_file": "Rocky-8-GenericCloud-Base.latest.x86_64.qcow2", "ipv4_address": "10.20.0.112/23", "ipv4_gateway": "192.168.1.1", "ipv4mode": "static", "memory": 1024, "name": "Rockman", "node": "proxmox01", "state": "new", "tags": ["rocky_linux", "ansible_generated", "vlan20"], "vlan": 20, "vmid": 112}, "msg": "creation of qemu VM Rockman with vmid 112 failed with exception=500 Internal Server Error: Only root can pass arbitrary filesystem paths. at /usr/share/perl5/PVE/Storage.pm line 651.", "vmid": 112}I have googled this extensively, and come up with some posts on this very forum, but none seem to really explain why this is failing. I checked the API key, and I should have full permissions to this with the API key, and yet it still fails.
Relevant threads:
Hello.
I get this error after terraform apply:
Error: error creating VM: 500 unable to parse directory volume name 'ubuntu-20.04.5-live-server-amd64.iso', error status: {"data":null} (params: map[agent:0 args: bios:seabios boot:c bootdisk:scsi0 cores:2 cpu:host description: hotplug:network,disk,usb ide2:local:ubuntu-20.04.5-live-server-amd64.iso,media=cdrom kvm:true machine: memory:2048 name:test-vm-1 net0:virtio=E6
2:4B:72:97:CA,bridge=vmbr0 numa:false onboot:false ostype:l26 scsi0:local-lvm:10,iothread=1 scsihw:virtio-scsi-pci sockets:1 startup: tablet:true tags: vmid:102])
main.tf...
I get this error after terraform apply:
Error: error creating VM: 500 unable to parse directory volume name 'ubuntu-20.04.5-live-server-amd64.iso', error status: {"data":null} (params: map[agent:0 args: bios:seabios boot:c bootdisk:scsi0 cores:2 cpu:host description: hotplug:network,disk,usb ide2:local:ubuntu-20.04.5-live-server-amd64.iso,media=cdrom kvm:true machine: memory:2048 name:test-vm-1 net0:virtio=E6
main.tf...
- susumanin
- terraform
- Replies: 2
- Forum: Proxmox VE: Installation and configuration
Hello
I'm trying to get my code that sends api requests to work.
But I have this error:
I think it's a problem when I define rootfs in the request body but I'm not sure.
My body:
I'm trying to get my code that sends api requests to work.
But I have this error:
Code:
Only root can pass arbitrary filesystem paths. at /usr/share/perl5/PVE/Storage.pm line 538.
I think it's a problem when I define rootfs in the request body but I'm not sure.
My body:
Code:
var body = {
"ostemplate": os,
"password": password,
"memory": ram_in_mb,
"rootfs": stockage_name + ":" + stockage_in_mb,
"cores": number_processor_cores,
"swap": "0",
"vmid": nextid.data.data,
"net0": "name=" +...
- Cubix Gamer
- api code 500 lxc post proxmox
- Replies: 6
- Forum: Proxmox VE: Installation and configuration