Skip to content

Commit

Permalink
fix issue #199
Browse files Browse the repository at this point in the history
- Use a list with name and mode (optional) attribut
- Use a loop_contorl / loop_var for better read the playbook
- Change only the permission of /etc/mysql/debian.cnf from 0644 to 0600 on all debian but it's can easily update to other OS
  • Loading branch information
Christian IUGA committed Feb 29, 2024
1 parent 1267324 commit 6b408d6
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 28 deletions.
20 changes: 12 additions & 8 deletions tasks/setup_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@
verbosity: 3

- name: setup_cluster | configuring settings for mariadb and galera
template:
src: "{{ item }}.j2"
dest: "/{{ item }}"
mode: "0644"
ansible.builtin.template:
src: "{{ file.name }}.j2"
dest: "/{{ file.name }}"
mode: "{{ file.mode |default ('0644') }}"
follow: true
become: true
register: "_mariadb_galera_cluster_reconfigured"
loop: "{{ mariadb_confs }}"
loop_control:
loop_var: file

- name: setup_cluster | cluster rolling restart - apply config changes (first node)
include_tasks: manage_node_state.yml
Expand Down Expand Up @@ -162,11 +164,13 @@
not galera_cluster_configured.stat.exists
- name: setup_cluster | cluster bootstrap - configuring final galera config for first node
template:
src: "{{ item }}.j2"
dest: "/{{ item }}"
mode: "0644"
ansible.builtin.template:
src: "{{ file.name }}.j2"
dest: "/{{ file.name }}"
mode: "{{ file.mode |default ('0644') }}"
loop: "{{ mariadb_confs }}"
loop_control:
loop_var: file
become: true
when: >
not galera_cluster_configured.stat.exists and
Expand Down
2 changes: 1 addition & 1 deletion vars/centos-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mariabackup_packages:
mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
mariadb_systemd_service_name: "mariadb"
mariadb_confs:
- "etc/my.cnf.d/server.cnf"
- name: "etc/my.cnf.d/server.cnf"
mariadb_temp_confs:
- "etc/my.cnf.d/server.cnf"
galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
7 changes: 4 additions & 3 deletions vars/debian-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ mariabackup_packages:
mariadb_certificates_dir: "/etc/mysql/certificates"
mariadb_systemd_service_name: "mariadb"
mariadb_confs:
- "etc/mysql/debian.cnf"
- "etc/mysql/my.cnf"
- "etc/mysql/conf.d/galera.cnf"
- name: "etc/mysql/debian.cnf"
mode: "0600"
- name: "etc/mysql/my.cnf"
- name: "etc/mysql/conf.d/galera.cnf"
mariadb_temp_confs:
- "etc/mysql/conf.d/galera.cnf"
galera_wsrep_provider: "/usr/lib/galera/libgalera_smm.so"
7 changes: 4 additions & 3 deletions vars/debian-12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ mariabackup_packages:
mariadb_certificates_dir: "/etc/mysql/certificates"
mariadb_systemd_service_name: "mariadb"
mariadb_confs:
- "etc/mysql/debian.cnf"
- "etc/mysql/my.cnf"
- "etc/mysql/conf.d/galera.cnf"
- name: "etc/mysql/debian.cnf"
mode: "0600"
- name: "etc/mysql/my.cnf"
- name: "etc/mysql/conf.d/galera.cnf"
mariadb_temp_confs:
- "etc/mysql/conf.d/galera.cnf"
galera_wsrep_provider: "/usr/lib/galera/libgalera_smm.so"
7 changes: 4 additions & 3 deletions vars/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ mariabackup_packages:
mariadb_certificates_dir: "/etc/mysql/certificates"
mariadb_systemd_service_name: "mysql"
mariadb_confs:
- "etc/mysql/debian.cnf"
- "etc/mysql/my.cnf"
- "etc/mysql/conf.d/galera.cnf"
- name: "etc/mysql/debian.cnf"
mode: 0600
- name: "etc/mysql/my.cnf"
- name: "etc/mysql/conf.d/galera.cnf"
mariadb_temp_confs:
- "etc/mysql/conf.d/galera.cnf"
galera_wsrep_provider: "/usr/lib/galera/libgalera_smm.so"
2 changes: 1 addition & 1 deletion vars/fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mariabackup_packages:
mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
mariadb_systemd_service_name: "mariadb"
mariadb_confs:
- "etc/my.cnf.d/server.cnf"
- name: "etc/my.cnf.d/server.cnf"
mariadb_temp_confs:
- "etc/my.cnf.d/server.cnf"
galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
2 changes: 1 addition & 1 deletion vars/redhat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mariabackup_packages:
mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
mariadb_systemd_service_name: "mysql"
mariadb_confs:
- "etc/my.cnf.d/server.cnf"
- name: "etc/my.cnf.d/server.cnf"
mariadb_temp_confs:
- "etc/my.cnf.d/server.cnf"
galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
2 changes: 1 addition & 1 deletion vars/rocky-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mariabackup_packages:
mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
mariadb_systemd_service_name: "mariadb"
mariadb_confs:
- "etc/my.cnf.d/server.cnf"
- name: "etc/my.cnf.d/server.cnf"
mariadb_temp_confs:
- "etc/my.cnf.d/server.cnf"
galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
2 changes: 1 addition & 1 deletion vars/rocky-9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mariabackup_packages:
mariadb_certificates_dir: "/etc/my.cnf.d/certificates"
mariadb_systemd_service_name: "mariadb"
mariadb_confs:
- "etc/my.cnf.d/server.cnf"
- name: "etc/my.cnf.d/server.cnf"
mariadb_temp_confs:
- "etc/my.cnf.d/server.cnf"
galera_wsrep_provider: "/usr/lib64/galera-4/libgalera_smm.so"
6 changes: 3 additions & 3 deletions vars/ubuntu-20.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ mariabackup_packages:
mariadb_certificates_dir: "/etc/mysql/certificates"
mariadb_systemd_service_name: "mariadb"
mariadb_confs:
- "etc/mysql/debian.cnf"
- "etc/mysql/my.cnf"
- "etc/mysql/conf.d/galera.cnf"
- name: "etc/mysql/debian.cnf"
- name: "etc/mysql/my.cnf"
- name: "etc/mysql/conf.d/galera.cnf"
mariadb_temp_confs:
- "etc/mysql/conf.d/galera.cnf"
galera_wsrep_provider: "/usr/lib/galera/libgalera_smm.so"
6 changes: 3 additions & 3 deletions vars/ubuntu-22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ mariabackup_packages:
mariadb_certificates_dir: "/etc/mysql/certificates"
mariadb_systemd_service_name: "mariadb"
mariadb_confs:
- "etc/mysql/debian.cnf"
- "etc/mysql/my.cnf"
- "etc/mysql/conf.d/galera.cnf"
- name: "etc/mysql/debian.cnf"
- name: "etc/mysql/my.cnf"
- name: "etc/mysql/conf.d/galera.cnf"
mariadb_temp_confs:
- "etc/mysql/conf.d/galera.cnf"
galera_wsrep_provider: "/usr/lib/galera/libgalera_smm.so"

0 comments on commit 6b408d6

Please sign in to comment.