|
|
|
|
@@ -3,25 +3,47 @@
|
|
|
|
|
mysql_user:
|
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
|
password: "{{ item.password }}"
|
|
|
|
|
host: "{{ item.host | default('%') }}"
|
|
|
|
|
priv: "{{ item.priv | default('*.*:USAGE') }}"
|
|
|
|
|
host: "{{ item.host }}"
|
|
|
|
|
priv: "{{ (item.priv | join('/')) if item.priv is iterable and item.priv is not string else (item.priv | default('*.*:USAGE')) }}"
|
|
|
|
|
plugin: "mysql_native_password"
|
|
|
|
|
state: present
|
|
|
|
|
login_user: root
|
|
|
|
|
login_password: "{{ percona_root_password }}"
|
|
|
|
|
loop: "{{ percona_users }}"
|
|
|
|
|
when: item.auth_plugin is defined and item.auth_plugin == 'mysql_native_password'
|
|
|
|
|
vars:
|
|
|
|
|
user_host_pairs: |
|
|
|
|
|
{%- set pairs = [] -%}
|
|
|
|
|
{%- for user in percona_users -%}
|
|
|
|
|
{%- if user.auth_plugin is defined and user.auth_plugin == 'mysql_native_password' -%}
|
|
|
|
|
{%- set hosts = [user.host | default('%')] if user.host is undefined or user.host is string else user.host -%}
|
|
|
|
|
{%- for host in hosts -%}
|
|
|
|
|
{%- set _ = pairs.append(user | combine({'host': host})) -%}
|
|
|
|
|
{%- endfor -%}
|
|
|
|
|
{%- endif -%}
|
|
|
|
|
{%- endfor -%}
|
|
|
|
|
{{ pairs }}
|
|
|
|
|
loop: "{{ user_host_pairs }}"
|
|
|
|
|
|
|
|
|
|
- name: percona | create users
|
|
|
|
|
mysql_user:
|
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
|
host: "{{ item.host | default('%') }}"
|
|
|
|
|
priv: "{{ item.priv | default('*.*:USAGE') }}"
|
|
|
|
|
host: "{{ item.host }}"
|
|
|
|
|
priv: "{{ (item.priv | join('/')) if item.priv is iterable and item.priv is not string else (item.priv | default('*.*:USAGE')) }}"
|
|
|
|
|
plugin: caching_sha2_password
|
|
|
|
|
plugin_auth_string: "{{ item.password }}"
|
|
|
|
|
salt: "{{ percona_caching_sha2_password_salt }}"
|
|
|
|
|
state: present
|
|
|
|
|
login_user: root
|
|
|
|
|
login_password: "{{ percona_root_password }}"
|
|
|
|
|
loop: "{{ percona_users }}"
|
|
|
|
|
when: item.auth_plugin is not defined or item.auth_plugin == 'caching_sha2_password'
|
|
|
|
|
vars:
|
|
|
|
|
user_host_pairs: |
|
|
|
|
|
{%- set pairs = [] -%}
|
|
|
|
|
{%- for user in percona_users -%}
|
|
|
|
|
{%- if user.auth_plugin is not defined or user.auth_plugin == 'caching_sha2_password' -%}
|
|
|
|
|
{%- set hosts = [user.host | default('%')] if user.host is undefined or user.host is string else user.host -%}
|
|
|
|
|
{%- for host in hosts -%}
|
|
|
|
|
{%- set _ = pairs.append(user | combine({'host': host})) -%}
|
|
|
|
|
{%- endfor -%}
|
|
|
|
|
{%- endif -%}
|
|
|
|
|
{%- endfor -%}
|
|
|
|
|
{{ pairs }}
|
|
|
|
|
loop: "{{ user_host_pairs }}"
|
|
|
|
|
|