diff --git a/tests/sudorule/test_sudorule.yml b/tests/sudorule/test_sudorule.yml index 476fb1d89b848000377a0a6ab46e3f938a3adad7..25dd84cdd14aafde9bdfa9e44127e6efcacd894a 100644 --- a/tests/sudorule/test_sudorule.yml +++ b/tests/sudorule/test_sudorule.yml @@ -3,11 +3,15 @@ - name: Test sudorule hosts: "{{ ipa_test_host | default('ipaserver') }}" become: true - gather_facts: true + gather_facts: false tasks: # setup + - name: Ensure DNS Ansible facts are available + ansible.builtin.setup: + gather_subset: dns + - name: Ensure test user is present ipauser: ipaadmin_password: SomeADMINpassword @@ -1157,7 +1161,7 @@ hostmask: 192.168.120.0/24 action: member register: result - check_mode: yes + check_mode: true failed_when: not result.changed or result.failed - name: Ensure sudorule hostmask member is present diff --git a/tests/sudorule/test_sudorule_categories.yml b/tests/sudorule/test_sudorule_categories.yml index 95b94f128253998de64cd2ba7f8d9cf33c51957f..91b9dca0d932c50806e63c3d021dbe011d3f3bc2 100644 --- a/tests/sudorule/test_sudorule_categories.yml +++ b/tests/sudorule/test_sudorule_categories.yml @@ -1,13 +1,22 @@ --- - name: Test sudorule user category hosts: ipaserver - become: yes - gather_facts: yes + become: false + gather_facts: false tasks: - - name: Get Domain from the server name - ansible.builtin.set_fact: - ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join('.') }}" + - name: Test sudorule single hostnames + block: + # setup test environment + - name: Ensure ipaserver_domain is set + when: ipaserver_domain is not defined + block: + - name: Retrieve host information + ansible.builtin.setup: + gather_subset: dns + - name: Get Domain from the server name + ansible.builtin.set_fact: + ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join('.') }}" - name: Ensure sudorules are absent ipasudorule: diff --git a/tests/sudorule/test_sudorule_client_context.yml b/tests/sudorule/test_sudorule_client_context.yml index 331f138be4b747965d726ec47306105b027a69ae..faa111b9318067151872cc13056cf3cfe265ae0b 100644 --- a/tests/sudorule/test_sudorule_client_context.yml +++ b/tests/sudorule/test_sudorule_client_context.yml @@ -1,8 +1,8 @@ --- - name: Test sudorule hosts: ipaclients, ipaserver - become: no - gather_facts: no + become: false + gather_facts: false tasks: - name: Include FreeIPA facts. diff --git a/tests/sudorule/test_sudorule_member_case_insensitive.yml b/tests/sudorule/test_sudorule_member_case_insensitive.yml index cc212406a4fc3fde88c6d6fbec32d0a3b0eaa444..21ffe3028e91332e404c595e40bed4d4220b11f6 100644 --- a/tests/sudorule/test_sudorule_member_case_insensitive.yml +++ b/tests/sudorule/test_sudorule_member_case_insensitive.yml @@ -1,8 +1,8 @@ --- - name: Test sudorule members should be case insensitive. hosts: "{{ ipa_test_host | default('ipaserver') }}" - become: no - gather_facts: no + become: false + gather_facts: false vars: groups_present: @@ -37,7 +37,7 @@ ipahost: ipaadmin_password: SomeADMINpassword name: "{{ item }}.{{ ipa_domain }}" - force: yes + force: true loop: "{{ groups_present }}" - name: Ensure test users exist. diff --git a/tests/sudorule/test_sudorule_single_hostnames.yml b/tests/sudorule/test_sudorule_single_hostnames.yml index cc6a781928bfea707463c983781335cc4dbb4b4e..728aab1cc72b8e0fbd3683cb5d9674870bc3a121 100644 --- a/tests/sudorule/test_sudorule_single_hostnames.yml +++ b/tests/sudorule/test_sudorule_single_hostnames.yml @@ -1,17 +1,22 @@ --- - name: Test sudorule with single hostnames. hosts: "{{ ipa_test_host | default('ipaserver') }}" - become: no - gather_facts: no + become: false + gather_facts: false tasks: - name: Test sudorule single hostnames block: # setup test environment - - name: Get Domain from the server name - ansible.builtin.set_fact: - ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join('.') }}" + - name: Ensure ipaserver_domain is set when: ipaserver_domain is not defined + block: + - name: Retrieve host information + ansible.builtin.setup: + gather_subset: dns + - name: Get Domain from the server name + ansible.builtin.set_fact: + ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join('.') }}" - name: Ensure test sudo rule is absent ipasudorule: @@ -24,9 +29,9 @@ ipaadmin_password: SomeADMINpassword hosts: - name: "host01.{{ ipaserver_domain }}" - force: yes + force: true - name: "host02.{{ ipaserver_domain }}" - force: yes + force: true # start tests - name: Ensure sudorule exist with host member using FQDN. diff --git a/tests/sudorule/test_sudorules.yml b/tests/sudorule/test_sudorules.yml index 745926897b57efebe9ccaad60270f1ca00e6a496..0df3066c89894094955bcb102b865a05c8aefc4f 100644 --- a/tests/sudorule/test_sudorules.yml +++ b/tests/sudorule/test_sudorules.yml @@ -2,7 +2,7 @@ - name: Test sudorule hosts: "{{ ipa_test_host | default('ipaserver') }}" become: false - gather_facts: true # required for ansible_facts['fqdn'] + gather_facts: false module_defaults: ipauser: