ceph-ansible/roles/ceph-nfs/tasks/start_nfs.yml

99 lines
2.4 KiB
YAML

---
- name: set_fact docker_exec_cmd_nfs
set_fact:
docker_exec_cmd_nfs: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}"
when:
- containerized_deployment
- name: check if rados index object exists
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
command: "{{ 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
delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: true
- name: create /etc/ganesha
file:
path: /etc/ganesha
state: directory
owner: root
group: root
mode: "0755"
- name: generate ganesha configuration file
action: config_template
args:
src: "ganesha.conf.j2"
dest: /etc/ganesha/ganesha.conf
owner: "root"
group: "root"
mode: "0644"
config_type: ini
notify:
- restart ceph nfss
- name: create exports directory
file:
path: /etc/ganesha/export.d
state: directory
owner: "root"
group: "root"
mode: "0755"
when:
- ceph_nfs_dynamic_exports
- name: create exports dir index file
copy:
content: ""
force: no
dest: /etc/ganesha/export.d/INDEX.conf
owner: "root"
group: "root"
mode: "0644"
when:
- ceph_nfs_dynamic_exports
- name: generate systemd unit file
become: true
template:
src: "{{ role_path }}/templates/ceph-nfs.service.j2"
dest: /etc/systemd/system/ceph-nfs@.service
owner: "root"
group: "root"
mode: "0644"
when:
- containerized_deployment
notify:
- restart ceph nfss
- name: systemd start nfs container
systemd:
name: ceph-nfs@{{ ceph_nfs_service_suffix | default(ansible_hostname) }}
state: started
enabled: yes
daemon_reload: yes
when:
- containerized_deployment
- ceph_nfs_enable_service
- name: start nfs gateway service
systemd:
name: nfs-ganesha
state: started
enabled: yes
when:
- not containerized_deployment
- ceph_nfs_enable_service