diff --git a/plugins/modules/ipahost.py b/plugins/modules/ipahost.py index 453200e6e762e47e7b22a3478b4491d63c9f7ca4..39857bca633dfdec6213c28b01482f79bf1adf83 100644 --- a/plugins/modules/ipahost.py +++ b/plugins/modules/ipahost.py @@ -764,7 +764,7 @@ def main(): mac_address = ansible_module.params_get("mac_address") sshpubkey = ansible_module.params_get("sshpubkey") userclass = ansible_module.params_get("userclass") - auth_ind = ansible_module.params_get("auth_ind") + auth_ind = ansible_module.params_get("auth_ind", allow_empty_string=True) requires_pre_auth = ansible_module.params_get("requires_pre_auth") ok_as_delegate = ansible_module.params_get("ok_as_delegate") ok_to_auth_as_delegate = ansible_module.params_get( diff --git a/tests/host/test_host_empty_string_params.yml b/tests/host/test_host_empty_string_params.yml new file mode 100644 index 0000000000000000000000000000000000000000..59481d1198d048d87a45c7c03ccc90cb455a3daa --- /dev/null +++ b/tests/host/test_host_empty_string_params.yml @@ -0,0 +1,86 @@ +--- +- name: Test host + hosts: "{{ ipa_test_host | default('ipaserver') }}" + become: yes + gather_facts: yes + + tasks: + - name: Get Domain from server name + set_fact: + ipaserver_domain: "{{ ansible_facts['fqdn'].split('.')[1:] | join ('.') }}" + when: ipaserver_domain is not defined + + - name: Set host1_fqdn .. host6_fqdn + set_fact: + host1_fqdn: "{{ 'host1.' + ipaserver_domain }}" + + # CLEANUP TEST ITEMS + + - name: Ensure host "{{ host1_fqdn }}" absent + ipahost: + ipaadmin_password: SomeADMINpassword + ipaapi_context: "{{ ipa_context | default(omit) }}" + name: "{{ host1_fqdn }}" + state: absent + + # CREATE TEST ITEMS + + - name: Ensure host "{{ host1_fqdn }}" present + ipahost: + ipaadmin_password: SomeADMINpassword + ipaapi_context: "{{ ipa_context | default(omit) }}" + name: "{{ host1_fqdn }}" + force: yes + register: result + failed_when: not result.changed or result.failed + + # TESTS + + - name: Ensure host "{{ host1_fqdn }}" present with auth_ind otp and radius + ipahost: + ipaadmin_password: SomeADMINpassword + ipaapi_context: "{{ ipa_context | default(omit) }}" + name: "{{ host1_fqdn }}" + auth_ind: + - otp + - radius + register: result + failed_when: not result.changed or result.failed + + - name: Ensure host "{{ host1_fqdn }}" present with auth_ind otp and radius, again + ipahost: + ipaadmin_password: SomeADMINpassword + ipaapi_context: "{{ ipa_context | default(omit) }}" + name: "{{ host1_fqdn }}" + auth_ind: + - otp + - radius + register: result + failed_when: result.changed or result.failed + + - name: Ensure host "{{ host1_fqdn }}" present with empty auth_ind + ipahost: + ipaadmin_password: SomeADMINpassword + ipaapi_context: "{{ ipa_context | default(omit) }}" + name: "{{ host1_fqdn }}" + auth_ind: "" + register: result + failed_when: not result.changed or result.failed + + - name: Ensure host "{{ host1_fqdn }}" present with empty auth_ind, again + ipahost: + ipaadmin_password: SomeADMINpassword + ipaapi_context: "{{ ipa_context | default(omit) }}" + name: "{{ host1_fqdn }}" + auth_ind: "" + register: result + failed_when: result.changed or result.failed + + # CLEANUP TEST ITEMS + + - name: Ensure host "{{ host1_fqdn }}" absent + ipahost: + ipaadmin_password: SomeADMINpassword + ipaapi_context: "{{ ipa_context | default(omit) }}" + name: "{{ host1_fqdn }}" + state: absent