mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-08 14:23:11 +00:00
[RFE] Allow multiple groups creation.
Adding an option `groups` to create multiple groups in one operation.
Adding tests (present/absent/external/nonposix) with server and
client context.
Simple example of `groups` option:
```
tasks:
- name: Ensure 2 groups are present
ipagroup:
ipaadmin_password: SomeADMINpassword
groups:
- name: group1
- name: group2
```
Signed-off-by: Denis Karpelevich <dkarpele@redhat.com>
This commit is contained in:
47
tests/group/test_groups_present_slice.yml
Normal file
47
tests/group/test_groups_present_slice.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
---
|
||||
- name: Include create_groups_json.yml
|
||||
ansible.builtin.import_playbook: create_groups_json.yml
|
||||
|
||||
- name: Test groups present slice
|
||||
hosts: ipaserver
|
||||
gather_facts: false
|
||||
|
||||
vars:
|
||||
slice_size: 500
|
||||
tasks:
|
||||
- name: Include groups.json
|
||||
ansible.builtin.include_vars:
|
||||
file: groups.json # noqa 505
|
||||
|
||||
- name: Size of groups slice.
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ group_list | length }}"
|
||||
|
||||
- name: Groups present
|
||||
ipagroup:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
groups: "{{ group_list[item : item + slice_size] }}"
|
||||
loop: "{{ range(0, group_list | length, slice_size) | list }}"
|
||||
|
||||
- name: Initialize groups_names
|
||||
ansible.builtin.set_fact:
|
||||
groups_names: []
|
||||
|
||||
- name: Create dict with group names
|
||||
ansible.builtin.set_fact:
|
||||
groups_names: "{{ groups_names | default([]) + [{'name': item.name}] }}"
|
||||
loop: "{{ group_list }}"
|
||||
|
||||
- name: Remove groups
|
||||
ipagroup:
|
||||
ipaadmin_password: SomeADMINpassword
|
||||
groups: "{{ groups_names }}"
|
||||
state: absent
|
||||
|
||||
- name: Remove groups.json
|
||||
hosts: localhost
|
||||
tasks:
|
||||
- name: Remove groups.json
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: groups.json
|
||||
Reference in New Issue
Block a user