From 0a8672fcb50ebb51fff148c5657f47b62b0757a6 Mon Sep 17 00:00:00 2001
From: Thomas Woerner <twoerner@redhat.com>
Date: Mon, 18 Sep 2017 17:33:08 +0200
Subject: [PATCH] library/ipajoin.py: Enhanced tests for password and keytab

mutually_exclusive and required_one_of are only able to check if the parameters
are defined, but not if they are set to "".
---
 library/ipajoin.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/library/ipajoin.py b/library/ipajoin.py
index 1ae9ff1a..746d842f 100644
--- a/library/ipajoin.py
+++ b/library/ipajoin.py
@@ -202,8 +202,6 @@ def main():
             kinit_attempts=dict(required=False, type='int', default=5),
             debug=dict(required=False, type='bool'),
         ),
-        mutually_exclusive = [['password','keytab']],
-        required_one_of = [['password', 'keytab']],
         supports_check_mode = True,
     )
 
@@ -222,6 +220,10 @@ def main():
     kinit_attempts = module.params.get('kinit_attempts')
     debug = module.params.get('debug')
 
+    if password is not None and password != "" and \
+       keytab is not None and keytab != "":
+        module.fail_json(msg="Password and keytab cannot be used together")
+
     client_domain = hostname[hostname.find(".")+1:]
     nolog = tuple()
     env = {'PATH': SECURE_PATH}
-- 
GitLab