use single ansible fact to delete user
Signed-off-by: Sebastian Gumprich <[email protected]>
This commit is contained in:
1 parent
d4a4faa16d
commit
7d68c6036c
1 file changed
+9
-18
@@ -80,32 +80,23 @@
|
||||
|
||||
- name: create a fact for users without password or authentication_string
|
||||
set_fact:
|
||||
users_wo_password_or_auth_string: "{{ mysql_users_wo_passwords_or_auth_string.query_result.0.0 | community.general.json_query('users') }}"
|
||||
users_wo_auth: "{{ mysql_users_wo_passwords_or_auth_string.query_result.0.0 | community.general.json_query('users') }}"
|
||||
when:
|
||||
- mysql_version.version.full is version('5.7.6', '>=')
|
||||
- mysql_users_wo_passwords_or_auth_string.query_result is defined
|
||||
- mysql_users_wo_passwords_or_auth_string.query_result != ""
|
||||
|
||||
- name: create a fact for users without password
|
||||
set_fact:
|
||||
users_wo_password: "{{ mysql_users_wo_passwords.query_result.0.0 | community.general.json_query('users') }}"
|
||||
users_wo_auth: "{{ mysql_users_wo_passwords.query_result.0.0 | community.general.json_query('users') }}"
|
||||
when:
|
||||
- mysql_version.version.full is version('5.7.6', '<')
|
||||
- mysql_users_wo_passwords.query_result is defined
|
||||
- mysql_users_wo_passwords.query_result != ""
|
||||
|
||||
- name: ensure that there are no users without password or authentication_string
|
||||
community.mysql.mysql_query:
|
||||
query:
|
||||
- "drop user {{ users_wo_password_or_auth_string }}"
|
||||
- "DROP USER {{ users_wo_auth }}"
|
||||
login_unix_socket: "{{ login_unix_socket | default(omit) }}"
|
||||
when:
|
||||
- users_wo_password_or_auth_string is defined
|
||||
- users_wo_password_or_auth_string != "" # noqa empty-string-compare
|
||||
- mysql_version.version.full is version('5.7.6', '>=')
|
||||
|
||||
- name: ensure that there are no users without password
|
||||
community.mysql.mysql_query:
|
||||
query:
|
||||
- "drop user {{ users_wo_password }}"
|
||||
login_unix_socket: "{{ login_unix_socket | default(omit) }}"
|
||||
when:
|
||||
- users_wo_password is defined
|
||||
- users_wo_password != "" # noqa empty-string-compare
|
||||
- mysql_version.version.full is version('5.7.6', '<')
|
||||
- users_wo_auth is defined
|
||||
- users_wo_auth != "" # noqa empty-string-compare
|
||||
Reference in new issue
Block a user