Closed lolllpop closed 1 year ago
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the !component
bot command.
This is related to this part:
def __init__(self, module):
if not HAS_PROXMOXER:
module.fail_json(msg=missing_required_lib('proxmoxer'), exception=PROXMOXER_IMP_ERR)
self.module = module
self.proxmox_api = self._connect()
self.proxmoxer_version = proxmoxer_version
# Test token validity
try:
self.proxmox_api.version.get()
except Exception as e:
module.fail_json(msg='%s' % e, exception=traceback.format_exc())
def _connect(self):
api_host = self.module.params['api_host']
api_user = self.module.params['api_user']
api_password = self.module.params['api_password']
api_token_id = self.module.params['api_token_id']
api_token_secret = self.module.params['api_token_secret']
validate_certs = self.module.params['validate_certs']
auth_args = {'user': api_user}
if api_password:
auth_args['password'] = api_password
else:
if self.version() < LooseVersion('1.1.0'):
self.module.fail_json('Using "token_name" and "token_value" require proxmoxer>=1.1.0')
auth_args['token_name'] = api_token_id
auth_args['token_value'] = api_token_secret
try:
return ProxmoxAPI(api_host, verify_ssl=validate_certs, **auth_args)
except Exception as e:
self.module.fail_json(msg='%s' % e, exception=traceback.format_exc())
def version(self):
try:
apiversion = self.proxmox_api.version.get()
return LooseVersion(apiversion['version'])
except Exception as e:
self.module.fail_json(msg='Unable to retrieve Proxmox VE version: %s' % e)
self.init()
defines self.proxmox_api
by calling self._connect()
, which calls self.version()
, which finally looks at self.proxmox_api
object.
related to #6974
CC @russoz
Summary
Token authentication of proxmox modules is broken.
https://github.com/ansible-collections/community.general/commit/e5dc69788799168c0f53c1da636262c81d8fdc5b introduced a version check for proxmoxer, but actually makes an api call to PVE itself, and this before the api is readily connected.
Reverting this change fixes the token authentication.
Issue Type
Bug Report
Component Name
/plugins/module_utils/proxmox.py
Ansible Version
Community.general Version
Configuration
OS / Environment
Gentoo stable
Steps to Reproduce
Expected Results
Creation of a minimal VM on node1
Actual Results
Code of Conduct