forked from freeipa/ansible-freeipa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request freeipa#1281 from t-woerner/multi_user_test_genera…
…te_test_data tests/user/test_users_present_*: Use new generate_test_data.yml
- Loading branch information
Showing
6 changed files
with
76 additions
and
98 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Generate lists for users | ||
--- | ||
- name: Create present services.json data | ||
ansible.builtin.shell: | | ||
date=$(date --date='+2 years' "+%Y-%m-%d %H:%M:%S") | ||
echo "[" | ||
for i in $(seq -w 1 "{{ NUM }}"); do | ||
echo " {" | ||
echo " \"name\": \"testuser_${i}\"," | ||
echo " \"first\": \"First ${i}\"," | ||
echo " \"last\": \"Last ${i}\"," | ||
echo " \"password\": \"user${i}PW\"," | ||
echo " \"passwordexpiration\": \"${date}\"" | ||
if [ "$i" -lt "{{ NUM }}" ]; then | ||
echo " }," | ||
else | ||
echo " }" | ||
fi | ||
done | ||
echo "]" | ||
vars: | ||
NUM: 500 | ||
register: command | ||
|
||
- name: Set user_list | ||
ansible.builtin.set_fact: | ||
user_list: "{{ command.stdout | from_json }}" | ||
|
||
- name: Create absent user.json data | ||
ansible.builtin.shell: | | ||
echo "[" | ||
for i in $(seq -w 1 "{{ NUM }}"); do | ||
echo " {" | ||
echo " \"name\": \"testuser_${i}\"" | ||
if [ "$i" -lt "{{ NUM }}" ]; then | ||
echo " }," | ||
else | ||
echo " }" | ||
fi | ||
done | ||
echo "]" | ||
vars: | ||
NUM: 500 | ||
register: command | ||
|
||
- name: Set user_absent_list | ||
ansible.builtin.set_fact: | ||
user_absent_list: "{{ command.stdout | from_json }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,38 @@ | ||
--- | ||
- name: Include create_users_json.yml | ||
ansible.builtin.import_playbook: create_users_json.yml | ||
|
||
- name: Test users present and absent | ||
hosts: ipaserver | ||
become: true | ||
gather_facts: false | ||
|
||
tasks: | ||
- name: Include users.json | ||
ansible.builtin.include_vars: | ||
file: users.json # noqa missing-import | ||
- 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: Create dict with user names | ||
ansible.builtin.set_fact: | ||
user_names: "{{ user_names | default([]) + [{'name': item.name}] }}" | ||
loop: "{{ users }}" | ||
- name: Size of user_absent_list | ||
ansible.builtin.debug: | ||
msg: "{{ user_absent_list | length }}" | ||
|
||
- name: Cleanup test users len:{{ users | length }} | ||
- name: Cleanup test users | ||
ipauser: | ||
ipaadmin_password: SomeADMINpassword | ||
users: "{{ user_names }}" | ||
users: "{{ user_absent_list }}" | ||
state: absent | ||
|
||
- name: Users present len:{{ users | length }} | ||
- name: Users present | ||
ipauser: | ||
ipaadmin_password: SomeADMINpassword | ||
users: "{{ users }}" | ||
users: "{{ user_list }}" | ||
register: result | ||
failed_when: not result.changed or result.failed | ||
|
||
- name: Users absent len:{{ users | length }} | ||
- name: Users absent | ||
ipauser: | ||
ipaadmin_password: SomeADMINpassword | ||
users: "{{ user_names }}" | ||
users: "{{ user_absent_list }}" | ||
state: absent | ||
register: result | ||
failed_when: not result.changed or result.failed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.