Skip to content

Commit 8ce177a

Browse files
feature: Set api_token and validate_certs module parameters via environment variable (#136)
* Added missing env-fallback parameters to argument-spec * add PR# to Changelog fragement * Update changelogs/fragments/136-api-token-env-var-support.yml Co-authored-by: Felix Fontein <[email protected]> * Update plugins/doc_fragments/proxmox.py with new env-vars --------- Co-authored-by: Felix Fontein <[email protected]>
1 parent 5299416 commit 8ce177a

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- proxmox* modules - added fallback environment variables for ``api_token``, ``api_secret``, and ``validate_certs`` (https://github.com/ansible-collections/community.proxmox/issues/63, https://github.com/ansible-collections/community.proxmox/pull/136).

plugins/doc_fragments/proxmox.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class ModuleDocFragment(object):
1414
api_host:
1515
description:
1616
- Specify the target host of the Proxmox VE cluster.
17+
- Uses the E(PROXMOX_HOST) environment variable if not specified.
1718
type: str
1819
required: true
1920
api_port:
@@ -25,25 +26,29 @@ class ModuleDocFragment(object):
2526
api_user:
2627
description:
2728
- Specify the user to authenticate with.
29+
- Uses the E(PROXMOX_USER) environment variable if not specified.
2830
type: str
2931
required: true
3032
api_password:
3133
description:
3234
- Specify the password to authenticate with.
33-
- You can use E(PROXMOX_PASSWORD) environment variable.
35+
- Uses the E(PROXMOX_PASSWORD) environment variable if not specified.
3436
type: str
3537
api_token_id:
3638
description:
3739
- Specify the token ID.
40+
- Uses the E(PROXMOX_TOKEN_ID) environment variable if not specified.
3841
type: str
3942
api_token_secret:
4043
description:
4144
- Specify the token secret.
45+
- Uses the E(PROXMOX_TOKEN_SECRET) environment variable if not specified.
4246
type: str
4347
validate_certs:
4448
description:
4549
- If V(false), SSL certificates will not be validated.
4650
- This should only be used on personally controlled sites using self-signed certificates.
51+
- Uses the E(PROXMOX_VALIDATE_CERTS) environment variable if not specified.
4752
type: bool
4853
default: false
4954
requirements: ["proxmoxer >= 2.0", "requests"]

plugins/module_utils/proxmox.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ def proxmox_auth_argument_spec():
4343
fallback=(env_fallback, ['PROXMOX_PASSWORD'])
4444
),
4545
api_token_id=dict(type='str',
46-
no_log=False
46+
no_log=False,
47+
fallback=(env_fallback, ['PROXMOX_TOKEN_ID'])
4748
),
4849
api_token_secret=dict(type='str',
49-
no_log=True
50+
no_log=True,
51+
fallback=(env_fallback, ['PROXMOX_TOKEN_SECRET'])
5052
),
5153
validate_certs=dict(type='bool',
52-
default=False
54+
default=False,
55+
fallback=(env_fallback, ['PROXMOX_VALIDATE_CERTS'])
5356
),
5457
)
5558

0 commit comments

Comments
 (0)