Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
- name: Include create_users_json.yml
ansible.builtin.import_playbook: create_users_json.yml
- name: Test users present and absent with slice
hosts: ipaserver
become: true
gather_facts: false
vars:
slice_size: 100
tasks:
- name: Include users.json
ansible.builtin.include_vars:
file: users.json # noqa missing-import
- name: Create dict with user names
ansible.builtin.set_fact:
user_names: "{{ user_names | default([]) + [{'name': item.name}] }}"
loop: "{{ users }}"
- name: Size of users slice.
ansible.builtin.debug:
msg: "{{ users | length }}"
- name: Cleanup test users
ipauser:
ipaadmin_password: SomeADMINpassword
users: "{{ user_names[item : item + slice_size] }}"
state: absent
loop: "{{ range(0, user_names | length, slice_size) | list }}"
- name: Users present
ipauser:
ipaadmin_password: SomeADMINpassword
users: "{{ users[item : item + slice_size] }}"
loop: "{{ range(0, users | length, slice_size) | list }}"
register: result
failed_when: not result.changed or result.failed
- name: Users absent
ipauser:
ipaadmin_password: SomeADMINpassword
users: "{{ user_names[item : item + slice_size] }}"
state: absent
loop: "{{ range(0, user_names | length, slice_size) | list }}"
register: result
failed_when: not result.changed or result.failed