API issue w/ 'proxmox' ansible module.

locusofself

Member
Mar 29, 2016
39
3
8
40
Hello, big proxmox fan and ansible user here. I am trying to create new LXC containers in proxmox using ansible. I believe this is same issue as: https://github.com/ansible/ansible/issues/25113

I'd like to help fix it and maybe do a pull request for the ansible module.

I can't say with 100% certainty, but I think its perhaps calling the API wrong. Here is what I get in my pve-proxy/access.log (note 500 error in last line)


10.128.30.241 - - [29/Aug/2017:20:47:13 -0700] "POST /api2/json/access/ticket HTTP/1.1" 200 643
10.128.30.241 - root@pam [29/Aug/2017:20:47:14 -0700] "GET /api2/json/version HTTP/1.1" 200 80
10.128.30.241 - root@pam [29/Aug/2017:20:47:14 -0700] "GET /api2/json/cluster/nextid HTTP/1.1" 200 14
10.128.30.241 - root@pam [29/Aug/2017:20:47:14 -0700] "GET /api2/json/cluster/resources?type=vm HTTP/1.1" 200 347
10.128.30.241 - root@pam [29/Aug/2017:20:47:14 -0700] "GET /api2/json/cluster/resources?type=vm HTTP/1.1" 200 334
10.128.30.241 - root@pam [29/Aug/2017:20:47:14 -0700] "GET /api2/json/nodes HTTP/1.1" 200 193
10.128.30.241 - root@pam [29/Aug/2017:20:47:14 -0700] "GET /api2/json/nodes/z3/storage/debian-8.0-standard_8.7-1_amd64.tar.gz/content HTTP/1.1" 500 13



This debian tarball LXC template is located on my /var/lib/vz/template/cache/ directory, /var/lib/vz is mounted as 'local' in proxmox. At first I thought maybe the API is not finding it in that path, so I tried moving other places but then I got another error indicating the template doesnt exist, so I don't think that is the problem.



Any help appreciated thanks!
 
I found the issue or a workaround. I was trying to have the LXC target storgage be 'local' (default) but I did not have Container type allowed. So I just changed it to my other storage local-lvm.

Ansible, and the pveproxy/access.log only showed 500 error, but querying the API with curl gave me the actual error message.

{"errors":{"storage":"storage 'local' does not support container directories"},"data":null}


So I have a playbook which works now, still need to add more stuff like for networking etc..

---
- hosts: lxctest
gather_facts: no
become: no
tasks:
- name: create container
proxmox:
node: z3
api_user: root@pam
api_password: '******!'
api_host: proxmox.*****.com
password: 123456
hostname: lxc.****.com
ostemplate: 'local:vztmpl/debian-8.0-standard_8.7-1_amd64.tar.gz'
pubkey: '****'
onboot: yes
storage: local-lvm
delegate_to: localhost
 
  • Like
Reactions: fleischkarussel
we are not involved in the development of the ansible proxmox module, did you report the issue in their bug tracker ?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!