ipaservice: Updated and new tests for certificates and multi service handling

The tests test_services_absent.yml, test_services_present.yml and
test_services_present_slice.yml have been updated to use in memory data
for testing instead of loading json files. This made is simpler to use
variables from the playbook for example for fqdn host names.

New tests for certificates with and without trailing new lines have been
added for single service and multiple service handling.
This commit is contained in:
Thomas Woerner
2023-06-06 13:00:26 +02:00
parent 872c9e4cb2
commit 09250cb2c5
10 changed files with 735 additions and 156 deletions

View File

@@ -0,0 +1,98 @@
# Generate lists for hosts and services
---
- name: Get Domain from server name
ansible.builtin.set_fact:
ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join('.') }}"
when: ipaserver_domain is not defined
- name: Create present services.json data
ansible.builtin.shell: |
echo "["
for i in $(seq 1 "{{ NUM }}"); do
echo " {"
echo " \"name\": \"HTTP/www$i.{{ DOMAIN }}\","
echo " \"principal\": \"host/test$i.{{ DOMAIN }}\","
echo " \"force\": \"true\""
if [ "$i" -lt "{{ NUM }}" ]; then
echo " },"
else
echo " }"
fi
done
echo "]"
vars:
NUM: 500
DOMAIN: "{{ ipaserver_domain }}"
register: command
- name: Set service_list
ansible.builtin.set_fact:
service_list: "{{ command.stdout | from_json }}"
- name: Create absent services.json data
ansible.builtin.shell: |
echo "["
for i in $(seq 1 "{{ NUM }}"); do
echo " {"
echo " \"name\": \"HTTP/www$i.{{ DOMAIN }}\","
echo " \"continue\": \"true\""
if [ "$i" -lt "{{ NUM }}" ]; then
echo " },"
else
echo " }"
fi
done
echo "]"
vars:
NUM: 500
DOMAIN: "{{ ipaserver_domain }}"
register: command
- name: Set service_absent_list
ansible.builtin.set_fact:
service_absent_list: "{{ command.stdout | from_json }}"
- name: Create present hosts.json data
ansible.builtin.shell: |
echo "["
for i in $(seq 1 "{{ NUM }}"); do
echo " {"
echo " \"name\": \"www$i.{{ DOMAIN }}\","
echo " \"force\": \"true\""
if [ "$i" -lt "{{ NUM }}" ]; then
echo " },"
else
echo " }"
fi
done
echo "]"
vars:
NUM: 500
DOMAIN: "{{ ipaserver_domain }}"
register: command
- name: Set host_list
ansible.builtin.set_fact:
host_list: "{{ command.stdout | from_json }}"
- name: Create absent hosts.json data
ansible.builtin.shell: |
echo "["
for i in $(seq 1 "{{ NUM }}"); do
echo " {"
echo " \"name\": \"www$i.{{ DOMAIN }}\""
if [ "$i" -lt "{{ NUM }}" ]; then
echo " },"
else
echo " }"
fi
done
echo "]"
vars:
NUM: 500
DOMAIN: "{{ ipaserver_domain }}"
register: command
- name: Set host_absent_list
ansible.builtin.set_fact:
host_absent_list: "{{ command.stdout | from_json }}"