-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vultr.py: Do not try to parse ini if $VULTR_API_KEY #42659
Conversation
lib/ansible/module_utils/vultr.py
Outdated
continue | ||
env_conf[key] = os.environ['VULTR_API_%s' % key.upper()] | ||
|
||
if env_conf.get('key'): | ||
return env_conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not return here anymore
ecc95fb
to
bbee7a7
Compare
@resmo does the last approach looks better? |
lib/ansible/module_utils/vultr.py
Outdated
except KeyError: | ||
config = {} | ||
|
||
if not config.get('key'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is too early, it should be after the self.api_config setting and therefore check should be updated to
if not self.api_config.get('api_key'):
self.module.fail_json(msg="The API key is not specified. Please refer to the documentation.")
In its current behavior, `read_ini_config()` tries to read ini file, even thought $VULTR_API_KEY environment file has been specified. This is due to the fact that if not *all* the keys (key, timeout, retries and endpoint) are specified in the environment, then the method goes and look for the vultr.ini file. Since timeout, retries and endpoint have default value, it is a perfectly valid use case to only specify key. Before patch: VULTR_API_KEY=XXXX ansible -m vr_ssh_key .... fails with Config file is missing After patch: VULTR_API_KEY=XXXX ansible -m vr_ssh_key goes all the way
bbee7a7
to
4fc7c86
Compare
shipit |
SUMMARY
In its current behavior,
read_ini_config()
tries to read ini file,even thought
$VULTR_API_KEY
environment file has been specified.This is due to the fact that if not all the keys (key, timeout,
retries and endpoint) are specified in the environment, then the method
goes and look for the vultr.ini file.
Since timeout, retries and endpoint have default value, it is a
perfectly valid use case to only specify key.
Before patch:
VULTR_API_KEY=XXXX ansible -m vr_ssh_key ...
fails with Config file ismissing
After patch:
VULTR_API_KEY=XXXX ansible -m vr_ssh_key ...
goes all the wayISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
ADDITIONAL INFORMATION