From bf8f589958450ce07ec19d01fb98176ab50ab71f Mon Sep 17 00:00:00 2001 From: Tom Barron Date: Sat, 1 Sep 2018 10:32:51 -0400 Subject: [PATCH] run rados cmd in container if containerized deployment When ceph-nfs is deployed containerized and ceph-common is not installed on the host the start_nfs task fails because the rados command is missing on the host. Run rados commands from a ceph container instead so that they will succeed. Signed-off-by: Tom Barron --- roles/ceph-nfs/tasks/start_nfs.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/roles/ceph-nfs/tasks/start_nfs.yml b/roles/ceph-nfs/tasks/start_nfs.yml index ab12a93dc..53850bb0e 100644 --- a/roles/ceph-nfs/tasks/start_nfs.yml +++ b/roles/ceph-nfs/tasks/start_nfs.yml @@ -1,15 +1,23 @@ --- +- name: set_fact docker_exec_cmd_nfs + set_fact: + docker_exec_cmd_nfs: "docker exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}" + when: + - containerized_deployment + - name: check if rados index object exists - shell: "rados -p {{ cephfs_data }} --cluster {{ cluster }} ls|grep {{ ceph_nfs_rados_export_index }}" + shell: "{{ docker_exec_cmd_nfs | default('') }} rados -p {{ cephfs_data }} --cluster {{ cluster }} ls|grep {{ ceph_nfs_rados_export_index }}" changed_when: false failed_when: false register: rados_index_exists check_mode: no when: - ceph_nfs_rados_backend + delegate_to: "{{ groups[mon_group_name][0] }}" + run_once: true - name: create an empty rados index object - shell: "echo | rados -p {{ cephfs_data }} --cluster {{ cluster }} put {{ ceph_nfs_rados_export_index }} -" + shell: "{{ docker_exec_cmd_nfs | default('') }} rados -p {{ cephfs_data }} --cluster {{ cluster }} put {{ ceph_nfs_rados_export_index }} /dev/null" when: - ceph_nfs_rados_backend - rados_index_exists.rc != 0