From 827723db90131ac8e8c3845dc90e361ea2353194 Mon Sep 17 00:00:00 2001 From: Evgeni Golov Date: Mon, 6 Feb 2017 19:53:12 +0100 Subject: [PATCH] use require_if to check for username or AK instead of custom code (#20937) the logical or parameter to require_if was introduced in #20220 --- lib/ansible/modules/packaging/os/redhat_subscription.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/ansible/modules/packaging/os/redhat_subscription.py b/lib/ansible/modules/packaging/os/redhat_subscription.py index 0bcb9853f0..041da5c6e1 100644 --- a/lib/ansible/modules/packaging/os/redhat_subscription.py +++ b/lib/ansible/modules/packaging/os/redhat_subscription.py @@ -490,6 +490,7 @@ def main(): ), required_together = [ ['username', 'password'], ['activationkey', 'org_id'] ], mutually_exclusive = [ ['username', 'activationkey'] ], + required_if = [ [ 'state', 'present', ['username', 'activationkey'], True ] ], ) rhsm.module = module @@ -515,10 +516,6 @@ def main(): # Ensure system is registered if state == 'present': - # Check for missing parameters ... - if not (activationkey or org_id or username or password): - module.fail_json(msg="Missing arguments, must supply an activationkey (%s) and Organization ID (%s) or username (%s) and password (%s)" % (activationkey, org_id, username, password)) - # Register system if rhsm.is_registered and not force_register: if pool != '^$':