Unable to use api_user and api_password from Ansible's Proxmox module

Conacious

New Member
Sep 17, 2019
24
0
1
29
Hi,
I have installed on a debian 10 buster server Proxmox 6.1-8.

I'm trying to run an Ansible script that adds a public key to the proxmox server.

The code, using the Ansible docs:

Code:
- proxmox:
    api_user: " {{ proxmox.api_user }}"
    api_password: "{{ proxmox.api_password }}"
    api_host: tfg
    password: "{{ proxmox.api_password }}"
    pubkey: "{{ public_keys.victor_home }}"

I'm using the root@pam user and password for api_user and api_password.

Also tryied to create a new user for the api with:

Code:
pvesh create /access/users -userid testuser2@pve

But always got the same error.

"msg": "authorization on proxmox cluster failed with exception: Couldn't authenticate user:

My question is how can I create a proper api_user and api_password to use on my Ansible playbook?

Thank you very much.
 

Conacious

New Member
Sep 17, 2019
24
0
1
29
I have to add that when I run

Code:
 curl -k -d "username=root@pam&password=xxxxxx"  https://xxxxxxxx:8006/api2/json/access/ticket

I got the ticket correctly as a JSON response using the same user and password than before
 

fabian

Proxmox Staff Member
Staff member
Jan 7, 2016
6,710
1,171
164
then likely your ansible playbook does something else. you probably need to turn up debugging/logging on the ansible side (to hopefully see the full request and/or error), and check pveproxy logs for incoming requests while running your playbook.
 

Conacious

New Member
Sep 17, 2019
24
0
1
29
Thank you for asnwer.

I forgot to add the @pam to the api_user var :rolleyes:.


Anyways i'm getting an other error. The proxmox module for Ansible doesn't have debugger mode so I don't have many info.

The access.log of pvproxy shows 2 requests that seem okey:


Code:
2a01:4f8:173:159c::2 - - [17/03/2020:12:06:42 +0100] "POST /api2/json/access/ticket HTTP/1.1" 200 677
2a01:4f8:173:159c::2 - root@pam [17/03/2020:12:06:42 +0100] "GET /api2/json/version HTTP/1.1" 200 64


But i'm still getting this error on Ansible:

Code:
fatal: [tfg.intelligenia.com]: FAILED! => {"changed": false, "msg": "authorization on proxmox cluster failed with exception: invalid literal for float(): 6.1-8"}

I'm guessing that it may be a bug on the Ansible's proxmox module.
 

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 your own in 60 seconds.

Buy now!