From 77c6a68a02d7c60fc09175cdbb0f087156d5890f Mon Sep 17 00:00:00 2001 From: Laurent Indermuehle Date: Thu, 21 Sep 2023 14:05:10 +0200 Subject: [PATCH] document how to use mysql_info to clone accounts to another server --- plugins/modules/mysql_info.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/plugins/modules/mysql_info.py b/plugins/modules/mysql_info.py index f01959f..87e7a0a 100644 --- a/plugins/modules/mysql_info.py +++ b/plugins/modules/mysql_info.py @@ -125,6 +125,31 @@ EXAMPLES = r''' - databases exclude_fields: db_size return_empty_dbs: true + +- name: Clone users on another server - Step 1 + delegate_to: server_source + community.mysql.mysql_info: + filter: + - users_privs + register: result + +- name: Clone users on another server - Step 2 + community.mysql.mysql_user: + name: "{{ item.name }}" + host: "{{ item.host }}" + plugin: "{{ item.plugin | default(omit) }}" + plugin_auth_string: "{{ item.auth_string | default(omit) }}" + tls_require: "{{ item.tls_require | default(omit) }}" + priv: "{{ item.priv | default(omit) }}" + resource_limits: "{{ item.resource_limits | default(omit) }}" + state: present + loop: "{{ result.users_privs }}" + loop_control: + label: "{{ item.name }}@{{ item.host }}" + when: + - item.name != 'root' # In case you don't want to import admin accounts + - item.name != 'mariadb.sys' + - item.name != 'mysql' ''' RETURN = r'''