mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-03-26 21:33:05 +00:00
tests/sudorule: Don't become or gather_facts and use only true/false
Unless there's a real need to use privileged access or to gather Ansible facts upfront, we should always set "become: false" and "gather_facts: false". In the case that only a few Ansible facts are required, 'ansible.builtin.setup' with 'gather_subset' should be used. As the YAML 1.2 standard dictates, boolean values should only use 'true' or 'false' values. This patch fixes these issues in the 'sudorule' test suite.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user