-
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
Add grants to influxdb_user #46216
Add grants to influxdb_user #46216
Conversation
The test
The test
|
The test
The test
|
481f62d
to
2815570
Compare
2815570
to
171880b
Compare
ea20f0b
to
728f492
Compare
728f492
to
9534fde
Compare
8d06cf0
to
58ed8dc
Compare
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.
needs_revision
def main(): | ||
argument_spec = influx.InfluxDb.influxdb_argument_spec() | ||
argument_spec.update( | ||
state=dict(default='present', type='str', choices=['present', 'absent']), | ||
user_name=dict(required=True, type='str'), | ||
user_password=dict(required=False, type='str', no_log=True), | ||
admin=dict(default='False', type='bool') | ||
admin=dict(default='False', type='bool'), | ||
grants=dict(default=[], type='list') |
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.
Default to None
:
grants=dict(type='list')
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.
It's done, thanks
else: | ||
user_password = user_password or '' | ||
create_user(module, client, user_name, user_password, admin) | ||
changed = True | ||
|
||
if grants: |
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.
The default to an empty list may result in a unexpected behaviour, if users don't use this param (default empty list) and have set grants manually, the grants would get deleted with this implementation.
I would change it in a way to only handle it if a list (be it empty) is set and ignore it if None (param unset):
if grants is not None:
if set_user_grants(module, client, user_name, grants):
changed = True
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.
It's done, thanks
58ed8dc
to
4d5cf32
Compare
4d5cf32
to
ad15106
Compare
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.
shipit
SUMMARY
I needed to be able to set influxdb user privileges, so I added a function to the module.
Fixes influxdb_user does not support setting privileges #35771
I also caught the exception you get when you try creating an admin user for the first time with authentication enabled.
ISSUE TYPE
COMPONENT NAME
influxdb_user
ANSIBLE VERSION
ADDITIONAL INFORMATION