2017-09-19 22:19:14 +08:00
|
|
|
---
|
2019-05-20 21:58:10 +08:00
|
|
|
- block:
|
|
|
|
- name: set_fact container_exec_cmd_nfs
|
|
|
|
set_fact:
|
|
|
|
container_exec_cmd_nfs: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}"
|
|
|
|
when: containerized_deployment
|
2018-09-01 22:32:51 +08:00
|
|
|
|
2019-05-20 21:58:10 +08:00
|
|
|
- name: check if rados index object exists
|
|
|
|
shell: "{{ container_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
|
2017-11-15 19:59:36 +08:00
|
|
|
|
2019-05-20 21:58:10 +08:00
|
|
|
- name: create an empty rados index object
|
|
|
|
command: "{{ container_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
|
|
|
|
when: groups.get(mon_group_name, []) | length > 0
|
2017-11-15 19:59:36 +08:00
|
|
|
|
2017-09-27 05:16:43 +08:00
|
|
|
- name: create /etc/ganesha
|
|
|
|
file:
|
|
|
|
path: /etc/ganesha
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0755"
|
|
|
|
|
2017-09-19 22:19:14 +08:00
|
|
|
- name: generate ganesha configuration file
|
|
|
|
action: config_template
|
|
|
|
args:
|
2018-02-20 00:57:18 +08:00
|
|
|
src: "ganesha.conf.j2"
|
2017-09-19 22:19:14 +08:00
|
|
|
dest: /etc/ganesha/ganesha.conf
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
mode: "0644"
|
|
|
|
config_type: ini
|
2019-04-01 23:46:15 +08:00
|
|
|
notify: restart ceph nfss
|
2017-09-19 22:19:14 +08:00
|
|
|
|
2017-10-04 19:25:53 +08:00
|
|
|
- name: create exports directory
|
|
|
|
file:
|
|
|
|
path: /etc/ganesha/export.d
|
|
|
|
state: directory
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
mode: "0755"
|
2019-04-01 23:46:15 +08:00
|
|
|
when: ceph_nfs_dynamic_exports
|
2017-10-04 19:25:53 +08:00
|
|
|
|
|
|
|
- name: create exports dir index file
|
|
|
|
copy:
|
|
|
|
content: ""
|
|
|
|
force: no
|
|
|
|
dest: /etc/ganesha/export.d/INDEX.conf
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
mode: "0644"
|
2019-04-01 23:46:15 +08:00
|
|
|
when: ceph_nfs_dynamic_exports
|
2017-10-04 19:25:53 +08:00
|
|
|
|
2017-09-27 05:16:43 +08:00
|
|
|
- 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"
|
2019-04-01 23:46:15 +08:00
|
|
|
when: containerized_deployment
|
|
|
|
notify: restart ceph nfss
|
2017-09-27 05:16:43 +08:00
|
|
|
|
|
|
|
- name: systemd start nfs container
|
|
|
|
systemd:
|
2017-10-04 19:09:43 +08:00
|
|
|
name: ceph-nfs@{{ ceph_nfs_service_suffix | default(ansible_hostname) }}
|
2017-09-27 05:16:43 +08:00
|
|
|
state: started
|
|
|
|
enabled: yes
|
2019-03-20 18:35:36 +08:00
|
|
|
masked: no
|
2017-09-27 05:16:43 +08:00
|
|
|
daemon_reload: yes
|
|
|
|
when:
|
|
|
|
- containerized_deployment
|
2017-10-16 20:15:43 +08:00
|
|
|
- ceph_nfs_enable_service
|
2017-09-27 05:16:43 +08:00
|
|
|
|
2017-09-19 22:19:14 +08:00
|
|
|
- name: start nfs gateway service
|
2017-10-16 20:15:43 +08:00
|
|
|
systemd:
|
2017-09-19 22:19:14 +08:00
|
|
|
name: nfs-ganesha
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
2019-03-20 18:35:36 +08:00
|
|
|
masked: no
|
2017-09-19 22:19:14 +08:00
|
|
|
when:
|
2017-09-27 05:16:43 +08:00
|
|
|
- not containerized_deployment
|
2017-10-16 20:15:43 +08:00
|
|
|
- ceph_nfs_enable_service
|