2017-09-19 22:19:14 +08:00
|
|
|
---
|
|
|
|
- name: set_fact docker_exec_cmd_nfs
|
|
|
|
set_fact:
|
2018-11-08 17:02:37 +08:00
|
|
|
docker_exec_cmd_nfs: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}"
|
2017-09-19 22:19:14 +08:00
|
|
|
when:
|
|
|
|
- containerized_deployment
|
|
|
|
|
2018-10-26 21:27:33 +08:00
|
|
|
- name: check if "{{ ceph_nfs_rgw_user }}" exists
|
2018-11-01 19:47:17 +08:00
|
|
|
command: "{{ docker_exec_cmd_nfs | default('') }} radosgw-admin --cluster {{ cluster }} user info --uid={{ ceph_nfs_rgw_user }}"
|
2018-10-26 21:27:33 +08:00
|
|
|
run_once: true
|
|
|
|
register: rgwuser_exists
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
when:
|
|
|
|
- nfs_obj_gw
|
|
|
|
|
|
|
|
- name: create rgw nfs user "{{ ceph_nfs_rgw_user }}"
|
2018-11-01 19:47:17 +08:00
|
|
|
command: "{{ docker_exec_cmd_nfs | default('') }} radosgw-admin --cluster {{ cluster }} user create --uid={{ ceph_nfs_rgw_user }} --display-name='RGW NFS User'"
|
2017-10-04 19:16:04 +08:00
|
|
|
run_once: true
|
2017-09-19 22:19:14 +08:00
|
|
|
register: rgwuser
|
2017-09-27 05:16:43 +08:00
|
|
|
changed_when: false
|
2017-09-19 22:19:14 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
when:
|
|
|
|
- nfs_obj_gw
|
2018-10-26 21:27:33 +08:00
|
|
|
- rgwuser_exists.get('rc', 1) != 0
|
2017-09-19 22:19:14 +08:00
|
|
|
|
|
|
|
- name: set_fact ceph_nfs_rgw_access_key
|
|
|
|
set_fact:
|
2018-10-26 21:27:33 +08:00
|
|
|
ceph_nfs_rgw_access_key: "{{ (rgwuser.stdout | from_json)['keys'][0]['access_key'] if rgwuser_exists.get('rc', 1) != 0 else (rgwuser_exists.stdout | from_json)['keys'][0]['access_key'] }}"
|
2017-09-19 22:19:14 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
when:
|
|
|
|
- nfs_obj_gw
|
|
|
|
- ceph_nfs_rgw_access_key is not defined
|
|
|
|
|
|
|
|
- name: set_fact ceph_nfs_rgw_secret_key
|
|
|
|
set_fact:
|
2018-10-26 21:27:33 +08:00
|
|
|
ceph_nfs_rgw_secret_key: "{{ (rgwuser.stdout | from_json)['keys'][0]['secret_key'] if rgwuser_exists.get('rc', 1) != 0 else (rgwuser_exists.stdout | from_json)['keys'][0]['secret_key'] }}"
|
2017-09-19 22:19:14 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
when:
|
|
|
|
- nfs_obj_gw
|
|
|
|
- ceph_nfs_rgw_secret_key is not defined
|