---
- name: Test $name
  hosts: "{{ ipa_test_host | default('ipaserver') }}"
  # It is normally not needed to set "become" to "true" for a module test.
  # Only set it to true if it is needed to execute commands as root.
  become: false
  # Enable "gather_facts" only if "ansible_facts" variable needs to be used.
  gather_facts: false
  module_defaults:
    ipa$name:
      ipaadmin_password: SomeADMINpassword
      ipaapi_context: "{{ ipa_context | default(omit) }}"

  tasks:

  # CLEANUP TEST ITEMS

  - name: Ensure $name NAME is absent
    ipa$name:
      name: NAME
      state: absent

  # CREATE TEST ITEMS

  # TESTS

  - name: Ensure $name NAME is present
    ipa$name:
      name: NAME
      # Add needed parameters here
    register: result
    failed_when: not result.changed or result.failed

  - name: Ensure $name NAME is present again
    ipa$name:
      name: NAME
      # Add needed parameters here
    register: result
    failed_when: result.changed or result.failed

  # more tests here

  - name: Ensure $name NAME is absent
    ipa$name:
      name: NAME
      state: absent
    register: result
    failed_when: not result.changed or result.failed

  - name: Ensure $name NAME is absent again
    ipa$name:
      name: NAME
      state: absent
    register: result
    failed_when: result.changed or result.failed

  # CLEANUP TEST ITEMS

  - name: Ensure $name NAME is absent
    ipa$name:
      name: NAME
      state: absent
