mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-03-26 21:33:05 +00:00
Use Fully Qualified Collection Name (FQCN) for ansible builtins. This is ansible.builtin.set_fact instead of set_fact for example and aplies for all actions that are part of ansible.builtin. All the replaced ansible.builtins: assert, command, copy, debug, fail, fetch, file, import_playbook, import_tasks, include_role, include_tasks, include_vars, package, set_fact, shell, slurp, stat, systemd
170 lines
6.0 KiB
YAML
170 lines
6.0 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
|
|
ansible.builtin.set_fact:
|
|
ipa_server_name: "{{ ansible_facts['fqdn'].split('.')[0] }}"
|
|
rescue:
|
|
- name: Fallback to 'ipaserver'
|
|
ansible.builtin.set_fact:
|
|
ipa_server_name: ipaserver
|
|
when: ipa_server_name is not defined
|
|
|
|
- block:
|
|
- name: Get domain name from hostname.
|
|
ansible.builtin.set_fact:
|
|
ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join('.') }}"
|
|
rescue:
|
|
- name: Fallback to 'ipa.test'
|
|
ansible.builtin.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
|