From c52f355bcb051db156f480354a8b315b496183c0 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bonicoli Date: Fri, 14 Jul 2017 14:51:39 +0200 Subject: [PATCH] serverless: fix broken import --- lib/ansible/modules/cloud/misc/serverless.py | 12 ++++++++++-- test/sanity/import/skip.txt | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/misc/serverless.py b/lib/ansible/modules/cloud/misc/serverless.py index 44557d941a2..e77d7519aaa 100644 --- a/lib/ansible/modules/cloud/misc/serverless.py +++ b/lib/ansible/modules/cloud/misc/serverless.py @@ -58,7 +58,7 @@ options: default: true notes: - Currently, the `serverless` command must be in the path of the node executing the task. In the future this may be a flag. -requirements: [ "serverless" ] +requirements: [ "serverless", "yaml" ] author: "Ryan Scott Brown @ryansb" ''' @@ -116,7 +116,12 @@ command: import os import traceback -import yaml + +try: + import yaml + HAS_YAML = True +except ImportError: + HAS_YAML = False from ansible.module_utils.basic import AnsibleModule @@ -159,6 +164,9 @@ def main(): ), ) + if not HAS_YAML: + module.fail_json(msg='yaml is required for this module') + service_path = module.params.get('service_path') state = module.params.get('state') functions = module.params.get('functions') diff --git a/test/sanity/import/skip.txt b/test/sanity/import/skip.txt index 99ec588cce9..acd1b6bfa12 100644 --- a/test/sanity/import/skip.txt +++ b/test/sanity/import/skip.txt @@ -43,7 +43,6 @@ lib/ansible/modules/cloud/dimensiondata/dimensiondata_network.py lib/ansible/modules/cloud/google/gc_storage.py lib/ansible/modules/cloud/google/gcdns_record.py lib/ansible/modules/cloud/google/gcdns_zone.py -lib/ansible/modules/cloud/misc/serverless.py lib/ansible/modules/cloud/ovirt/ovirt_disks.py lib/ansible/modules/cloud/univention/udm_user.py lib/ansible/modules/cloud/webfaction/webfaction_app.py