From abfc8d36a8c020f41ad917b6bad94945977e5df5 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Tue, 17 May 2016 19:04:16 +0200 Subject: [PATCH] Add a test on jnpr.junos.utils.sw presence (#3666) --- lib/ansible/modules/network/junos/junos_package.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/network/junos/junos_package.py b/lib/ansible/modules/network/junos/junos_package.py index a7a5d0d6a61..897fef41b1a 100644 --- a/lib/ansible/modules/network/junos/junos_package.py +++ b/lib/ansible/modules/network/junos/junos_package.py @@ -93,7 +93,11 @@ EXAMPLES = """ reboot: no """ -from jnpr.junos.utils.sw import SW +try: + from jnpr.junos.utils.sw import SW + HAS_SW = True +except ImportError: + HAS_SW = False def install_package(module): junos = SW(module.connection.device) @@ -126,6 +130,9 @@ def main(): module = get_module(argument_spec=spec, supports_check_mode=True) + if not HAS_SW: + module.fail_json(msg='Missing jnpr.junos.utils.sw module') + result = dict(changed=False) do_upgrade = module.params['force'] or False