influxdb: add login aliases (#34599)
influxdb_user module has user_name, user_password which may confuse with existing login arg username and password. Added aliases prefixed ith login_ to help distinguish.
This commit is contained in:
parent
719feef2e0
commit
386c6b4051
3 changed files with 53 additions and 68 deletions
lib/ansible
module_utils
modules/database/influxdb
utils/module_docs_fragments
|
@ -42,8 +42,8 @@ class InfluxDb():
|
||||||
return dict(
|
return dict(
|
||||||
hostname=dict(default='localhost', type='str'),
|
hostname=dict(default='localhost', type='str'),
|
||||||
port=dict(default=8086, type='int'),
|
port=dict(default=8086, type='int'),
|
||||||
username=dict(default='root', type='str'),
|
username=dict(default='root', type='str', aliases=['login_username']),
|
||||||
password=dict(default='root', type='str', no_log=True),
|
password=dict(default='root', type='str', no_log=True, aliases=['login_password']),
|
||||||
ssl=dict(default=False, type='bool'),
|
ssl=dict(default=False, type='bool'),
|
||||||
validate_certs=dict(default=True, type='bool'),
|
validate_certs=dict(default=True, type='bool'),
|
||||||
timeout=dict(type='int'),
|
timeout=dict(type='int'),
|
||||||
|
|
|
@ -17,81 +17,62 @@ DOCUMENTATION = '''
|
||||||
module: influxdb_user
|
module: influxdb_user
|
||||||
short_description: Manage InfluxDB users
|
short_description: Manage InfluxDB users
|
||||||
description:
|
description:
|
||||||
- Manage InfluxDB users
|
- Manage InfluxDB users
|
||||||
version_added: 2.5
|
version_added: 2.5
|
||||||
author: "Vitaliy Zhhuta (@zhhuta)"
|
author: "Vitaliy Zhhuta (@zhhuta)"
|
||||||
requirements:
|
requirements:
|
||||||
- "python >= 2.6"
|
- "python >= 2.6"
|
||||||
- "influxdb >= 0.9"
|
- "influxdb >= 0.9"
|
||||||
options:
|
options:
|
||||||
hostname:
|
user_name:
|
||||||
description:
|
description:
|
||||||
- The hostname or IP address on which InfluxDB server is listening
|
- Name of the user.
|
||||||
default: localhost
|
required: True
|
||||||
required: false
|
user_password:
|
||||||
user_name:
|
description:
|
||||||
description:
|
- Password to be set for the user.
|
||||||
- User that we want to create
|
required: false
|
||||||
default: None
|
admin:
|
||||||
required: True
|
description:
|
||||||
user_password:
|
- Whether the user should be in the admin role or not.
|
||||||
description:
|
default: no
|
||||||
- Password that we want to set for user
|
choices: [ yes, no]
|
||||||
default: None
|
state:
|
||||||
required: false
|
description:
|
||||||
admin:
|
- State of the user.
|
||||||
description:
|
choices: [ present, absent ]
|
||||||
- specify if user should be admin
|
default: present
|
||||||
default: False
|
extends_documentation_fragment: influxdb
|
||||||
required: false
|
|
||||||
|
|
||||||
port:
|
|
||||||
description:
|
|
||||||
- The port on which InfluxDB server is listening
|
|
||||||
default: 8086
|
|
||||||
required: false
|
|
||||||
state:
|
|
||||||
description:
|
|
||||||
- Determines if the database should be created or destroyed
|
|
||||||
choices: ['present', 'absent']
|
|
||||||
default: present
|
|
||||||
required: false
|
|
||||||
username:
|
|
||||||
description:
|
|
||||||
- user to auth with influxdb
|
|
||||||
default: root
|
|
||||||
required: false
|
|
||||||
password:
|
|
||||||
description:
|
|
||||||
- password to auth username with influxdb
|
|
||||||
default: root
|
|
||||||
required: false
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
# Example influxdb_user command from Ansible Playbooks
|
- name: Create a user on localhost using default login credentials
|
||||||
- name: Create User
|
|
||||||
influxdb_user:
|
influxdb_user:
|
||||||
user_name: "{{influxdb_user_name}}"
|
user_name: john
|
||||||
user_password: "{{influxdb_user_password}}"
|
user_password: s3cr3t
|
||||||
state: present
|
|
||||||
|
|
||||||
- name: Destroy User
|
- name: Create a user on localhost using custom login credentials
|
||||||
influxdb_user:
|
influxdb_user:
|
||||||
user_name: "{{influxdb_user_name}}"
|
user_name: john
|
||||||
username: "{{influxdb_password}}"
|
user_password: s3cr3t
|
||||||
password: "{{influxdb_user_password}}"
|
login_username: "{{ influxdb_username }}"
|
||||||
state: absent
|
login_password: "{{ influxdb_password }}"
|
||||||
|
|
||||||
- name: Create user on dest host
|
- name: Create an admin user on a remote host using custom login credentials
|
||||||
influxdb_user:
|
influxdb_user:
|
||||||
hostname: "{{influxdb_ip_address}}"
|
user_name: john
|
||||||
username: "{{influxdb_username}}"
|
user_password: s3cr3t
|
||||||
password: "{{influxdb_password}}"
|
admin: yes
|
||||||
user_name: "{{influxdb_user_name}}"
|
hostname: "{{ influxdb_hostname }}"
|
||||||
user_password: "{{influxdb_user_password}}"
|
login_username: "{{ influxdb_username }}"
|
||||||
admin: true
|
login_password: "{{ influxdb_password }}"
|
||||||
state: present
|
|
||||||
|
- name: Destroy a user using custom login credentials
|
||||||
|
influxdb_user:
|
||||||
|
user_name: john
|
||||||
|
login_username: "{{ influxdb_username }}"
|
||||||
|
login_password: "{{ influxdb_password }}"
|
||||||
|
state: absent
|
||||||
'''
|
'''
|
||||||
|
|
||||||
RETURN = '''
|
RETURN = '''
|
||||||
|
|
|
@ -9,17 +9,21 @@ class ModuleDocFragment(object):
|
||||||
options:
|
options:
|
||||||
hostname:
|
hostname:
|
||||||
description:
|
description:
|
||||||
- The hostname or IP address on which InfluxDB server is listening
|
- The hostname or IP address on which InfluxDB server is listening.
|
||||||
- Since version 2.5, defaulted to localhost.
|
- Since version 2.5, defaulted to localhost.
|
||||||
default: localhost
|
default: localhost
|
||||||
username:
|
username:
|
||||||
description:
|
description:
|
||||||
- Username that will be used to authenticate against InfluxDB server
|
- Username that will be used to authenticate against InfluxDB server.
|
||||||
|
- Alias C(login_username) added in version 2.5.
|
||||||
default: root
|
default: root
|
||||||
|
aliases: [ login_username ]
|
||||||
password:
|
password:
|
||||||
description:
|
description:
|
||||||
- Password that will be used to authenticate against InfluxDB server
|
- Password that will be used to authenticate against InfluxDB server.
|
||||||
|
- Alias C(login_password) added in version 2.5.
|
||||||
default: root
|
default: root
|
||||||
|
aliases: [ login_password ]
|
||||||
port:
|
port:
|
||||||
description:
|
description:
|
||||||
- The port on which InfluxDB server is listening
|
- The port on which InfluxDB server is listening
|
||||||
|
|
Loading…
Add table
Reference in a new issue