]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
defaults: add missing handlers for rbd mirorr and mgr
authorSébastien Han <seb@redhat.com>
Wed, 27 Sep 2017 00:08:40 +0000 (02:08 +0200)
committerSébastien Han <seb@redhat.com>
Fri, 29 Sep 2017 00:38:24 +0000 (02:38 +0200)
Signed-off-by: Sébastien Han <seb@redhat.com>
group_vars/all.yml.sample
group_vars/rhcs.yml.sample
roles/ceph-config/tasks/main.yml
roles/ceph-defaults/defaults/main.yml
roles/ceph-defaults/handlers/main.yml
roles/ceph-defaults/templates/restart_mgr_daemon.sh.j2 [new file with mode: 0644]
roles/ceph-defaults/templates/restart_rbd_mirror_daemon.sh.j2 [new file with mode: 0644]

index e2d54f78b7e7050695330fa3f0a3b4e3dca92d71..22110f879b4f5c16c40592d8b845b987808154df 100644 (file)
@@ -398,6 +398,14 @@ dummy:
 #handler_health_nfs_check_retries: 5
 #handler_health_nfs_check_delay: 10
 
+# RBD MIRROR handler checks
+#handler_health_rbd_mirror_check_retries: 5
+#handler_health_rbd_mirror_check_delay: 10
+
+# MGR handler checks
+#handler_health_mgr_check_retries: 5
+#handler_health_mgr_check_delay: 10
+
 ###############
 # NFS-GANESHA #
 ###############
index 112efa41e7372941c63474d90f64bf722f3377e2..5ba40b7fc20512f151f0a7b1041bdd05fda1894c 100644 (file)
@@ -398,6 +398,14 @@ ceph_repository: rhcs
 #handler_health_nfs_check_retries: 5
 #handler_health_nfs_check_delay: 10
 
+# RBD MIRROR handler checks
+#handler_health_rbd_mirror_check_retries: 5
+#handler_health_rbd_mirror_check_delay: 10
+
+# MGR handler checks
+#handler_health_mgr_check_retries: 5
+#handler_health_mgr_check_delay: 10
+
 ###############
 # NFS-GANESHA #
 ###############
index 3ecf5d9e7261e9fd3ba350bb660bbffb6c9e2511..4a5df3350330cc626a7c7fbefe6c5f0459f570a2 100644 (file)
       - restart ceph osds
       - restart ceph mdss
       - restart ceph rgws
+      - restart ceph rbdmirrors
+      - restart ceph mgrs
 
   - name: set fsid fact when generate_fsid = true
     set_fact:
index cfdbbbdcaf0115dd74f79096202bf754721719bb..20a31d3e749a350a9076cecb7daa9b42ea6b583a 100644 (file)
@@ -390,6 +390,14 @@ handler_health_rgw_check_delay: 10
 handler_health_nfs_check_retries: 5
 handler_health_nfs_check_delay: 10
 
+# RBD MIRROR handler checks
+handler_health_rbd_mirror_check_retries: 5
+handler_health_rbd_mirror_check_delay: 10
+
+# MGR handler checks
+handler_health_mgr_check_retries: 5
+handler_health_mgr_check_delay: 10
+
 ###############
 # NFS-GANESHA #
 ###############
index 885a42abeabd7afaf7a6ad2b894235db61e01a85..98799bd9a5a5933b8d19a2ede6c10d2e91e106f7 100644 (file)
     # We do not want to run these checks on initial deployment (`socket.rc == 0`)
     - nfs_group_name in group_names
     - nfs_socket_stat.rc == 0
+
+- name: copy rbd mirror restart script
+  template:
+    src: restart_rbd_mirror_daemon.sh.j2
+    dest: /tmp/restart_rbd_mirror_daemon.sh
+    owner: root
+    group: root
+    mode: 0750
+  listen: "restart ceph rbdmirrors"
+  when:
+    - rbdmirror_group_name in group_names
+    - inventory_hostname in play_hosts
+
+- name: restart ceph rbd mirror daemon(s)
+  command: /tmp/restart_rbd_mirror_daemon.sh
+  listen: "restart ceph rbdmirrors"
+  when:
+    # We do not want to run these checks on initial deployment (`socket.rc == 0`)
+    - rbdmirror_group_name in group_names
+    - rbd_mirror_socket_stat.rc == 0
+
+- name: copy mgr restart script
+  template:
+    src: restart_mgr_daemon.sh.j2
+    dest: /tmp/restart_mgr_daemon.sh
+    owner: root
+    group: root
+    mode: 0750
+  listen: "restart ceph mgrs"
+  when:
+    - mgr_group_name in group_names
+    - inventory_hostname in play_hosts
+
+- name: restart ceph mgr daemon(s)
+  command: /tmp/restart_mgr_daemon.sh
+  listen: "restart ceph mgrs"
+  when:
+    # We do not want to run these checks on initial deployment (`socket.rc == 0`)
+    - mgr_group_name in group_names
+    - mgr_socket_stat.rc == 0
diff --git a/roles/ceph-defaults/templates/restart_mgr_daemon.sh.j2 b/roles/ceph-defaults/templates/restart_mgr_daemon.sh.j2
new file mode 100644 (file)
index 0000000..bfc85ba
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+RETRIES="{{ handler_health_mgr_check_retries }}"
+DELAY="{{ handler_health_mgr_check_delay }}"
+MGR_NAME="{{ ansible_hostname }}"
+SOCKET=/var/run/ceph/{{ cluster }}-mgr.${MGR_NAME}.asok
+
+# First, restart the daemon
+systemctl restart ceph-mgr@${MGR_NAME}
+
+COUNT=10
+# Wait and ensure the socket exists after restarting the daemds
+while [ $RETRIES -ne 0 ]; do
+  {{ docker_exec_cmd }} test -S $SOCKET && exit 0
+  sleep $DELAY
+  let RETRIES=RETRIES-1
+done
+# If we reach this point, it means the socket is not present.
+echo "Socket file ${SOCKET} could not be found, which means ceph manager is not running."
+exit 1
diff --git a/roles/ceph-defaults/templates/restart_rbd_mirror_daemon.sh.j2 b/roles/ceph-defaults/templates/restart_rbd_mirror_daemon.sh.j2
new file mode 100644 (file)
index 0000000..a9e9f6e
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+RETRIES="{{ handler_health_rbd_mirror_check_retries }}"
+DELAY="{{ handler_health_rbd_mirror_check_delay }}"
+RBD_MIRROR_NAME="{{ ansible_hostname }}"
+SOCKET=/var/run/ceph/{{ cluster }}-client.rbd-mirror.${RBD_MIRROR_NAME}.asok
+
+# First, restart the daemon
+systemctl restart ceph-rbd-mirror@rbd-mirror.${RBD_MIRROR_NAME}
+
+COUNT=10
+# Wait and ensure the socket exists after restarting the daemon
+while [ $RETRIES -ne 0 ]; do
+  {{ docker_exec_cmd }} test -S $SOCKET && exit 0
+  sleep $DELAY
+  let RETRIES=RETRIES-1
+done
+# If we reach this point, it means the socket is not present.
+echo "Socket file ${SOCKET} could not be found, which means rbd mirror is not running."
+exit 1