-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ahmadali shafiee <mail@ahmadalli.net>
- Loading branch information
Showing
6 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
percona_xtradb_cluster_version: "8.0" | ||
|
||
percona_xtradb_cluster_name: pxc-cluster | ||
# name of the inventory group containing the pxc nodes | ||
percona_xtradb_cluster_inventory_group_name: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
- name: get key | ||
slurp: | ||
src: /var/lib/mysql/{{ _key | mandatory }} | ||
register: _key_slurp | ||
when: inventory_hostname == groups[percona_xtradb_cluster_inventory_group_name][0] | ||
- name: write key | ||
copy: | ||
dest: /var/lib/mysql/{{ _key | mandatory }} | ||
content: "{{ _key_slurp['content'] | b64decode }}" | ||
delegate_to: "{{ item }}" | ||
delegate_facts: true | ||
loop: "{{ groups[percona_xtradb_cluster_inventory_group_name][1:] }}" | ||
when: inventory_hostname == groups[percona_xtradb_cluster_inventory_group_name][0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
- name: set comman facts | ||
ansible.builtin.include_vars: common.yaml | ||
- name: copy keys | ||
include: copy-key.yaml | ||
loop: | ||
- ca-key.pem | ||
- ca.pem | ||
- server-key.pem | ||
- server-cert.pem | ||
loop_control: | ||
loop_var: _key | ||
- name: write mysqld configuration files | ||
template: | ||
src: mysqld-{{ percona_xtradb_cluster_version }}.conf.j2 | ||
dest: /etc/mysql/mysql.conf.d/mysqld.cnf | ||
owner: root | ||
group: root | ||
mode: "0644" | ||
- name: write wsrep configuration files | ||
template: | ||
src: wsrep-{{ percona_xtradb_cluster_version }}.conf.j2 | ||
dest: /etc/mysql/mysql.conf.d/wsrep.cnf | ||
owner: root | ||
group: root | ||
mode: "0644" |
14 changes: 14 additions & 0 deletions
14
roles/percona/xtradb/configure/templates/mysqld-8.0.conf.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Template my.cnf for PXC | ||
# Edit to your requirements. | ||
[client] | ||
socket=/var/run/mysqld/mysqld.sock | ||
|
||
[mysqld] | ||
server-id={{ percona_xtradb_cluster_server_id }} | ||
datadir=/var/lib/mysql | ||
socket=/var/run/mysqld/mysqld.sock | ||
log-error=/var/log/mysql/error.log | ||
pid-file=/var/run/mysqld/mysqld.pid | ||
|
||
# Binary log expiration period is 604800 seconds, which equals 7 days | ||
binlog_expire_logs_seconds=604800 |
42 changes: 42 additions & 0 deletions
42
roles/percona/xtradb/configure/templates/wsrep-8.0.conf.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[mysqld] | ||
# Path to Galera library | ||
wsrep_provider=/usr/lib/galera4/libgalera_smm.so | ||
|
||
# Cluster name | ||
wsrep_cluster_name={{ percona_xtradb_cluster_name }} | ||
|
||
# Cluster connection URL contains IPs of nodes | ||
#If no IP is found, this implies that a new cluster needs to be created, | ||
#in order to do that you need to bootstrap this node | ||
wsrep_cluster_address=gcomm://{{ percona_xtradb_cluster_host_ips | join(',') }} | ||
|
||
# In order for Galera to work correctly binlog format should be ROW | ||
binlog_format=ROW | ||
|
||
# Slave thread to use | ||
wsrep_slave_threads=8 | ||
|
||
wsrep_log_conflicts | ||
|
||
# This changes how InnoDB autoincrement locks are managed and is a requirement for Galera | ||
innodb_autoinc_lock_mode=2 | ||
|
||
#If wsrep_node_name is not specified, then system hostname will be used | ||
wsrep_node_name={{ inventory_hostname }} | ||
|
||
# Node IP address | ||
wsrep_node_address={{ ip | default(ansible_host, true) }} | ||
|
||
#pxc_strict_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER | ||
pxc_strict_mode=ENFORCING | ||
|
||
# SST method | ||
wsrep_sst_method=xtrabackup-v2 | ||
|
||
wsrep_provider_options=”socket.ssl_key=server-key.pem;socket.ssl_cert=server-cert.pem;socket.ssl_ca=ca.pem” | ||
|
||
[sst] | ||
encrypt=4 | ||
ssl-key=server-key.pem | ||
ssl-ca=ca.pem | ||
ssl-cert=server-cert.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
percona_xtradb_cluster_host_ips: > | ||
[ | ||
{% for host in query('inventory_hostnames', percona_xtradb_cluster_inventory_group_name) %} | ||
"{{ hostvars[host]['ip'] | default(hostvars[host]['ansible_host'], true) }}" | ||
{% if not loop.last %},{% endif %} | ||
{% endfor %} | ||
] | ||
percona_xtradb_cluster_server_id: "{{ groups[percona_xtradb_cluster_inventory_group_name].index(inventory_hostname) + 1 }}" |