From 840a57a4edbf5a2c71f91cf8bbbb4b2236abbc93 Mon Sep 17 00:00:00 2001 From: Pilou Date: Thu, 12 Oct 2017 20:48:05 +0200 Subject: [PATCH] s3_sync: fix broken import (#31460) --- lib/ansible/modules/cloud/amazon/s3_sync.py | 12 +++++++++++- test/sanity/import/skip.txt | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/s3_sync.py b/lib/ansible/modules/cloud/amazon/s3_sync.py index 431e3e724b4..54274e88af3 100644 --- a/lib/ansible/modules/cloud/amazon/s3_sync.py +++ b/lib/ansible/modules/cloud/amazon/s3_sync.py @@ -99,6 +99,7 @@ options: requirements: - boto3 >= 1.4.4 - botocore + - python-dateutil author: tedder extends_documentation_fragment: @@ -209,13 +210,18 @@ import mimetypes import os import stat as osstat # os.stat constants import traceback -from dateutil import tz # import module snippets from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.ec2 import camel_dict_to_snake_dict, ec2_argument_spec, boto3_conn, get_aws_connection_info, HAS_BOTO3, boto_exception from ansible.module_utils._text import to_text +try: + from dateutil import tz + HAS_DATEUTIL = True +except ImportError: + HAS_DATEUTIL = False + try: import botocore except ImportError: @@ -497,6 +503,10 @@ def main(): module = AnsibleModule( argument_spec=argument_spec, ) + + if not HAS_DATEUTIL: + module.fail_json(msg='dateutil required for this module') + if not HAS_BOTO3: module.fail_json(msg='boto3 required for this module') diff --git a/test/sanity/import/skip.txt b/test/sanity/import/skip.txt index 3c90812f17e..aa2a337c771 100644 --- a/test/sanity/import/skip.txt +++ b/test/sanity/import/skip.txt @@ -1,6 +1,5 @@ lib/ansible/modules/cloud/amazon/cloudtrail.py lib/ansible/modules/cloud/amazon/ec2_win_password.py -lib/ansible/modules/cloud/amazon/s3_sync.py lib/ansible/modules/cloud/azure/azure.py lib/ansible/modules/cloud/azure/azure_rm_dnsrecordset.py lib/ansible/modules/cloud/centurylink/clc_firewall_policy.py