ceph-ansible/roles/ceph-iscsi-gw/tasks/common.yml

46 lines
1.9 KiB
YAML
Raw Normal View History

---
- name: copy admin key
copy:
src: "{{ fetch_directory }}/{{ fsid }}/etc/ceph/{{ cluster }}.client.admin.keyring"
dest: "/etc/ceph/{{ cluster }}.client.admin.keyring"
owner: "root"
group: "root"
mode: "{{ ceph_keyring_permissions }}"
when: cephx | bool
- name: deploy gateway settings, used by the ceph_iscsi_config modules
template:
src: "{{ role_path }}/templates/iscsi-gateway.cfg.j2"
dest: /etc/ceph/iscsi-gateway.cfg
- name: set_fact container_exec_cmd
set_fact:
container_exec_cmd: "{{ container_binary }} exec ceph-mon-{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }}"
delegate_to: "{{ groups[mon_group_name][0] }}"
when: containerized_deployment | bool
- name: check if a rbd pool exists
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool ls --format json"
changed_when: false
register: rbd_pool_exists
delegate_to: "{{ groups[mon_group_name][0] }}"
- name: rbd pool related tasks
when: "'rbd' not in (rbd_pool_exists.stdout | from_json)"
block:
- name: create a rbd pool if it doesn't exist
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool create rbd {{ osd_pool_default_pg_num }}"
changed_when: false
delegate_to: "{{ groups[mon_group_name][0] }}"
- name: assign application rbd to pool 'rbd'
command: "{{ container_exec_cmd }} ceph --connect-timeout 5 --cluster {{ cluster }} osd pool application enable rbd rbd"
delegate_to: "{{ groups[mon_group_name][0] }}"
run_once: True
- name: customize pool size
command: "{{ container_exec_cmd | default('') }} ceph --cluster {{ cluster }} osd pool set rbd size {{ rbd_pool_size | default(osd_pool_default_size) }}"
delegate_to: "{{ groups[mon_group_name][0] }}"
changed_when: false
when: rbd_pool_size | default(osd_pool_default_size) != ceph_osd_pool_default_size