From edf1ee20739289c7a62588b563a64d631be3f79b Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 30 Jan 2019 10:11:26 +0100 Subject: [PATCH] mon: check if an initial monitor keyring already exists When adding a new monitor, we must reuse the existing initial monitor keyring. Otherwise, the new monitor will issue its 'mkfs' with a new monitor keyring and it will result with a mismatch between them. The new monitor will be unable to join the quorum in the end. Signed-off-by: Guillaume Abrioux Co-authored-by: Rishabh Dave --- roles/ceph-mon/tasks/deploy_monitors.yml | 34 +++++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/roles/ceph-mon/tasks/deploy_monitors.yml b/roles/ceph-mon/tasks/deploy_monitors.yml index c92de2a92..4c027ea7b 100644 --- a/roles/ceph-mon/tasks/deploy_monitors.yml +++ b/roles/ceph-mon/tasks/deploy_monitors.yml @@ -1,4 +1,15 @@ --- +- name: check if monitor initial keyring already exists + command: > + {{ hostvars[groups[mon_group_name][0]]['docker_exec_cmd'] | default('') }} + ceph --cluster ceph --name mon. -k + /var/lib/ceph/mon/{{ cluster }}-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}/keyring + auth get-key mon. + register: initial_mon_key + run_once: True + delegate_to: "{{ groups.get(mon_group_name, [])[0] }}" + when: ceph_current_status.fsid is defined + - name: generate monitor initial keyring shell: > python -c "import os ; import struct ; @@ -6,17 +17,22 @@ header = struct.pack(' - cp /var/lib/ceph/tmp/{{ cluster }}.mon..keyring /etc/ceph/{{ cluster }}.mon.keyring + cp /var/lib/ceph/tmp/{{ cluster }}.mon..keyring + /etc/ceph/{{ cluster }}.mon.keyring changed_when: false - when: - - cephx - - containerized_deployment + when: containerized_deployment - name: create (and fix ownership of) monitor directory file: @@ -109,4 +123,4 @@ args: creates: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/store.db when: - - not cephx \ No newline at end of file + - not cephx