defaults: only run socket checks on their specific roles

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>
pull/1939/head
Sébastien Han 2017-09-27 00:55:31 +02:00
parent 341c9e077b
commit 048b55be4a
2 changed files with 106 additions and 25 deletions

View File

@ -20,8 +20,8 @@
listen: "restart ceph mons" listen: "restart ceph mons"
when: when:
# We do not want to run these checks on initial deployment (`socket.rc == 0`) # 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_group_name in group_names
- mon_socket_stat.rc == 0
# This does not just restart OSDs but everything else too. Unfortunately # 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 # at this time the ansible role does not have an OSD id list to use
@ -35,8 +35,8 @@
mode: 0750 mode: 0750
listen: "restart ceph osds" listen: "restart ceph osds"
when: when:
- inventory_hostname in play_hosts
- osd_group_name in group_names - osd_group_name in group_names
- inventory_hostname in play_hosts
- name: restart containerized ceph osds daemon(s) - name: restart containerized ceph osds daemon(s)
command: /tmp/restart_osd_daemon.sh command: /tmp/restart_osd_daemon.sh
@ -45,17 +45,18 @@
when: when:
# We do not want to run these checks on initial deployment (`socket_osd_container_stat.results[n].rc == 0`) # 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 # 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 - containerized_deployment
- ((crush_location is defined and crush_location) or item.get('rc') == 0) - ((crush_location is defined and crush_location) or item.get('rc') == 0)
- handler_health_osd_check - handler_health_osd_check
# See https://github.com/ceph/ceph-ansible/issues/1457 for the condition below # See https://github.com/ceph/ceph-ansible/issues/1457 for the condition below
- inventory_hostname in play_hosts - inventory_hostname in play_hosts
- osd_group_name in group_names
- name: restart non-containerized ceph osds daemon(s) - name: restart non-containerized ceph osds daemon(s)
command: /tmp/restart_osd_daemon.sh command: /tmp/restart_osd_daemon.sh
listen: "restart ceph osds" listen: "restart ceph osds"
when: when:
- osd_group_name in group_names
- not containerized_deployment - not containerized_deployment
# We do not want to run these checks on initial deployment (`socket_osd_container.results[n].rc == 0`) # 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 # except when a crush location is specified. ceph-disk will start the osds before the osd crush location is specified
@ -64,8 +65,8 @@
- handler_health_osd_check - handler_health_osd_check
# See https://github.com/ceph/ceph-ansible/issues/1457 for the condition below # See https://github.com/ceph/ceph-ansible/issues/1457 for the condition below
- inventory_hostname in play_hosts - inventory_hostname in play_hosts
- osd_group_name in group_names
- block:
- name: copy mds restart script - name: copy mds restart script
template: template:
src: restart_mds_daemon.sh.j2 src: restart_mds_daemon.sh.j2
@ -75,16 +76,16 @@
mode: 0750 mode: 0750
listen: "restart ceph mdss" listen: "restart ceph mdss"
when: when:
- inventory_hostname in play_hosts
- mds_group_name in group_names - mds_group_name in group_names
- inventory_hostname in play_hosts
- name: restart ceph mds daemon(s) - name: restart ceph mds daemon(s)
command: /tmp/restart_mds_daemon.sh command: /tmp/restart_mds_daemon.sh
listen: "restart ceph mdss" listen: "restart ceph mdss"
when: when:
# We do not want to run these checks on initial deployment (`socket.rc == 0`) # 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_group_name in group_names
- mds_socket_stat.rc == 0
- name: copy rgw restart script - name: copy rgw restart script
template: template:
@ -95,20 +96,33 @@
mode: 0750 mode: 0750
listen: "restart ceph rgws" listen: "restart ceph rgws"
when: when:
- inventory_hostname in play_hosts
- rgw_group_name in group_names - rgw_group_name in group_names
- inventory_hostname in play_hosts
- name: restart ceph rgw daemon(s) - name: restart ceph rgw daemon(s)
command: /tmp/restart_rgw_daemon.sh command: /tmp/restart_rgw_daemon.sh
listen: "restart ceph rgws" listen: "restart ceph rgws"
when: when:
# We do not want to run these checks on initial deployment (`socket.rc == 0`) # 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_group_name in group_names
- rgw_socket_stat.rc == 0
- name: restart ceph nfss - name: copy nfs restart script
service: template:
name: nfs-ganesha src: restart_nfs_daemon.sh.j2
state: restarted dest: /tmp/restart_nfs_daemon.sh
owner: root
group: root
mode: 0750
listen: "restart ceph nfss"
when: when:
- nfs_group_name in group_names - 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

View File

@ -4,6 +4,7 @@
set_fact: set_fact:
docker_exec_cmd: "docker exec ceph-mon-{{ ansible_hostname }}" docker_exec_cmd: "docker exec ceph-mon-{{ ansible_hostname }}"
when: when:
- inventory_hostname in groups.get(mon_group_name, [])
- containerized_deployment - containerized_deployment
- name: check for a ceph mon socket - name: check for a ceph mon socket
@ -13,6 +14,8 @@
failed_when: false failed_when: false
always_run: true always_run: true
register: mon_socket_stat register: mon_socket_stat
when:
- inventory_hostname in groups.get(mon_group_name, [])
- name: check if the ceph mon socket is in-use - name: check if the ceph mon socket is in-use
shell: | shell: |
@ -22,6 +25,7 @@
always_run: true always_run: true
register: mon_socket register: mon_socket
when: when:
- inventory_hostname in groups.get(mon_group_name, [])
- mon_socket_stat.rc == 0 - mon_socket_stat.rc == 0
- name: remove ceph mon socket if exists and not used by a process - name: remove ceph mon socket if exists and not used by a process
@ -29,6 +33,7 @@
name: "{{ mon_socket_stat.stdout }}" name: "{{ mon_socket_stat.stdout }}"
state: absent state: absent
when: when:
- inventory_hostname in groups.get(mon_group_name, [])
- not containerized_deployment - not containerized_deployment
- mon_socket_stat.rc == 0 - mon_socket_stat.rc == 0
- mon_socket.rc != 0 - mon_socket.rc != 0
@ -41,6 +46,7 @@
always_run: true always_run: true
register: osd_socket_stat register: osd_socket_stat
when: when:
- inventory_hostname in groups.get(osd_group_name, [])
- not containerized_deployment - not containerized_deployment
- name: check if the ceph osd socket is in-use - name: check if the ceph osd socket is in-use
@ -51,6 +57,7 @@
always_run: true always_run: true
register: osd_socket register: osd_socket
when: when:
- inventory_hostname in groups.get(osd_group_name, [])
- not containerized_deployment - not containerized_deployment
- osd_socket_stat.rc == 0 - osd_socket_stat.rc == 0
@ -59,6 +66,7 @@
name: "{{ osd_socket_stat.stdout }}" name: "{{ osd_socket_stat.stdout }}"
state: absent state: absent
when: when:
- inventory_hostname in groups.get(osd_group_name, [])
- not containerized_deployment - not containerized_deployment
- osd_socket_stat.rc == 0 - osd_socket_stat.rc == 0
- osd_socket.rc != 0 - osd_socket.rc != 0
@ -67,6 +75,7 @@
set_fact: set_fact:
docker_exec_cmd: "docker exec ceph-mds-{{ ansible_hostname }}" docker_exec_cmd: "docker exec ceph-mds-{{ ansible_hostname }}"
when: when:
- inventory_hostname in groups.get(mds_group_name, [])
- containerized_deployment - containerized_deployment
- name: check for a ceph mds socket - name: check for a ceph mds socket
@ -76,6 +85,8 @@
failed_when: false failed_when: false
always_run: true always_run: true
register: mds_socket_stat register: mds_socket_stat
when:
- inventory_hostname in groups.get(mds_group_name, [])
- name: check if the ceph mds socket is in-use - name: check if the ceph mds socket is in-use
shell: | shell: |
@ -85,6 +96,7 @@
always_run: true always_run: true
register: mds_socket register: mds_socket
when: when:
- inventory_hostname in groups.get(mds_group_name, [])
- mds_socket_stat.rc == 0 - mds_socket_stat.rc == 0
- name: remove ceph mds socket if exists and not used by a process - name: remove ceph mds socket if exists and not used by a process
@ -92,6 +104,7 @@
name: "{{ mds_socket_stat.stdout }}" name: "{{ mds_socket_stat.stdout }}"
state: absent state: absent
when: when:
- inventory_hostname in groups.get(mds_group_name, [])
- not containerized_deployment - not containerized_deployment
- mds_socket_stat.rc == 0 - mds_socket_stat.rc == 0
- mds_socket.rc != 0 - mds_socket.rc != 0
@ -100,6 +113,7 @@
set_fact: set_fact:
docker_exec_cmd: "docker exec ceph-rgw-{{ ansible_hostname }}" docker_exec_cmd: "docker exec ceph-rgw-{{ ansible_hostname }}"
when: when:
- inventory_hostname in groups.get(rgw_group_name, [])
- containerized_deployment - containerized_deployment
- name: check for a ceph rgw socket - name: check for a ceph rgw socket
@ -109,6 +123,8 @@
failed_when: false failed_when: false
always_run: true always_run: true
register: rgw_socket_stat register: rgw_socket_stat
when:
- inventory_hostname in groups.get(rgw_group_name, [])
- name: check if the ceph rgw socket is in-use - name: check if the ceph rgw socket is in-use
shell: | shell: |
@ -118,6 +134,7 @@
always_run: true always_run: true
register: rgw_socket register: rgw_socket
when: when:
- inventory_hostname in groups.get(rgw_group_name, [])
- rgw_socket_stat.rc == 0 - rgw_socket_stat.rc == 0
- name: remove ceph rgw socket if exists and not used by a process - name: remove ceph rgw socket if exists and not used by a process
@ -125,6 +142,7 @@
name: "{{ rgw_socket_stat.stdout }}" name: "{{ rgw_socket_stat.stdout }}"
state: absent state: absent
when: when:
- inventory_hostname in groups.get(rgw_group_name, [])
- not containerized_deployment - not containerized_deployment
- rgw_socket_stat.rc == 0 - rgw_socket_stat.rc == 0
- rgw_socket.rc != 0 - rgw_socket.rc != 0
@ -133,6 +151,7 @@
set_fact: set_fact:
docker_exec_cmd: "docker exec ceph-mgr-{{ ansible_hostname }}" docker_exec_cmd: "docker exec ceph-mgr-{{ ansible_hostname }}"
when: when:
- inventory_hostname in groups.get(mgr_group_name, [])
- containerized_deployment - containerized_deployment
- name: check for a ceph mgr socket - name: check for a ceph mgr socket
@ -142,6 +161,8 @@
failed_when: false failed_when: false
always_run: true always_run: true
register: mgr_socket_stat register: mgr_socket_stat
when:
- inventory_hostname in groups.get(mgr_group_name, [])
- name: check if the ceph mgr socket is in-use - name: check if the ceph mgr socket is in-use
shell: | shell: |
@ -151,6 +172,7 @@
always_run: true always_run: true
register: mgr_socket register: mgr_socket
when: when:
- inventory_hostname in groups.get(mgr_group_name, [])
- mgr_socket_stat.rc == 0 - mgr_socket_stat.rc == 0
- name: remove ceph mgr socket if exists and not used by a process - name: remove ceph mgr socket if exists and not used by a process
@ -158,6 +180,7 @@
name: "{{ mgr_socket_stat.stdout }}" name: "{{ mgr_socket_stat.stdout }}"
state: absent state: absent
when: when:
- inventory_hostname in groups.get(mgr_group_name, [])
- not containerized_deployment - not containerized_deployment
- mgr_socket_stat.rc == 0 - mgr_socket_stat.rc == 0
- mgr_socket.rc != 0 - mgr_socket.rc != 0
@ -166,6 +189,7 @@
set_fact: set_fact:
docker_exec_cmd: "docker exec ceph-rbd-mirror-{{ ansible_hostname }}" docker_exec_cmd: "docker exec ceph-rbd-mirror-{{ ansible_hostname }}"
when: when:
- inventory_hostname in groups.get(rbdmirror_group_name, [])
- containerized_deployment - containerized_deployment
- name: check for a ceph rbd mirror socket - name: check for a ceph rbd mirror socket
@ -175,6 +199,8 @@
failed_when: false failed_when: false
always_run: true always_run: true
register: rbd_mirror_socket_stat 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 - name: check if the ceph rbd mirror socket is in-use
shell: | shell: |
@ -184,6 +210,7 @@
always_run: true always_run: true
register: rbd_mirror_socket register: rbd_mirror_socket
when: when:
- inventory_hostname in groups.get(rbdmirror_group_name, [])
- rbd_mirror_socket_stat.rc == 0 - rbd_mirror_socket_stat.rc == 0
- name: remove ceph rbd mirror socket if exists and not used by a process - name: remove ceph rbd mirror socket if exists and not used by a process
@ -191,10 +218,49 @@
name: "{{ rbd_mirror_socket_stat.stdout }}" name: "{{ rbd_mirror_socket_stat.stdout }}"
state: absent state: absent
when: when:
- inventory_hostname in groups.get(rbdmirror_group_name, [])
- not containerized_deployment - not containerized_deployment
- rbd_mirror_socket_stat.rc == 0 - rbd_mirror_socket_stat.rc == 0
- rbd_mirror_socket.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) - name: check for a ceph socket in containerized deployment (osds)
shell: | shell: |
docker exec ceph-osd-"{{ ansible_hostname }}"-"{{ item | replace('/', '') }}" bash -c 'stat --printf=%n /var/run/ceph/*.asok' docker exec ceph-osd-"{{ ansible_hostname }}"-"{{ item | replace('/', '') }}" bash -c 'stat --printf=%n /var/run/ceph/*.asok'
@ -206,3 +272,4 @@
when: when:
- containerized_deployment - containerized_deployment
- inventory_hostname in groups.get(osd_group_name, []) - inventory_hostname in groups.get(osd_group_name, [])