--- # Copyright 2021 Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - name: Get ceph_cli include_tasks: ceph_cli.yaml vars: ceph_command: 'rados' # ceph cli needs manila cephx keyring if admin is not available select_keyring: "{{ 'manila' if groups['ceph_mon'] | default([]) | length == 0 else 'admin' }}" # when ceph is external and admin keyring is not available we're passing -n client.{{ selected_keyring }} external_cluster: "{{ true if groups['ceph_mon'] | default([]) | length == 0 else false }}" - name: check if rados index object exists shell: | {{ tripleo_cephadm_ceph_cli }} -p {{ cephfs_data_pool.name }} --cluster {{ tripleo_cephadm_cluster }} \ ls | grep {{ tripleo_cephadm_nfs_rados_export_index }} changed_when: false failed_when: false register: rados_index_exists check_mode: false when: tripleo_cephadm_ceph_nfs_rados_backend | bool - name: create an empty rados index object become: true command: | {{ tripleo_cephadm_ceph_cli }} -p {{ cephfs_data_pool.name }} --cluster {{ tripleo_cephadm_cluster }} \ put {{ tripleo_cephadm_nfs_rados_export_index }} /dev/null when: - tripleo_cephadm_ceph_nfs_rados_backend | bool - rados_index_exists.rc != 0 delegate_to: "{{ groups['ceph_nfs'][0] }}" - name: Extract keys block: - name: Extract key - internal ceph_key: name: "{{ item.name }}" cluster: "{{ tripleo_cephadm_cluster }}" output_format: plain state: info environment: CEPH_CONTAINER_IMAGE: "{{ tripleo_cephadm_container_ns + '/' + tripleo_cephadm_container_image + ':' + tripleo_cephadm_container_tag }}" CEPH_CONTAINER_BINARY: "{{ tripleo_cephadm_container_cli }}" CEPH_FSID: "{{ tripleo_cephadm_fsid }}" register: _rgw_keys_int become: true with_items: - { name: "client.bootstrap-rgw", path: "/var/lib/ceph/bootstrap-rgw/{{ tripleo_cephadm_cluster }}.keyring", copy_key: true } run_once: true delegate_to: "{{ groups['ceph_nfs'][0] }}" when: not external_cluster - name: slurp manila key from remote host - external become: true slurp: src: "{{ tripleo_cephadm_config_home }}/{{ tripleo_cephadm_cluster }}.client.{{ tripleo_cephadm_ceph_nfs_ceph_user }}.keyring" register: _rgw_keys_ext delegate_to: "{{ groups['ceph_nfs'][0] }}" when: external_cluster vars: external_cluster: "{{ true if groups['ceph_mon'] | default([]) | length == 0 else false }}" - name: Distribute Ceph keys to the nfs nodes include_tasks: ganesha/distribute_keys.yaml vars: nfs_node: "{{ node }}" rgw_keys_int: "{{ _rgw_keys_int }}" rgw_keys_ext: "{{ _rgw_keys_ext }}" external_cluster: "{{ true if groups['ceph_mon'] | default([]) | length == 0 else false }}" loop: "{{ groups['ceph_nfs'] }}" loop_control: loop_var: node - name: get dbus-1 file command: | {{ container_cli }} run --rm --entrypoint=cat \ {{ tripleo_cephadm_container_ns + '/' + tripleo_cephadm_container_image + ':' + tripleo_cephadm_container_tag }} \ /etc/dbus-1/system.d/org.ganesha.nfsd.conf register: _dbus_ganesha run_once: true changed_when: false delegate_to: "{{ groups['ceph_nfs'][0] }}" - name: Get Ceph version command: "{{ tripleo_cephadm_container_cli }} run --rm --entrypoint=ceph {{ ceph_container }} -v" register: ceph_version vars: ceph_container: "{{ tripleo_cephadm_container_ns }}/{{ tripleo_cephadm_container_image }}:{{ tripleo_cephadm_container_tag }}" - name: Render Ganesha templates and files include_tasks: ganesha/start_nfs.yaml vars: nfs_node: "{{ node }}" dbus_ganesha_file: "{{ _dbus_ganesha }}" tripleo_cephadm_ceph_version: "{{ ceph_version.stdout.split(' ')[2] }}" loop: "{{ groups['ceph_nfs'] }}" loop_control: loop_var: node