mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-08-02 04:44:42 +00:00
Merge pull request #350 from rjeffman/tests_skip_tests_ipa_version
Add FreeIPA version as Ansible facts for testing.
This commit is contained in:
18
tests/env_freeipa_facts.yml
Normal file
18
tests/env_freeipa_facts.yml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# This playbook should be included with `include_tasks` as the first task
|
||||||
|
# of a test playbook that requires FreeIPA information.
|
||||||
|
#
|
||||||
|
# Available Facts:
|
||||||
|
#
|
||||||
|
# ipa_version: The installed FreeIPA version.
|
||||||
|
# ipa_api_version: The installed FreeIPA API version.
|
||||||
|
#
|
||||||
|
---
|
||||||
|
- name: Retrieving FreeIPA version.
|
||||||
|
shell:
|
||||||
|
cmd: 'ipa --version | sed -n "s/VERSION: \([^,]*\).*API_VERSION: \([^,]*\).*/\1\\n\2/p"'
|
||||||
|
register: ipa_cmd_version
|
||||||
|
|
||||||
|
- name: Set FreeIPA facts.
|
||||||
|
set_fact:
|
||||||
|
ipa_version: "{{ ipa_cmd_version.stdout_lines[0] }}"
|
||||||
|
ipa_api_version: "{{ ipa_cmd_version.stdout_lines[1] }}"
|
||||||
@@ -5,6 +5,10 @@
|
|||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
- include_tasks: ../env_freeipa_facts.yml
|
||||||
|
|
||||||
|
- name: Tests requiring IPA version 4.8.4+
|
||||||
|
block:
|
||||||
- name: Ensure host-group testhostgroup is absent
|
- name: Ensure host-group testhostgroup is absent
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
@@ -217,3 +221,4 @@
|
|||||||
state: absent
|
state: absent
|
||||||
register: result
|
register: result
|
||||||
failed_when: not result.changed
|
failed_when: not result.changed
|
||||||
|
when: ipa_version is version('4.8.4', '>=')
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
- include_tasks: ../env_freeipa_facts.yml
|
||||||
|
|
||||||
|
- name: Tests requiring IPA version 4.8.7+
|
||||||
|
block:
|
||||||
- name: Ensure testing host-group are absent
|
- name: Ensure testing host-group are absent
|
||||||
ipahostgroup:
|
ipahostgroup:
|
||||||
ipaadmin_password: SomeADMINpassword
|
ipaadmin_password: SomeADMINpassword
|
||||||
@@ -103,3 +107,5 @@
|
|||||||
- databases
|
- databases
|
||||||
- datalake
|
- datalake
|
||||||
state: absent
|
state: absent
|
||||||
|
|
||||||
|
when: ipa_version is version('4.8.7', '>=')
|
||||||
|
|||||||
@@ -4,9 +4,96 @@
|
|||||||
become: yes
|
become: yes
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
- include_tasks: ../env_freeipa_facts.yml
|
||||||
|
|
||||||
|
- name: Tests requiring IPA version 4.7.0+
|
||||||
|
block:
|
||||||
# setup
|
# setup
|
||||||
- name: Setup test environment
|
- name: Get Domain from server name
|
||||||
include_tasks: env_setup.yml
|
set_fact:
|
||||||
|
ipaserver_domain: "{{ ansible_fqdn.split('.')[1:] | join ('.') }}"
|
||||||
|
when: ipaserver_domain is not defined
|
||||||
|
|
||||||
|
- name: Set host1, host2 and svc hosts fqdn
|
||||||
|
set_fact:
|
||||||
|
host1_fqdn: "{{ 'host1.' + ipaserver_domain }}"
|
||||||
|
host2_fqdn: "{{ 'host2.' + ipaserver_domain }}"
|
||||||
|
svc_fqdn: "{{ 'svc.' + ipaserver_domain }}"
|
||||||
|
|
||||||
|
- name: Host absent
|
||||||
|
ipahost:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name:
|
||||||
|
- svc.ihavenodns.info
|
||||||
|
- "{{ host1_fqdn }}"
|
||||||
|
- "{{ host2_fqdn }}"
|
||||||
|
- "{{ svc_fqdn }}"
|
||||||
|
update_dns: yes
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Get IPv4 address prefix from server node
|
||||||
|
set_fact:
|
||||||
|
ipv4_prefix: "{{ ansible_default_ipv4.address.split('.')[:-1] |
|
||||||
|
join('.') }}"
|
||||||
|
|
||||||
|
- name: Add hosts for tests.
|
||||||
|
ipahost:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
hosts:
|
||||||
|
- name: "{{ host1_fqdn }}"
|
||||||
|
ip_address: "{{ ipv4_prefix + '.201' }}"
|
||||||
|
update_dns: yes
|
||||||
|
- name: "{{ host2_fqdn }}"
|
||||||
|
ip_address: "{{ ipv4_prefix + '.202' }}"
|
||||||
|
update_dns: yes
|
||||||
|
- name: "{{ svc_fqdn }}"
|
||||||
|
ip_address: "{{ ipv4_prefix + '.203' }}"
|
||||||
|
update_dns: yes
|
||||||
|
- name: svc.ihavenodns.info
|
||||||
|
update_dns: no
|
||||||
|
force: yes
|
||||||
|
|
||||||
|
- name: Ensure testing user user01 is present.
|
||||||
|
ipauser:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name: user01
|
||||||
|
first: user01
|
||||||
|
last: last
|
||||||
|
|
||||||
|
- name: Ensure testing user user02 is present.
|
||||||
|
ipauser:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name: user02
|
||||||
|
first: user02
|
||||||
|
last: last
|
||||||
|
|
||||||
|
- name: Ensure testing group group01 is present.
|
||||||
|
ipagroup:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name: group01
|
||||||
|
|
||||||
|
- name: Ensure testing group group02 is present.
|
||||||
|
ipagroup:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name: group02
|
||||||
|
|
||||||
|
- name: Ensure testing hostgroup hostgroup01 is present.
|
||||||
|
ipahostgroup:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name: hostgroup01
|
||||||
|
|
||||||
|
- name: Ensure testing hostgroup hostgroup02 is present.
|
||||||
|
ipahostgroup:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name: hostgroup02
|
||||||
|
|
||||||
|
- name: Ensure services are absent.
|
||||||
|
ipaservice:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name:
|
||||||
|
- "HTTP/{{ svc_fqdn }}"
|
||||||
|
- HTTP/svc.ihavenodns.info
|
||||||
|
state: absent
|
||||||
|
|
||||||
# tests
|
# tests
|
||||||
- name: Ensure service is present
|
- name: Ensure service is present
|
||||||
@@ -343,5 +430,52 @@
|
|||||||
failed_when: result.changed
|
failed_when: result.changed
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
- name: Cleanup test environment
|
|
||||||
include_tasks: env_cleanup.yml
|
- name: Ensure services are absent.
|
||||||
|
ipaservice:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name:
|
||||||
|
- "HTTP/{{ svc_fqdn }}"
|
||||||
|
- HTTP/svc.ihavenodns.info
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Ensure host is absent
|
||||||
|
ipahost:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name:
|
||||||
|
- "{{ svc_fqdn }}"
|
||||||
|
- "{{ host1_fqdn }}"
|
||||||
|
- "{{ host2_fqdn }}"
|
||||||
|
- svc.ihavenodns.info
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Ensure testing users are absent.
|
||||||
|
ipauser:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name:
|
||||||
|
- user01
|
||||||
|
- user02
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Ensure testing groups are absent.
|
||||||
|
ipagroup:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name:
|
||||||
|
- group01
|
||||||
|
- group02
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Ensure testing hostgroup hostgroup01 is absent.
|
||||||
|
ipagroup:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name:
|
||||||
|
- hostgroup01
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Ensure testing hostgroup hostgroup02 is absent.
|
||||||
|
ipagroup:
|
||||||
|
ipaadmin_password: SomeADMINpassword
|
||||||
|
name:
|
||||||
|
- hostgroup02
|
||||||
|
state: absent
|
||||||
|
when: ipa_version is version('4.7.0', '>=')
|
||||||
|
|||||||
Reference in New Issue
Block a user