---
- name: Ensure introspection rules exist
  vars:
    ansible_python_interpreter: "{{ ironic_inspector_venv }}/bin/python"
  os_ironic_inspector_rule:
    auth_type: "{{ ironic_inspector_auth_type }}"
    auth: "{{ ironic_inspector_auth }}"
    cacert: "{{ ironic_inspector_cacert | default(omit, true) }}"
    cloud: "{{ ironic_inspector_cloud | default(omit, true) }}"
    interface: "{{ ironic_inspector_interface | default(omit, true) }}"
    conditions: "{{ ironic_inspector_rules[item].conditions }}"
    actions: "{{ ironic_inspector_rules[item].actions }}"
    description: "{{ ironic_inspector_rules[item].description | default(omit) }}"
    uuid: "{{ ironic_inspector_rules[item].uuid | default(ironic_inspector_rules[item].description | to_uuid) | default(omit) }}"
    sensitive: "{{ ironic_inspector_rules[item].sensitive | default(omit) }}"
    state: present
  loop_control:
    label: "{{ ironic_inspector_rules[item].description }}"
  with_items: "{{ range(0, ironic_inspector_rules | length) | list }}"
