tests service: Fixes evaluation of 'Keytab = True'

In ansible-core 2.19 there's no automatic coercion from None or empty
strings to the boolean value "false", so we need to compare the result
of the filter 'regex_search' to 'None' and the empty string to evaluate
if any match occurred.

In fixing this issue, it was found that the tests were incorrectly
evaluating the results, and the comparisons were fixed.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
This commit is contained in:
Rafael Guterres Jeffman
2025-06-12 18:48:44 -03:00
parent 668830fc94
commit d1dfdc38c9

View File

@@ -48,7 +48,8 @@
- name: Verify keytab - name: Verify keytab
ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}" ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
register: result register: result
failed_when: result.failed or result.stdout | regex_search(" Keytab. true") changed_when: false
failed_when: result.failed or (result.stdout | regex_search(" Keytab. [Tt]rue")) in [None, ""]
- name: Ensure service is disabled - name: Ensure service is disabled
ipaservice: ipaservice:
@@ -61,7 +62,8 @@
- name: Verify keytab - name: Verify keytab
ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}" ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
register: result register: result
failed_when: result.failed or result.stdout | regex_search(" Keytab. true") changed_when: false
failed_when: result.failed or (result.stdout | regex_search(" Keytab. [Ff]alse")) in [None, ""]
- name: Obtain keytab - name: Obtain keytab
ansible.builtin.shell: ipa-getkeytab -s "{{ ansible_facts['fqdn'] }}" -p "mysvc1/{{ ansible_facts['fqdn'] }}" -k mysvc1.keytab ansible.builtin.shell: ipa-getkeytab -s "{{ ansible_facts['fqdn'] }}" -p "mysvc1/{{ ansible_facts['fqdn'] }}" -k mysvc1.keytab
@@ -69,7 +71,8 @@
- name: Verify keytab - name: Verify keytab
ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}" ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
register: result register: result
failed_when: result.failed or result.stdout | regex_search(" Keytab. true") changed_when: false
failed_when: result.failed or (result.stdout | regex_search(" Keytab. [Tt]rue")) in [None, ""]
- name: Ensure service is disabled - name: Ensure service is disabled
ipaservice: ipaservice:
@@ -82,7 +85,8 @@
- name: Verify keytab - name: Verify keytab
ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}" ansible.builtin.shell: ipa service-find "mysvc1/{{ ansible_facts['fqdn'] }}"
register: result register: result
failed_when: result.failed or result.stdout | regex_search(" Keytab. true") changed_when: false
failed_when: result.failed or (result.stdout | regex_search(" Keytab. [Ff]alse")) in [None, ""]
- name: Ensure service is disabled, with no keytab. - name: Ensure service is disabled, with no keytab.
ipaservice: ipaservice: