---
- name: set_fact use_new_ceph_iscsi package or old ceph-iscsi-config/cli
  set_fact:
    use_new_ceph_iscsi: "{{ (gateway_ip_list | default('0.0.0.0') == '0.0.0.0' and gateway_iqn | default('') | length == 0 and client_connections | default({}) | length == 0 and rbd_devices | default({}) | length == 0) | bool | ternary(true, false) }}"

- name: make sure gateway_ip_list is configured
  fail:
    msg: "you must set a list of IPs (comma separated) for gateway_ip_list"
  when:
    - "gateway_ip_list | default('0.0.0.0') == '0.0.0.0'"
    - not containerized_deployment | bool
    - not use_new_ceph_iscsi | bool

- name: fail if unsupported chap configuration
  fail:
    msg: "Mixing clients with CHAP enabled and disabled is not supported."
  with_items: "{{ client_connections | default({})  }}"
  when:
    - item.status is defined
    - item.status == "present"
    - item.chap
    - " '' in client_connections | selectattr('status', 'match', 'present') | map(attribute='chap') | list"

---
- name: set_fact use_new_ceph_iscsi package or old ceph-iscsi-config/cli
  set_fact:
    use_new_ceph_iscsi: "{{ (gateway_ip_list | default('0.0.0.0') == '0.0.0.0' and gateway_iqn | default('') | length == 0 and client_connections | default({}) | length == 0 and rbd_devices | default({}) | length == 0) | bool | ternary(true, false) }}"

- name: make sure gateway_ip_list is configured
  fail:
    msg: "you must set a list of IPs (comma separated) for gateway_ip_list"
  when:
    - "gateway_ip_list | default('0.0.0.0') == '0.0.0.0'"
    - not containerized_deployment | bool
    - not use_new_ceph_iscsi | bool

- name: make sure gateway_iqn is configured
  fail:
    msg: "you must set a iqn for the iSCSI target"
  when:
    - "gateway_iqn | default('') | length == 0"
    - not containerized_deployment | bool
    - not use_new_ceph_iscsi | bool

- name: fail if unsupported chap configuration
  fail:
    msg: "Mixing clients with CHAP enabled and disabled is not supported."
  with_items: "{{ client_connections | default({})  }}"
  when:
    - item.status is defined
    - item.status == "present"
    - item.chap
    - " '' in client_connections | selectattr('status', 'match', 'present') | map(attribute='chap') | list"

Add check for missing iqn
igw: Add check for missing iqn

If the user is still using the older packages and does not setup
the target iqn you will just get a vague error message later on.
This adds a check during the validate task, so it is clear to the
user.

Signed-off-by: Mike Christie <39daeb1549a929782e38aa87c4e3da7f3844b09a@redhat.com>
