1
0
Fork 0
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:
LucasBoisserie 2022-01-31 19:33:35 +01:00 committed by GitHub
parent 6a7811f696
commit 5710faab64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- scaleway inventory plugin - add profile parameter ``scw_profile`` (https://github.com/ansible-collections/community.general/pull/4049).

View file

@ -31,6 +31,12 @@ DOCUMENTATION = r'''
tags:
description: Filter results on a specific tag.
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:
description:
- Scaleway OAuth token.
@ -303,7 +309,13 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
if not oauth_token and os.path.exists(scw_config_path):
with open(scw_config_path) as fh:
scw_config = yaml.safe_load(fh)
active_profile = scw_config.get('active_profile', 'default')
ansible_profile = self.get_option('scw_profile')
if ansible_profile:
active_profile = ansible_profile
else:
active_profile = scw_config.get('active_profile', 'default')
if active_profile == 'default':
oauth_token = scw_config.get('secret_key')
else: