mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add profile parameter for scaleway inventory (#4049)
* add profile parameter for scaleway inventory * Update doc from review and add changelog * Update changelogs from review Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
6a7811f696
commit
5710faab64
2 changed files with 15 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- scaleway inventory plugin - add profile parameter ``scw_profile`` (https://github.com/ansible-collections/community.general/pull/4049).
|
|
@ -31,6 +31,12 @@ DOCUMENTATION = r'''
|
||||||
tags:
|
tags:
|
||||||
description: Filter results on a specific tag.
|
description: Filter results on a specific tag.
|
||||||
type: list
|
type: list
|
||||||
|
scw_profile:
|
||||||
|
description:
|
||||||
|
- The config profile to use in config file.
|
||||||
|
- By default uses the one specified as C(active_profile) in the config file, or falls back to C(default) if that is not defined.
|
||||||
|
type: string
|
||||||
|
version_added: 4.4.0
|
||||||
oauth_token:
|
oauth_token:
|
||||||
description:
|
description:
|
||||||
- Scaleway OAuth token.
|
- Scaleway OAuth token.
|
||||||
|
@ -303,7 +309,13 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
||||||
if not oauth_token and os.path.exists(scw_config_path):
|
if not oauth_token and os.path.exists(scw_config_path):
|
||||||
with open(scw_config_path) as fh:
|
with open(scw_config_path) as fh:
|
||||||
scw_config = yaml.safe_load(fh)
|
scw_config = yaml.safe_load(fh)
|
||||||
|
ansible_profile = self.get_option('scw_profile')
|
||||||
|
|
||||||
|
if ansible_profile:
|
||||||
|
active_profile = ansible_profile
|
||||||
|
else:
|
||||||
active_profile = scw_config.get('active_profile', 'default')
|
active_profile = scw_config.get('active_profile', 'default')
|
||||||
|
|
||||||
if active_profile == 'default':
|
if active_profile == 'default':
|
||||||
oauth_token = scw_config.get('secret_key')
|
oauth_token = scw_config.get('secret_key')
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue