]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
defaults: only run socket checks on their specific roles
authorSébastien Han <seb@redhat.com>
Tue, 26 Sep 2017 22:55:31 +0000 (00:55 +0200)
committerSébastien Han <seb@redhat.com>
Fri, 29 Sep 2017 00:38:24 +0000 (02:38 +0200)
Running the socket check on all the hosts will override the default
value of docker_exec_cmd, leaving it with the last value (currently
rbd-mirror), as a result the subsequent docker_exec_cmd usage for the
:x

Signed-off-by: Sébastien Han <seb@redhat.com>
roles/ceph-defaults/handlers/main.yml
roles/ceph-defaults/tasks/check_socket.yml

index f911344a37053be189ac5aed0b391d15fe3e11f6..885a42abeabd7afaf7a6ad2b894235db61e01a85 100644 (file)
@@ -20,8 +20,8 @@
     listen: "restart ceph mons"
   when:
     # We do not want to run these checks on initial deployment (`socket.rc == 0`)
-    - mon_socket_stat.rc == 0
     - mon_group_name in group_names
+    - mon_socket_stat.rc == 0
 
 # This does not just restart OSDs but everything else too. Unfortunately
 # at this time the ansible role does not have an OSD id list to use
@@ -35,8 +35,8 @@
     mode: 0750
   listen: "restart ceph osds"
   when:
-    - inventory_hostname in play_hosts
     - osd_group_name in group_names
+    - inventory_hostname in play_hosts
 
 - name: restart containerized ceph osds daemon(s)
   command: /tmp/restart_osd_daemon.sh
   when:
     # We do not want to run these checks on initial deployment (`socket_osd_container_stat.results[n].rc == 0`)
     # except when a crush location is specified. ceph-disk will start the osds before the osd crush location is specified
+    - osd_group_name in group_names
     - containerized_deployment
     - ((crush_location is defined and crush_location) or item.get('rc') == 0)
     - handler_health_osd_check
     # See https://github.com/ceph/ceph-ansible/issues/1457 for the condition below
     - inventory_hostname in play_hosts
-    - osd_group_name in group_names
 
 - name: restart non-containerized ceph osds daemon(s)
   command: /tmp/restart_osd_daemon.sh
   listen: "restart ceph osds"
   when:
+    - osd_group_name in group_names
     - not containerized_deployment
     # We do not want to run these checks on initial deployment (`socket_osd_container.results[n].rc == 0`)
     # except when a crush location is specified. ceph-disk will start the osds before the osd crush location is specified
     - handler_health_osd_check
     # See https://github.com/ceph/ceph-ansible/issues/1457 for the condition below
     - inventory_hostname in play_hosts
-    - osd_group_name in group_names
 
-- name: copy mds restart script
-  template:
-    src: restart_mds_daemon.sh.j2
-    dest: /tmp/restart_mds_daemon.sh
-    owner: root
-    group: root
-    mode: 0750
-  listen: "restart ceph mdss"
-  when:
-    - inventory_hostname in play_hosts
-    - mds_group_name in group_names
+- block:
+  - name: copy mds restart script
+    template:
+      src: restart_mds_daemon.sh.j2
+      dest: /tmp/restart_mds_daemon.sh
+      owner: root
+      group: root
+      mode: 0750
+    listen: "restart ceph mdss"
+    when:
+      - mds_group_name in group_names
+      - inventory_hostname in play_hosts
 
-- name: restart ceph mds daemon(s)
-  command: /tmp/restart_mds_daemon.sh
-  listen: "restart ceph mdss"
+  - name: restart ceph mds daemon(s)
+    command: /tmp/restart_mds_daemon.sh
+    listen: "restart ceph mdss"
   when:
     # We do not want to run these checks on initial deployment (`socket.rc == 0`)
-    - mds_socket_stat.rc == 0
     - mds_group_name in group_names
+    - mds_socket_stat.rc == 0
 
 - name: copy rgw restart script
   template:
     mode: 0750
   listen: "restart ceph rgws"
   when:
-    - inventory_hostname in play_hosts
     - rgw_group_name in group_names
+    - inventory_hostname in play_hosts
 
 - name: restart ceph rgw daemon(s)
   command: /tmp/restart_rgw_daemon.sh
   listen: "restart ceph rgws"
   when:
     # We do not want to run these checks on initial deployment (`socket.rc == 0`)
-    - rgw_socket_stat.rc == 0
     - rgw_group_name in group_names
+    - rgw_socket_stat.rc == 0
 
-- name: restart ceph nfss
-  service:
-    name: nfs-ganesha
-    state: restarted
+- name: copy nfs restart script
+  template:
+    src: restart_nfs_daemon.sh.j2
+    dest: /tmp/restart_nfs_daemon.sh
+    owner: root
+    group: root
+    mode: 0750
+  listen: "restart ceph nfss"
+  when:
+    - nfs_group_name in group_names
+    - inventory_hostname in play_hosts
+
+- name: restart ceph nfs daemon(s)
+  command: /tmp/restart_nfs_daemon.sh
+  listen: "restart ceph nfss"
   when:
+    # 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
index 21b5de05417d585055731a8caa2abd79f56f4283..70ed0e4336ad5450cc9c21283fbb9bb7bcc58c7d 100644 (file)
@@ -4,6 +4,7 @@
   set_fact:
     docker_exec_cmd: "docker exec ceph-mon-{{ ansible_hostname }}"
   when:
+    - inventory_hostname in groups.get(mon_group_name, [])
     - containerized_deployment
 
 - name: check for a ceph mon socket
@@ -13,6 +14,8 @@
   failed_when: false
   always_run: true
   register: mon_socket_stat
+  when:
+    - inventory_hostname in groups.get(mon_group_name, [])
 
 - name: check if the ceph mon socket is in-use
   shell: |
@@ -22,6 +25,7 @@
   always_run: true
   register: mon_socket
   when:
+    - inventory_hostname in groups.get(mon_group_name, [])
     - mon_socket_stat.rc == 0
 
 - name: remove ceph mon socket if exists and not used by a process
@@ -29,6 +33,7 @@
     name: "{{ mon_socket_stat.stdout }}"
     state: absent
   when:
+    - inventory_hostname in groups.get(mon_group_name, [])
     - not containerized_deployment
     - mon_socket_stat.rc == 0
     - mon_socket.rc != 0
@@ -41,6 +46,7 @@
   always_run: true
   register: osd_socket_stat
   when:
+    - inventory_hostname in groups.get(osd_group_name, [])
     - not containerized_deployment
 
 - name: check if the ceph osd socket is in-use
@@ -51,6 +57,7 @@
   always_run: true
   register: osd_socket
   when:
+    - inventory_hostname in groups.get(osd_group_name, [])
     - not containerized_deployment
     - osd_socket_stat.rc == 0
 
@@ -59,6 +66,7 @@
     name: "{{ osd_socket_stat.stdout }}"
     state: absent
   when:
+    - inventory_hostname in groups.get(osd_group_name, [])
     - not containerized_deployment
     - osd_socket_stat.rc == 0
     - osd_socket.rc != 0
@@ -67,6 +75,7 @@
   set_fact:
     docker_exec_cmd: "docker exec ceph-mds-{{ ansible_hostname }}"
   when:
+    - inventory_hostname in groups.get(mds_group_name, [])
     - containerized_deployment
 
 - name: check for a ceph mds socket
@@ -76,6 +85,8 @@
   failed_when: false
   always_run: true
   register: mds_socket_stat
+  when:
+    - inventory_hostname in groups.get(mds_group_name, [])
 
 - name: check if the ceph mds socket is in-use
   shell: |
@@ -85,6 +96,7 @@
   always_run: true
   register: mds_socket
   when:
+    - inventory_hostname in groups.get(mds_group_name, [])
     - mds_socket_stat.rc == 0
 
 - name: remove ceph mds socket if exists and not used by a process
     name: "{{ mds_socket_stat.stdout }}"
     state: absent
   when:
+    - inventory_hostname in groups.get(mds_group_name, [])
     - not containerized_deployment
     - mds_socket_stat.rc == 0
     - mds_socket.rc != 0
   set_fact:
     docker_exec_cmd: "docker exec ceph-rgw-{{ ansible_hostname }}"
   when:
+    - inventory_hostname in groups.get(rgw_group_name, [])
     - containerized_deployment
 
 - name: check for a ceph rgw socket
   failed_when: false
   always_run: true
   register: rgw_socket_stat
+  when:
+    - inventory_hostname in groups.get(rgw_group_name, [])
 
 - name: check if the ceph rgw socket is in-use
   shell: |
   always_run: true
   register: rgw_socket
   when:
+    - inventory_hostname in groups.get(rgw_group_name, [])
     - rgw_socket_stat.rc == 0
 
 - name: remove ceph rgw socket if exists and not used by a process
     name: "{{ rgw_socket_stat.stdout }}"
     state: absent
   when:
+    - inventory_hostname in groups.get(rgw_group_name, [])
     - not containerized_deployment
     - rgw_socket_stat.rc == 0
     - rgw_socket.rc != 0
   set_fact:
     docker_exec_cmd: "docker exec ceph-mgr-{{ ansible_hostname }}"
   when:
+    - inventory_hostname in groups.get(mgr_group_name, [])
     - containerized_deployment
 
 - name: check for a ceph mgr socket
   failed_when: false
   always_run: true
   register: mgr_socket_stat
+  when:
+    - inventory_hostname in groups.get(mgr_group_name, [])
 
 - name: check if the ceph mgr socket is in-use
   shell: |
   always_run: true
   register: mgr_socket
   when:
+    - inventory_hostname in groups.get(mgr_group_name, [])
     - mgr_socket_stat.rc == 0
 
 - name: remove ceph mgr socket if exists and not used by a process
     name: "{{ mgr_socket_stat.stdout }}"
     state: absent
   when:
+    - inventory_hostname in groups.get(mgr_group_name, [])
     - not containerized_deployment
     - mgr_socket_stat.rc == 0
     - mgr_socket.rc != 0
   set_fact:
     docker_exec_cmd: "docker exec ceph-rbd-mirror-{{ ansible_hostname }}"
   when:
+    - inventory_hostname in groups.get(rbdmirror_group_name, [])
     - containerized_deployment
 
 - name: check for a ceph rbd mirror socket
   failed_when: false
   always_run: true
   register: rbd_mirror_socket_stat
+  when:
+    - inventory_hostname in groups.get(rbdmirror_group_name, [])
 
 - name: check if the ceph rbd mirror socket is in-use
   shell: |
   always_run: true
   register: rbd_mirror_socket
   when:
+    - inventory_hostname in groups.get(rbdmirror_group_name, [])
     - rbd_mirror_socket_stat.rc == 0
 
 - name: remove ceph rbd mirror socket if exists and not used by a process
     name: "{{ rbd_mirror_socket_stat.stdout }}"
     state: absent
   when:
+    - inventory_hostname in groups.get(rbdmirror_group_name, [])
     - not containerized_deployment
     - rbd_mirror_socket_stat.rc == 0
     - rbd_mirror_socket.rc != 0
 
+- name: set_fact docker_exec_cmd nfs ganesha
+  set_fact:
+    docker_exec_cmd: "docker exec ceph-rbd-mirror-{{ ansible_hostname }}"
+  when:
+    - inventory_hostname in groups.get(nfs_group_name, [])
+    - containerized_deployment
+
+- name: check for a ceph nfs ganesha socket
+  shell: |
+    {{ docker_exec_cmd | default('') }} bash -c 'stat --printf=%n /var/run/ganesha.pid'
+  changed_when: false
+  failed_when: false
+  always_run: true
+  register: nfs_socket_stat
+  when:
+    - inventory_hostname in groups.get(nfs_group_name, [])
+
+- name: check if the ceph nfs ganesha socket is in-use
+  shell: |
+    {{ docker_exec_cmd | default('') }} bash -c 'fuser --silent {{ nfs_socket_stat.stdout }}'
+  changed_when: false
+  failed_when: false
+  always_run: true
+  register: nfs_socket
+  when:
+    - inventory_hostname in groups.get(nfs_group_name, [])
+    - nfs_socket_stat.rc == 0
+
+- name: remove ceph nfs ganesha socket if exists and not used by a process
+  file:
+    name: "{{ nfs_socket_stat.stdout }}"
+    state: absent
+  when:
+    - inventory_hostname in groups.get(nfs_group_name, [])
+    - not containerized_deployment
+    - nfs_socket_stat.rc == 0
+    - nfs_socket.rc != 0
+
 - name: check for a ceph socket in containerized deployment (osds)
   shell: |
     docker exec ceph-osd-"{{ ansible_hostname }}"-"{{ item | replace('/', '') }}" bash -c 'stat --printf=%n /var/run/ceph/*.asok'
   when:
     - containerized_deployment
     - inventory_hostname in groups.get(osd_group_name, [])
+