Browse Source

Replace /etc/my.cnf.d if it exists for SUSE/CentOS

In SUSE/CentOS systems, /etc/my.cnf.d may already exist on the
system. We need to ensure that it is removed if that is true so
that we can replace it with symlinks to the directories expected
to be used by the MariaDB packages instead. By replacing it with
symlinks, we allow anything else on the system expecting those
paths to be in place to still work as before, but we also ensure
that the MariaDB package expectations are met.

Change-Id: I07fd0872a76af9dab89414207e297946e84965cf
Jesse Pretorius 3 months ago
parent
commit
04f655f50c
2 changed files with 66 additions and 7 deletions
  1. 42
    7
      tasks/galera_install_yum.yml
  2. 24
    0
      tasks/galera_install_zypper.yml

+ 42
- 7
tasks/galera_install_yum.yml View File

@@ -36,18 +36,53 @@
36 36
     warn: no
37 37
     executable: /bin/bash
38 38
 
39
+# In SUSE/CentOS systems, /etc/my.cnf.d may already exist on the
40
+# system. We need to ensure that it is removed if that is true so
41
+# that we can replace it with symlinks to the directories expected
42
+# to be used by the MariaDB packages instead.
43
+- name: Stat /etc/my.cnf.d
44
+  stat:
45
+    path: /etc/my.cnf.d
46
+    get_attributes: no
47
+    get_checksum: no
48
+    get_mime: no
49
+  register: mycnfd_stat
50
+
51
+- name: Destroy my.cnf.d dir if is dir
52
+  file:
53
+    path: /etc/my.cnf.d
54
+    state: absent
55
+    force: true
56
+  when:
57
+    - mycnfd_stat.stat.isdir is defined
58
+    - mycnfd_stat.stat.isdir == True
59
+
60
+# We replace the default paths for the system with symlinks to
61
+# the paths used by the MariaDB packages so ensure that any other
62
+# system expectations are still met.
39 63
 - name: Update the local file system CRUD
40 64
   file:
41
-    src: "{{ item.src|default(omit) }}"
65
+    src: "{{ item.src | default(omit) }}"
42 66
     path: "{{ item.path }}"
43 67
     state: "{{ item.state }}"
44
-    force: "{{ item.force|default(omit) }}"
68
+    force: "{{ item.force | default(omit) }}"
45 69
   with_items:
46
-    - { path: "/etc/mysql", state: "directory" }
47
-    - { path: "/etc/mysql/conf.d", state: "directory" }
48
-    - { src: "/usr/lib64/galera", path: "/usr/lib/galera", state: "link", force: true }
49
-    - { src: "/etc/mysql/conf.d", path: "/etc/my.cnf.d", state: "link", force: true }
50
-    - { src: "/etc/mysql/my.cnf", path: "/etc/my.cnf", state: "link", force: true }
70
+    - path: "/etc/mysql"
71
+      state: "directory"
72
+    - path: "/etc/mysql/conf.d"
73
+      state: "directory"
74
+    - src: "/usr/lib64/galera"
75
+      path: "/usr/lib/galera"
76
+      state: "link"
77
+      force: true
78
+    - src: "/etc/mysql/conf.d"
79
+      path: "/etc/my.cnf.d"
80
+      state: "link"
81
+      force: true
82
+    - src: "/etc/mysql/my.cnf"
83
+      path: "/etc/my.cnf"
84
+      state: "link"
85
+      force: true
51 86
 
52 87
 - name: If a keyfile is provided, copy the gpg keyfile to the key location
53 88
   copy:

+ 24
- 0
tasks/galera_install_zypper.yml View File

@@ -18,6 +18,30 @@
18 18
     name: "{{ galera_server_mariadb_distro_packages_remove }}"
19 19
     state: absent
20 20
 
21
+# In SUSE/CentOS systems, /etc/my.cnf.d may already exist on the
22
+# system. We need to ensure that it is removed if that is true so
23
+# that we can replace it with symlinks to the directories expected
24
+# to be used by the MariaDB packages instead.
25
+- name: Stat /etc/my.cnf.d
26
+  stat:
27
+    path: /etc/my.cnf.d
28
+    get_attributes: no
29
+    get_checksum: no
30
+    get_mime: no
31
+  register: mycnfd_stat
32
+
33
+- name: Destroy my.cnf.d dir if is dir
34
+  file:
35
+    path: /etc/my.cnf.d
36
+    state: absent
37
+    force: true
38
+  when:
39
+    - mycnfd_stat.stat.isdir is defined
40
+    - mycnfd_stat.stat.isdir == True
41
+
42
+# We replace the default paths for the system with symlinks to
43
+# the paths used by the MariaDB packages so ensure that any other
44
+# system expectations are still met.
21 45
 - name: Update the local file system CRUD
22 46
   file:
23 47
     src: "{{ item.src|default(omit) }}"

Loading…
Cancel
Save