Skip to content
test_users_present_absent_slice.yml 1.25 KiB
Newer Older
Thomas Woerner's avatar
Thomas Woerner committed
---
- name: Test users present and absent with slice
  hosts: ipaserver
  become: true
  gather_facts: false

  vars:
    slice_size: 100
  tasks:
  - name: Include generate_test_data.yml
    ansible.builtin.include_tasks: generate_test_data.yml
  - name: Size of user_list
    ansible.builtin.debug:
      msg: "{{ user_list | length }}"
  - name: Size of user_absent_list
Thomas Woerner's avatar
Thomas Woerner committed
    ansible.builtin.debug:
      msg: "{{ user_absent_list | length }}"
Thomas Woerner's avatar
Thomas Woerner committed

  - name: Cleanup test users
    ipauser:
      ipaadmin_password: SomeADMINpassword
      users: "{{ user_absent_list[item : item + slice_size] }}"
Thomas Woerner's avatar
Thomas Woerner committed
      state: absent
    loop: "{{ range(0, user_absent_list | length, slice_size) | list }}"
Thomas Woerner's avatar
Thomas Woerner committed

  - name: Users present
    ipauser:
      ipaadmin_password: SomeADMINpassword
      users: "{{ user_list[item : item + slice_size] }}"
    loop: "{{ range(0, user_list | length, slice_size) | list }}"
Thomas Woerner's avatar
Thomas Woerner committed
    register: result
    failed_when: not result.changed or result.failed

  - name: Users absent
    ipauser:
      ipaadmin_password: SomeADMINpassword
      users: "{{ user_absent_list[item : item + slice_size] }}"
Thomas Woerner's avatar
Thomas Woerner committed
      state: absent
    loop: "{{ range(0, user_absent_list | length, slice_size) | list }}"
Thomas Woerner's avatar
Thomas Woerner committed
    register: result
    failed_when: not result.changed or result.failed