Files
ansible-freeipa/tests/server/test_server.yml
Rafael Guterres Jeffman db900ffe6a Fix comment identation in test playbooks.
Comments in YAML files should be aligned to content.
2021-09-29 15:49:00 -03:00

170 lines
5.9 KiB
YAML

---
- name: Test server
hosts: "{{ ipa_test_host | default('ipaserver') }}"
become: true
gather_facts: yes
tasks:
# CLEANUP TEST ITEMS
- block:
- name: Get server name from hostname
set_fact:
ipa_server_name: "{{ ansible_facts['hostname'].split('.')[0] }}"
rescue:
- name: Fallback to 'ipaserver'
set_fact:
ipa_server_name: ipaserver
when: ipa_server_name is not defined
- block:
- name: Get domain name from hostname.
set_fact:
ipaserver_domain: "{{ ansible_facts['hostname'].split('.')[0][1:] }}"
rescue:
- name: Fallback to 'ipa.test'
set_fact:
ipaserver_domain: "ipa.test"
when: ipaserver_domain is not defined
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without location
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
location: ""
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without service weight
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
service_weight: -1
- name: Ensure location "mylocation" is absent
ipalocation:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: mylocation
state: absent
# CREATE TEST ITEMS
- name: Ensure location "mylocation" is present
ipalocation:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: mylocation
register: result
failed_when: not result.changed or result.failed
# TESTS
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" is present
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
register: result
failed_when: result.changed or result.failed
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with location "mylocation"
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
location: "mylocation"
register: result
failed_when: not result.changed or result.failed
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with location "mylocation" again
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
location: "mylocation"
register: result
failed_when: result.changed or result.failed
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without location
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
location: ""
register: result
failed_when: not result.changed or result.failed
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without location again
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
location: ""
register: result
failed_when: result.changed or result.failed
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with service weight 1
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
service_weight: 1
register: result
failed_when: not result.changed or result.failed
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" with service weight 1 again
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
service_weight: 1
register: result
failed_when: result.changed or result.failed
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without service weight
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
service_weight: -1
register: result
failed_when: not result.changed or result.failed
- name: Ensure server "{{ ipa_server_name + '.' + ipaserver_domain }}" without service weight again
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ ipa_server_name + '.' + ipaserver_domain }}"
service_weight: -1
register: result
failed_when: result.changed or result.failed
# hidden requires an additional server, not tested
# absent requires an additional server, only sanity test with absent server
- name: Ensure server "{{ 'absent.' + ipaserver_domain }}" is absent
ipaserver:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: "{{ 'absent.' + ipaserver_domain }}"
state: absent
register: result
failed_when: result.changed or result.failed
# ignore_last_of_role requires an additional server, not tested
# ignore_topology_disconnect requires an additional server, not tested
# CLEANUP TEST ITEMS
- name: Ensure location "mylocation" is absent
ipalocation:
ipaadmin_password: SomeADMINpassword
ipaapi_context: "{{ ipa_context | default(omit) }}"
name: mylocation
state: absent
register: result
failed_when: not result.changed or result.failed