trying to use api sendkey via ansible uri, anyone has used before?

Martin_Etcheverri

New Member
Jul 10, 2020
1
0
1
48
i need to send keys to the vm when it boots .
looking to the api , i found
HTTP: PUT /api2/json/nodes/{node}/qemu/{vmid}/sendkey

i am trying to do something like that:
- name: send keys
uri:
url: "{{ proxmox_rest_api_url }}/{{ proxmox_node }}/qemu/{{proxmox_vmid}}/sendkey"
validate_certs: no
use_proxy: no
method: PUT
body_format: json
body:
{
"key": "{{ item }}",
"node": "{{ proxmox_node }}",
"vmid": "{{ proxmox_vmid }}",
}
headers:
Content-Type: "application/json"
Cookie: "{{ ticket }}"
CSRFPreventionToken: "{{ ticket }}"
loop:
- kp_enter
- kp_enter
- spc
- spc

And i get this response:
"Status code was -1 and not [200]: An unknown error occurred: expected string or bytes-like object",
 
this sounds like an error from the Ansible module.. maybe there's some way to get more detailed output from it?

anyhow, ticket and CSRF token are two different things, setting the same value for both of them is incorrect for sure ;)
 

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!