|
|
7d56d3 |
From 3780a9a00e77ae0fd2944b36adad446d094fc90f Mon Sep 17 00:00:00 2001
|
|
|
7d56d3 |
From: Thomas Woerner <twoerner@redhat.com>
|
|
|
7d56d3 |
Date: Tue, 11 Feb 2020 10:34:39 +0100
|
|
|
7d56d3 |
Subject: [PATCH] ansible_freeipa_module: Fix comparison of bool parameters in
|
|
|
7d56d3 |
compare_args_ipa
|
|
|
7d56d3 |
|
|
|
7d56d3 |
Bool types are not iterable. Therefore the comparison using sets was failing
|
|
|
7d56d3 |
with a TypeError. This prevented to change the bool parameters for hosts.
|
|
|
7d56d3 |
|
|
|
7d56d3 |
A test for the host module has been added to verify that the bool parameters
|
|
|
7d56d3 |
can be modified.
|
|
|
7d56d3 |
|
|
|
7d56d3 |
New test:
|
|
|
7d56d3 |
|
|
|
7d56d3 |
tests/host/test_host_bool_params.yml
|
|
|
7d56d3 |
|
|
|
7d56d3 |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1784514
|
|
|
7d56d3 |
---
|
|
|
7d56d3 |
.../module_utils/ansible_freeipa_module.py | 18 ++-
|
|
|
7d56d3 |
tests/host/test_host_bool_params.yml | 119 ++++++++++++++++++
|
|
|
7d56d3 |
2 files changed, 133 insertions(+), 4 deletions(-)
|
|
|
7d56d3 |
create mode 100644 tests/host/test_host_bool_params.yml
|
|
|
7d56d3 |
|
|
|
7d56d3 |
diff --git a/plugins/module_utils/ansible_freeipa_module.py b/plugins/module_utils/ansible_freeipa_module.py
|
|
|
7d56d3 |
index 8154a12..9e97b88 100644
|
|
|
7d56d3 |
--- a/plugins/module_utils/ansible_freeipa_module.py
|
|
|
7d56d3 |
+++ b/plugins/module_utils/ansible_freeipa_module.py
|
|
|
7d56d3 |
@@ -222,10 +222,20 @@ def compare_args_ipa(module, args, ipa):
|
|
|
7d56d3 |
arg = [to_text(_arg) for _arg in arg]
|
|
|
7d56d3 |
if isinstance(ipa_arg[0], unicode) and isinstance(arg[0], int):
|
|
|
7d56d3 |
arg = [to_text(_arg) for _arg in arg]
|
|
|
7d56d3 |
- # module.warn("%s <=> %s" % (arg, ipa_arg))
|
|
|
7d56d3 |
- if set(arg) != set(ipa_arg):
|
|
|
7d56d3 |
- # module.warn("DIFFERENT")
|
|
|
7d56d3 |
- return False
|
|
|
7d56d3 |
+ # module.warn("%s <=> %s" % (repr(arg), repr(ipa_arg)))
|
|
|
7d56d3 |
+ try:
|
|
|
7d56d3 |
+ arg_set = set(arg)
|
|
|
7d56d3 |
+ ipa_arg_set = set(ipa_arg)
|
|
|
7d56d3 |
+ except TypeError:
|
|
|
7d56d3 |
+ if arg != ipa_arg:
|
|
|
7d56d3 |
+ # module.warn("%s != %s" % (repr(arg), repr(ipa_arg)))
|
|
|
7d56d3 |
+ return False
|
|
|
7d56d3 |
+ else:
|
|
|
7d56d3 |
+ if arg_set != ipa_arg_set:
|
|
|
7d56d3 |
+ # module.warn("%s != %s" % (repr(arg), repr(ipa_arg)))
|
|
|
7d56d3 |
+ return False
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ # module.warn("%s == %s" % (repr(arg), repr(ipa_arg)))
|
|
|
7d56d3 |
|
|
|
7d56d3 |
return True
|
|
|
7d56d3 |
|
|
|
7d56d3 |
diff --git a/tests/host/test_host_bool_params.yml b/tests/host/test_host_bool_params.yml
|
|
|
7d56d3 |
new file mode 100644
|
|
|
7d56d3 |
index 0000000..824ea99
|
|
|
7d56d3 |
--- /dev/null
|
|
|
7d56d3 |
+++ b/tests/host/test_host_bool_params.yml
|
|
|
7d56d3 |
@@ -0,0 +1,119 @@
|
|
|
7d56d3 |
+---
|
|
|
7d56d3 |
+- name: Test host bool parameters
|
|
|
7d56d3 |
+ hosts: ipaserver
|
|
|
7d56d3 |
+ become: true
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ tasks:
|
|
|
7d56d3 |
+ - name: Get Domain from server name
|
|
|
7d56d3 |
+ set_fact:
|
|
|
7d56d3 |
+ ipaserver_domain: "{{ groups.ipaserver[0].split('.')[1:] | join ('.') }}"
|
|
|
7d56d3 |
+ when: ipaserver_domain is not defined
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Set host1_fqdn .. host6_fqdn
|
|
|
7d56d3 |
+ set_fact:
|
|
|
7d56d3 |
+ host1_fqdn: "{{ 'host1.' + ipaserver_domain }}"
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host absent
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name:
|
|
|
7d56d3 |
+ - "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ update_dns: yes
|
|
|
7d56d3 |
+ state: absent
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host "{{ host1_fqdn }}" present with requires_pre_auth, ok_as_delegate and ok_to_auth_as_delegate
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name: "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ force: yes
|
|
|
7d56d3 |
+ requires_pre_auth: yes
|
|
|
7d56d3 |
+ ok_as_delegate: yes
|
|
|
7d56d3 |
+ ok_to_auth_as_delegate: yes
|
|
|
7d56d3 |
+ register: result
|
|
|
7d56d3 |
+ failed_when: not result.changed
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host "{{ host1_fqdn }}" present with requires_pre_auth, ok_as_delegate and ok_to_auth_as_delegate again
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name: "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ requires_pre_auth: yes
|
|
|
7d56d3 |
+ ok_as_delegate: yes
|
|
|
7d56d3 |
+ ok_to_auth_as_delegate: yes
|
|
|
7d56d3 |
+ register: result
|
|
|
7d56d3 |
+ failed_when: result.changed
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host "{{ host1_fqdn }}" present with requires_pre_auth, ok_as_delegate and ok_to_auth_as_delegate set to no
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name: "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ requires_pre_auth: no
|
|
|
7d56d3 |
+ ok_as_delegate: no
|
|
|
7d56d3 |
+ ok_to_auth_as_delegate: no
|
|
|
7d56d3 |
+ register: result
|
|
|
7d56d3 |
+ failed_when: not result.changed
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host "{{ host1_fqdn }}" present with requires_pre_auth, ok_as_delegate and ok_to_auth_as_delegate set to no again
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name: "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ requires_pre_auth: no
|
|
|
7d56d3 |
+ ok_as_delegate: no
|
|
|
7d56d3 |
+ ok_to_auth_as_delegate: no
|
|
|
7d56d3 |
+ register: result
|
|
|
7d56d3 |
+ failed_when: result.changed
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host "{{ host1_fqdn }}" present with requires_pre_auth
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name: "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ requires_pre_auth: yes
|
|
|
7d56d3 |
+ register: result
|
|
|
7d56d3 |
+ failed_when: not result.changed
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host "{{ host1_fqdn }}" present with requires_pre_auth again
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name: "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ requires_pre_auth: yes
|
|
|
7d56d3 |
+ register: result
|
|
|
7d56d3 |
+ failed_when: result.changed
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host "{{ host1_fqdn }}" present with ok_as_delegate
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name: "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ ok_as_delegate: yes
|
|
|
7d56d3 |
+ register: result
|
|
|
7d56d3 |
+ failed_when: not result.changed
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host "{{ host1_fqdn }}" present with ok_as_delegate again
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name: "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ ok_as_delegate: yes
|
|
|
7d56d3 |
+ register: result
|
|
|
7d56d3 |
+ failed_when: result.changed
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host "{{ host1_fqdn }}" present with ok_to_auth_as_delegate
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name: "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ ok_to_auth_as_delegate: yes
|
|
|
7d56d3 |
+ register: result
|
|
|
7d56d3 |
+ failed_when: not result.changed
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host "{{ host1_fqdn }}" present with ok_to_auth_as_delegate again
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name: "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ ok_to_auth_as_delegate: yes
|
|
|
7d56d3 |
+ register: result
|
|
|
7d56d3 |
+ failed_when: result.changed
|
|
|
7d56d3 |
+
|
|
|
7d56d3 |
+ - name: Host absent
|
|
|
7d56d3 |
+ ipahost:
|
|
|
7d56d3 |
+ ipaadmin_password: MyPassword123
|
|
|
7d56d3 |
+ name:
|
|
|
7d56d3 |
+ - "{{ host1_fqdn }}"
|
|
|
7d56d3 |
+ update_dns: yes
|
|
|
7d56d3 |
+ state: absent
|