From 0aa9dea281c731d4d07249fc9c98ae48a0565936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Wed, 20 Aug 2014 14:04:34 +0200 Subject: [PATCH] Restart Ceph service after a configuration change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After a change is made on the configuration file we must restart the Ceph services. I also added a check that verifies if a socker exists because during the first play there are no services running. We check if a socket exists, if not we don't try to restart the services, if it exists we can restart them. Signed-off-by: Sébastien Han --- roles/ceph-common/handlers/main.yml | 8 ++++++++ roles/ceph-common/tasks/Debian.yml | 8 +++++++- roles/ceph-common/tasks/RedHat.yml | 6 ++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/roles/ceph-common/handlers/main.yml b/roles/ceph-common/handlers/main.yml index 3d83a193f..44be529ad 100644 --- a/roles/ceph-common/handlers/main.yml +++ b/roles/ceph-common/handlers/main.yml @@ -2,3 +2,11 @@ - name: "update apt cache" action: apt update-cache=yes + +- name: "restart ceph" + shell: service ceph restart ; service ceph-osd-all restart + when: socket.rc == 0 and ansible_distribution == 'Ubuntu' + +- name: "restart ceph" + command: service ceph restart + when: socket.rc == 0 and ansible_distribution == 'Debian' or ansible_os_family == 'RedHat' diff --git a/roles/ceph-common/tasks/Debian.yml b/roles/ceph-common/tasks/Debian.yml index e7c706725..b436668a6 100644 --- a/roles/ceph-common/tasks/Debian.yml +++ b/roles/ceph-common/tasks/Debian.yml @@ -37,5 +37,11 @@ - ceph-mds #|--> they don't get update so we need to force them - libcephfs1 #| -- name: Generate ceph configuration file +- name: Check for a Ceph socket + shell: stat /var/run/ceph/*.asok > /dev/null 2>&1 + ignore_errors: true + register: socket + +- name: Generate Ceph configuration file template: src=ceph.conf.j2 dest=/etc/ceph/ceph.conf owner=root group=root mode=0644 + notify: restart ceph diff --git a/roles/ceph-common/tasks/RedHat.yml b/roles/ceph-common/tasks/RedHat.yml index c4965f6ab..08ef01268 100644 --- a/roles/ceph-common/tasks/RedHat.yml +++ b/roles/ceph-common/tasks/RedHat.yml @@ -30,5 +30,11 @@ - name: Install Ceph yum: name=ceph state=latest +- name: Check for a Ceph socket + shell: stat /var/run/ceph/*.asok > /dev/null 2>&1 + ignore_errors: true + register: socket + - name: Generate Ceph configuration file template: src=ceph.conf.j2 dest=/etc/ceph/ceph.conf owner=root group=root mode=0644 + notify: restart ceph