4 Commits

Author SHA1 Message Date
Ludovic Cartier
fdeb93f4dc update template name && add buffer_pool_instances into template 2025-12-29 17:54:24 +01:00
Ludovic Cartier
e14f28f6c1 template - add percona_innodb_buffer_pool_instances 2025-12-29 17:14:28 +01:00
camille.prugnard
45334ef3c3 Refactor user creation tasks to allow multiple hosts with a list 2025-12-19 10:14:09 +01:00
camille.prugnard
c2693caf0e Fix wrong privs in case of list 2025-12-19 09:54:30 +01:00
5 changed files with 36 additions and 12 deletions

View File

@@ -4,7 +4,7 @@ Installs and manages Percona Server on Debian.
## Requirements ## Requirements
None. - Ansible 10+
## Role Variables ## Role Variables

View File

@@ -36,6 +36,7 @@ percona_table_definition_cache: 2000
# InnoDB settings # InnoDB settings
percona_innodb_buffer_pool_size: "1G" percona_innodb_buffer_pool_size: "1G"
percona_innodb_buffer_pool_instances: 1
percona_innodb_log_file_size: "256M" percona_innodb_log_file_size: "256M"
percona_innodb_log_buffer_size: "16M" percona_innodb_log_buffer_size: "16M"
percona_innodb_flush_log_at_trx_commit: 1 percona_innodb_flush_log_at_trx_commit: 1

View File

@@ -2,7 +2,7 @@
- name: percona | configure Percona Server - name: percona | configure Percona Server
template: template:
src: my.cnf.j2 src: my.cnf.j2
dest: /etc/mysql/conf.d/01-ansible.cnf dest: /etc/mysql/conf.d/01-override.cnf
mode: '0644' mode: '0644'
notify: Restart Percona Server notify: Restart Percona Server
@@ -28,4 +28,4 @@
plugin_auth_string: "{{ percona_root_password }}" plugin_auth_string: "{{ percona_root_password }}"
salt: "{{ percona_caching_sha2_password_salt }}" salt: "{{ percona_caching_sha2_password_salt }}"
login_unix_socket: /var/run/mysqld/mysqld.sock login_unix_socket: /var/run/mysqld/mysqld.sock
ignore_errors: true # In case password is already set and socket auth is disabled ignore_errors: true # In case password is already set and socket auth is disabled

View File

@@ -3,25 +3,47 @@
mysql_user: mysql_user:
name: "{{ item.name }}" name: "{{ item.name }}"
password: "{{ item.password }}" password: "{{ item.password }}"
host: "{{ item.host | default('%') }}" host: "{{ item.host }}"
priv: "{{ item.priv | default('*.*:USAGE') }}" priv: "{{ (item.priv | join('/')) if item.priv is iterable and item.priv is not string else (item.priv | default('*.*:USAGE')) }}"
plugin: "mysql_native_password" plugin: "mysql_native_password"
state: present state: present
login_user: root login_user: root
login_password: "{{ percona_root_password }}" login_password: "{{ percona_root_password }}"
loop: "{{ percona_users }}" vars:
when: item.auth_plugin is defined and item.auth_plugin == 'mysql_native_password' 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 - name: percona | create users
mysql_user: mysql_user:
name: "{{ item.name }}" name: "{{ item.name }}"
host: "{{ item.host | default('%') }}" host: "{{ item.host }}"
priv: "{{ item.priv | default('*.*:USAGE') }}" 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: caching_sha2_password
plugin_auth_string: "{{ item.password }}" plugin_auth_string: "{{ item.password }}"
salt: "{{ percona_caching_sha2_password_salt }}" salt: "{{ percona_caching_sha2_password_salt }}"
state: present state: present
login_user: root login_user: root
login_password: "{{ percona_root_password }}" login_password: "{{ percona_root_password }}"
loop: "{{ percona_users }}" vars:
when: item.auth_plugin is not defined or item.auth_plugin == 'caching_sha2_password' 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 }}"

View File

@@ -26,6 +26,7 @@ table_definition_cache = {{ percona_table_definition_cache }}
# InnoDB settings # InnoDB settings
innodb_buffer_pool_size = {{ percona_innodb_buffer_pool_size }} innodb_buffer_pool_size = {{ percona_innodb_buffer_pool_size }}
innodb_buffer_pool_instances = {{ percona_innodb_buffer_pool_instances }}
innodb_log_file_size = {{ percona_innodb_log_file_size }} innodb_log_file_size = {{ percona_innodb_log_file_size }}
innodb_log_buffer_size = {{ percona_innodb_log_buffer_size }} innodb_log_buffer_size = {{ percona_innodb_log_buffer_size }}
innodb_flush_log_at_trx_commit = {{ percona_innodb_flush_log_at_trx_commit }} innodb_flush_log_at_trx_commit = {{ percona_innodb_flush_log_at_trx_commit }}
@@ -65,4 +66,4 @@ performance_schema = {{ percona_performance_schema }}
sql_mode = {{ percona_sql_mode }} sql_mode = {{ percona_sql_mode }}
# Authentication # Authentication
mysql_native_password = ON mysql_native_password = ON