2017-08-05 02:18:11 +08:00
|
|
|
|
---
|
2017-10-04 14:58:03 +08:00
|
|
|
|
- name: check if a rbd pool exists
|
|
|
|
|
command: ceph --cluster {{ cluster }} osd pool ls --format json
|
|
|
|
|
register: rbd_pool_exists
|
|
|
|
|
|
|
|
|
|
- name: get default value for osd_pool_default_pg_num
|
|
|
|
|
command: ceph --cluster {{ cluster }} daemon mon.{{ hostvars[groups[mon_group_name][0]]['ansible_hostname'] }} config get osd_pool_default_pg_num
|
|
|
|
|
register: osd_pool_default_pg_num
|
|
|
|
|
when: "'rbd' not in (rbd_pool_exists.stdout | from_json)"
|
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
|
|
|
|
|
|
- name: create a rbd pool if it doesn't exist
|
|
|
|
|
command: ceph --cluster {{ cluster }} osd pool create rbd {{ (osd_pool_default_pg_num.stdout | from_json).osd_pool_default_pg_num }}
|
|
|
|
|
when: "'rbd' not in (rbd_pool_exists.stdout | from_json)"
|
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
|
|
2017-08-05 02:18:11 +08:00
|
|
|
|
- name: igw_gateway (tgt) | configure iscsi target (gateway)
|
|
|
|
|
igw_gateway:
|
|
|
|
|
mode: "target"
|
|
|
|
|
gateway_iqn: "{{ gateway_iqn }}"
|
|
|
|
|
gateway_ip_list: "{{ gateway_ip_list }}"
|
|
|
|
|
register: target
|
|
|
|
|
|
|
|
|
|
- name: igw_lun | configure luns (create/map rbds and add to lio)
|
|
|
|
|
igw_lun:
|
|
|
|
|
pool: "{{ item.pool }}"
|
|
|
|
|
image: "{{ item.image }}"
|
|
|
|
|
size: "{{ item.size }}"
|
|
|
|
|
host: "{{ item.host }}"
|
|
|
|
|
state: "{{ item.state }}"
|
2017-09-21 16:07:37 +08:00
|
|
|
|
with_items: "{{ rbd_devices }}"
|
2017-08-05 02:18:11 +08:00
|
|
|
|
register: images
|
|
|
|
|
|
|
|
|
|
- name: igw_gateway (map) | map luns to the iscsi target
|
|
|
|
|
igw_gateway:
|
|
|
|
|
mode: "map"
|
|
|
|
|
gateway_iqn: "{{ gateway_iqn }}"
|
|
|
|
|
gateway_ip_list: "{{ gateway_ip_list }}"
|
|
|
|
|
register: luns
|
|
|
|
|
|
|
|
|
|
- name: igw_client | configure client connectivity
|
|
|
|
|
igw_client:
|
|
|
|
|
client_iqn: "{{ item.client }}"
|
|
|
|
|
image_list: "{{ item.image_list }}"
|
|
|
|
|
chap: "{{ item.chap }}"
|
|
|
|
|
state: "{{ item.status }}"
|
2017-09-21 16:07:37 +08:00
|
|
|
|
with_items: "{{ client_connections }}"
|
2017-08-05 02:18:11 +08:00
|
|
|
|
register: clients
|