mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-30 04:49:09 -07:00
* Improved parameter handling on proxmox modules
* removed unused imports
* rollback change in plugins/modules/cloud/misc/proxmox_user_info.py
* added changelog fragment
* Update changelogs/fragments/1765-proxmox-params.yml
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 0a5f79724c
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
44ce63ed85
commit
81e71b5034
5 changed files with 28 additions and 50 deletions
|
@ -31,6 +31,7 @@ options:
|
|||
- The password to authenticate with.
|
||||
- You can use PROXMOX_PASSWORD environment variable.
|
||||
type: str
|
||||
required: yes
|
||||
hostname:
|
||||
description:
|
||||
- The instance name.
|
||||
|
@ -106,7 +107,6 @@ EXAMPLES = r'''
|
|||
|
||||
RETURN = r'''#'''
|
||||
|
||||
import os
|
||||
import time
|
||||
import traceback
|
||||
|
||||
|
@ -118,7 +118,7 @@ except ImportError:
|
|||
PROXMOXER_IMP_ERR = traceback.format_exc()
|
||||
HAS_PROXMOXER = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib, env_fallback
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
||||
|
@ -182,7 +182,7 @@ def main():
|
|||
argument_spec=dict(
|
||||
api_host=dict(required=True),
|
||||
api_user=dict(required=True),
|
||||
api_password=dict(no_log=True),
|
||||
api_password=dict(no_log=True, required=True, fallback=(env_fallback, ['PROXMOX_PASSWORD'])),
|
||||
vmid=dict(required=False),
|
||||
validate_certs=dict(type='bool', default='no'),
|
||||
hostname=dict(),
|
||||
|
@ -213,13 +213,6 @@ def main():
|
|||
force = module.params['force']
|
||||
vmstate = module.params['vmstate']
|
||||
|
||||
# If password not set get it from PROXMOX_PASSWORD env
|
||||
if not api_password:
|
||||
try:
|
||||
api_password = os.environ['PROXMOX_PASSWORD']
|
||||
except KeyError as e:
|
||||
module.fail_json(msg='You should set api_password param or use PROXMOX_PASSWORD environment variable' % to_native(e))
|
||||
|
||||
try:
|
||||
proxmox = setup_api(api_host, api_user, api_password, validate_certs)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue