From 0b1e9c0737ca84c2e4a34f827cf91e1a11007b16 Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Tue, 15 Oct 2019 11:32:40 -0400 Subject: [PATCH] rbd-mirror: fail if the peer is not added Due the 'failed_when: false' statement present in the peer task then the playbook continues to ran even if the peer task was failing (like incorrect remote peer format. "stderr": "rbd: invalid spec 'admin@cluster1'" This patch adds a task to list the peer present and add the peer only if it's not already added. With this we don't need the failed_when statement anymore. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1665877 Signed-off-by: Dimitri Savineau --- roles/ceph-rbd-mirror/tasks/configure_mirroring.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/roles/ceph-rbd-mirror/tasks/configure_mirroring.yml b/roles/ceph-rbd-mirror/tasks/configure_mirroring.yml index 36256ccc2..8dc4d7ec1 100644 --- a/roles/ceph-rbd-mirror/tasks/configure_mirroring.yml +++ b/roles/ceph-rbd-mirror/tasks/configure_mirroring.yml @@ -3,7 +3,13 @@ command: "{{ container_exec_cmd | default('') }} rbd --cluster {{ cluster }} --keyring /etc/ceph/{{ cluster }}.client.rbd-mirror.{{ ansible_hostname }}.keyring --name client.rbd-mirror.{{ ansible_hostname }} mirror pool enable {{ ceph_rbd_mirror_pool }} {{ ceph_rbd_mirror_mode }}" changed_when: false +- name: list mirroring peer + shell: "{{ container_exec_cmd | default('') }} rbd --cluster {{ cluster }} --keyring /etc/ceph/{{ cluster }}.client.rbd-mirror.{{ ansible_hostname }}.keyring --name client.rbd-mirror.{{ ansible_hostname }} mirror pool info {{ ceph_rbd_mirror_pool }} | grep -q {{ ceph_rbd_mirror_remote_user }}" + changed_when: false + failed_when: false + register: mirror_peer + - name: add a mirroring peer command: "{{ container_exec_cmd | default('') }} rbd --cluster {{ cluster }} --keyring /etc/ceph/{{ cluster }}.client.rbd-mirror.{{ ansible_hostname }}.keyring --name client.rbd-mirror.{{ ansible_hostname }} mirror pool peer add {{ ceph_rbd_mirror_pool }} {{ ceph_rbd_mirror_remote_user }}@{{ ceph_rbd_mirror_remote_cluster }}" changed_when: false - failed_when: false + when: mirror_peer.rc == 1 -- 2.39.5