Hi , i am pretty noob with ansible, i am struggling interacting with proxmox api using the module uri. I know that exist a proxmox module in ansible , but i need to send keys right after the vm boots , and that is not covered with the proxmox module . The proxmox api has a node to send keys (yes one by one).Here is the api node doc. https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/sendkey I am not used to interact with api's so my code could be "mounstruosily wrong". But i will use any hint/tip.
--- - name: configura hosts: localhost connection: local gather_facts: no vars: proxmox_vmid: "501" proxmox_node : "gallifrey" proxmox_auth_user: "someuser@pve" proxmox_auth_password: "somepassword" proxmox_rest_api_url: "https://10.0.0.225:8006/api2/json/nodes" tasks: - name: generaticket uri: url: "https://10.0.0.225:8006/api2/json/access/ticket" method: Post validate_certs: no body_format: json body: { "username": "{{ proxmox_auth_user}}", "password": "{{ proxmox_auth_password }}" } return_content: yes headers: Content-Type: "application/json" register: ticket - name: debug ticket debug: var: ticket - name: set fact jsondata set_fact: jsondata = "{{ ticket.json.data.ticket }}" - name: set fact jsondata2 set_fact: jsondata2 = "{{ ticket.json.data.CSRFPreventionToken }}" - name: debug ticket debug: msg: "{{ ticket.json.data.ticket }}" - name: debug CSRFPreventionToken debug: msg: "{{ ticket.json.data.CSRFPreventionToken }}" - name: envia_caracteres uri: url: "{{ proxmox_rest_api_url }}/{{ proxmox_node }}/qemu/{{proxmox_vmid}}/sendkey" validate_certs: no use_proxy: no method: PUT return_content: no url_username: "{{ proxmox_auth_user}}" url_password: "{{ ticket.json.data.ticket }}" body_format: json body: ' { "key":"kp_enter", "node":"gallifrey","vmid":"501", "CSRFPreventionToken":"{{ ticket.json.data.CSRFPreventionToken }}", "PVEAuthCookie":"{{ ticket.json.data.ticket }}", "username":"{{ proxmox_auth_user}}", "PVEAuthCookie": "{{ ticket.json.data.ticket }}" }' headers: Content-Type: "application/json" As you can see in the body , i am trying anything that pases on my mind ..... And i still receiving a "Status code was 401 and not [200]: HTTP Error 401: No ticket" I understand that i am doing the request in bad way , but i don't figure out. Anyone has interacted with proxmox api using uri module? Thanks in advance! Martin -- ::: (\(\ *: (=' :') :* ... (,('')('').... [email protected] -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAK5Zirz28_x_ez6%3Ds4cU28aUgiD%2BwJzCnXH11gt3V29nCh8nhQ%40mail.gmail.com.
