Skip to content

Commit

Permalink
change filter name to user_accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-indermuehle committed Oct 12, 2023
1 parent 71abdd7 commit db43c34
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 98 deletions.
2 changes: 1 addition & 1 deletion changelogs/fragments/lie_mysql_info_users_privs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

minor_changes:

- mysql_info - add filter ``users_privs`` (https://github.com/ansible-collections/community.mysql/pull/572).
- mysql_info - add filter ``user_accounts`` (https://github.com/ansible-collections/community.mysql/pull/572).
34 changes: 17 additions & 17 deletions plugins/modules/mysql_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
description:
- Limit the collected information by comma separated string or YAML list.
- Allowable values are C(version), C(databases), C(settings), C(global_status),
C(users), C(users_privs), C(engines), C(master_status), C(slave_status), C(slave_hosts).
C(users), C(user_accounts), C(engines), C(master_status), C(slave_status), C(slave_hosts).
- By default, collects all subsets.
- You can use '!' before value (for example, C(!settings)) to exclude it from the information.
- If you pass including and excluding values to the filter, for example, I(filter=!settings,version),
Expand Down Expand Up @@ -75,7 +75,7 @@
# ansible mysql-hosts -m mysql_info -a 'filter=databases,users'
# Display all users privileges:
# ansible mysql-hosts -m mysql_info -a 'filter=users_privs'
# ansible mysql-hosts -m mysql_info -a 'filter=user_accounts'
# Display only slave status:
# ansible standby -m mysql_info -a 'filter=slave_status'
Expand Down Expand Up @@ -133,7 +133,7 @@
delegate_to: server_source
community.mysql.mysql_info:
filter:
- users_privs
- user_accounts
register: result
# Step 2
Expand All @@ -150,7 +150,7 @@
resource_limits: "{{ item.resource_limits | default(omit) }}"
column_case_sensitive: true
state: present
loop: "{{ result.users_privs }}"
loop: "{{ result.user_accounts }}"
loop_control:
label: "{{ item.name }}@{{ item.host }}"
when:
Expand Down Expand Up @@ -221,7 +221,7 @@
type: dict
sample:
- { "localhost": { "root": { "Alter_priv": "Y", "Alter_routine_priv": "Y" } } }
users_privs:
user_accounts:
description:
- Information about users accounts.
- The output can be used as an input of the M(community.mysql.mysql_user) plugin.
Expand Down Expand Up @@ -334,7 +334,7 @@ def __init__(self, module, cursor):
'global_status': {},
'engines': {},
'users': {},
'users_privs': {},
'user_accounts': {},
'master_status': {},
'slave_hosts': {},
'slave_status': {},
Expand Down Expand Up @@ -403,8 +403,8 @@ def __collect(self, exclude_fields, return_empty_dbs, wanted):
if 'users' in wanted:
self.__get_users()

if 'users_privs' in wanted:
self.__get_users_privs()
if 'user_accounts' in wanted:
self.__get_user_accounts()

if 'master_status' in wanted:
self.__get_master_status()
Expand Down Expand Up @@ -544,23 +544,23 @@ def __get_users(self):
if vname not in ('Host', 'User'):
self.info['users'][host][user][vname] = self.__convert(val)

def __get_users_privs(self):
"""Get user privileges.
def __get_user_accounts(self):
"""Get user privileges, passwords, resources_limits, ...
Query the server to get all the users and return a string
of privileges that can be used by the mysql_user plugin.
For instance:
"users_privs": [
"user_accounts": [
{
"host": "users_privs.com",
"host": "user_accounts.com",
"priv": "*.*: ALL,GRANT",
"name": "users_privs_adm"
"name": "user_accounts_adm"
},
{
"host": "users_privs.com",
"priv": "`mysql`.*: SELECT/`users_privs_db`.*: SELECT",
"name": "users_privs_multi"
"host": "user_accounts.com",
"priv": "`mysql`.*: SELECT/`user_accounts_db`.*: SELECT",
"name": "user_accounts_multi"
}
]
"""
Expand Down Expand Up @@ -622,7 +622,7 @@ def __get_users_privs(self):

output.append(output_dict)

self.info['users_privs'] = output
self.info['user_accounts'] = output

def __get_databases(self, exclude_fields, return_empty_dbs):
"""Get info about databases."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DELIMITER //
DROP PROCEDURE IF EXISTS users_privs_db.get_all_items;
CREATE PROCEDURE users_privs_db.get_all_items()
DROP PROCEDURE IF EXISTS user_accounts_db.get_all_items;
CREATE PROCEDURE user_accounts_db.get_all_items()
BEGIN
SELECT * from users_privs_db.t1;
SELECT * from user_accounts_db.t1;
END //
DELIMITER ;
Loading

0 comments on commit db43c34

Please sign in to comment.