2018-03-23 11:24:56 +08:00
|
|
|
---
|
2019-09-23 19:30:05 +08:00
|
|
|
- name: get keys from monitors
|
|
|
|
command: "{{ container_exec_cmd }} ceph --cluster {{ cluster }} auth get {{ item.name }}"
|
|
|
|
register: _iscsi_keys
|
|
|
|
with_items:
|
|
|
|
- { name: "client.admin", path: "/etc/ceph/{{ cluster }}.client.admin.keyring", copy_key: "{{ copy_admin_key }}" }
|
|
|
|
delegate_to: "{{ groups.get(mon_group_name)[0] }}"
|
2019-10-02 15:57:50 +08:00
|
|
|
run_once: true
|
2019-09-23 19:30:05 +08:00
|
|
|
when:
|
|
|
|
- cephx | bool
|
|
|
|
- item.copy_key | bool
|
|
|
|
|
|
|
|
- name: copy ceph key(s) if needed
|
2018-03-23 11:24:56 +08:00
|
|
|
copy:
|
2019-09-23 19:30:05 +08:00
|
|
|
dest: "{{ item.item.path }}"
|
|
|
|
content: "{{ item.stdout + '\n' }}"
|
|
|
|
owner: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
2018-06-25 21:12:56 +08:00
|
|
|
mode: "{{ ceph_keyring_permissions }}"
|
2019-09-23 19:30:05 +08:00
|
|
|
with_items: "{{ _iscsi_keys.results }}"
|
|
|
|
when:
|
|
|
|
- cephx | bool
|
|
|
|
- item.item.copy_key | bool
|
2018-03-23 11:24:56 +08:00
|
|
|
|
2019-10-22 03:45:19 +08:00
|
|
|
- name: add mgr ip address to trusted list with dashboard
|
|
|
|
set_fact:
|
|
|
|
trusted_ip_list: '{{ trusted_ip_list }},{{ hostvars[item]["ansible_all_ipv4_addresses"] | ips_in_ranges(public_network.split(",")) | first }}'
|
|
|
|
with_items: '{{ groups[mgr_group_name] | default(groups[mon_group_name]) }}'
|
|
|
|
when: dashboard_enabled | bool
|
|
|
|
|
2018-03-23 11:24:56 +08:00
|
|
|
- name: deploy gateway settings, used by the ceph_iscsi_config modules
|
2019-07-09 02:36:07 +08:00
|
|
|
config_template:
|
2018-03-23 11:24:56 +08:00
|
|
|
src: "{{ role_path }}/templates/iscsi-gateway.cfg.j2"
|
|
|
|
dest: /etc/ceph/iscsi-gateway.cfg
|
2019-07-09 02:36:07 +08:00
|
|
|
config_type: ini
|
|
|
|
config_overrides: '{{ iscsi_conf_overrides }}'
|
2019-10-10 04:50:09 +08:00
|
|
|
notify: restart ceph rbd-target-api-gw
|
2018-03-23 11:24:56 +08:00
|
|
|
|
2019-05-14 20:51:32 +08:00
|
|
|
- name: set_fact container_exec_cmd
|
2018-03-23 11:24:56 +08:00
|
|
|
set_fact:
|
2019-05-14 20:51:32 +08:00
|
|
|
container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}"
|
2018-03-23 11:24:56 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2019-05-22 16:02:42 +08:00
|
|
|
when: containerized_deployment | bool
|
2018-03-23 11:24:56 +08:00
|
|
|
|
|
|
|
- name: check if a rbd pool exists
|
2019-05-14 20:51:32 +08:00
|
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool ls --format json"
|
2018-03-23 11:24:56 +08:00
|
|
|
changed_when: false
|
2019-07-09 02:36:07 +08:00
|
|
|
register: iscsi_pool_exists
|
2018-03-23 11:24:56 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
|
2019-07-09 02:36:07 +08:00
|
|
|
- name: iscsi pool related tasks
|
|
|
|
when: "iscsi_pool_name not in (iscsi_pool_exists.stdout | from_json)"
|
2018-10-01 23:11:13 +08:00
|
|
|
block:
|
2019-07-09 02:36:07 +08:00
|
|
|
- name: create a iscsi pool if it doesn't exist
|
|
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool create {{ iscsi_pool_name }} {{ osd_pool_default_pg_num }}"
|
2018-10-01 23:11:13 +08:00
|
|
|
changed_when: false
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
|
2019-07-09 02:36:07 +08:00
|
|
|
- name: assign application rbd to iscsi pool
|
|
|
|
command: "{{ container_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool application enable {{ iscsi_pool_name }} rbd"
|
2019-06-12 04:03:59 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
run_once: True
|
|
|
|
|
2018-10-01 23:11:13 +08:00
|
|
|
- name: customize pool size
|
2019-07-09 02:36:07 +08:00
|
|
|
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set {{ iscsi_pool_name }} size {{ iscsi_pool_size | default(osd_pool_default_size) }}"
|
2018-10-01 23:11:13 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
changed_when: false
|
2019-07-09 02:36:07 +08:00
|
|
|
when: iscsi_pool_size | default(osd_pool_default_size) != ceph_osd_pool_default_size
|