2013-03-19 17:07:36 +01:00
#!/usr/bin/python
2013-03-16 12:18:43 +01:00
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
DOCUMENTATION = '''
- - -
module : s3
2015-03-13 22:08:30 +01:00
short_description : manage objects in S3 .
2013-03-16 12:18:43 +01:00
description :
2015-03-13 22:08:30 +01:00
- This module allows the user to manage S3 buckets and the objects within them . Includes support for creating and deleting both objects and buckets , retrieving objects as files or strings and generating download links . This module has a dependency on python - boto .
2013-03-16 12:18:43 +01:00
version_added : " 1.1 "
options :
2015-02-24 19:24:23 +01:00
aws_access_key :
2013-03-16 12:18:43 +01:00
description :
2015-02-24 19:24:23 +01:00
- AWS access key id . If not set then the value of the AWS_ACCESS_KEY environment variable is used .
2013-03-16 12:18:43 +01:00
required : false
default : null
2015-02-24 19:24:23 +01:00
aliases : [ ' ec2_access_key ' , ' access_key ' ]
aws_secret_key :
2013-05-02 21:27:12 +02:00
description :
2015-02-24 19:24:23 +01:00
- AWS secret key . If not set then the value of the AWS_SECRET_KEY environment variable is used .
2013-05-02 21:27:12 +02:00
required : false
default : null
2015-02-24 19:24:23 +01:00
aliases : [ ' ec2_secret_key ' , ' secret_key ' ]
bucket :
2015-10-14 21:54:04 +02:00
description :
2015-07-21 02:05:10 +02:00
- Bucket name .
2015-02-24 19:24:23 +01:00
required : true
default : null
2013-05-02 21:27:12 +02:00
aliases : [ ]
2013-07-04 16:55:06 +02:00
dest :
2013-03-16 12:18:43 +01:00
description :
2013-07-04 16:55:06 +02:00
- The destination file path when downloading an object / key with a GET operation .
2013-03-16 12:18:43 +01:00
required : false
aliases : [ ]
2013-07-04 16:55:06 +02:00
version_added : " 1.3 "
2015-02-24 19:24:23 +01:00
encrypt :
2013-04-02 19:19:11 +02:00
description :
2015-02-24 19:24:23 +01:00
- When set for PUT mode , asks for server - side encryption
2013-04-02 19:19:11 +02:00
required : false
2015-02-24 19:24:23 +01:00
default : no
2015-07-09 22:38:14 +02:00
version_added : " 2.0 "
2013-10-08 14:42:03 +02:00
expiration :
2013-07-04 16:55:06 +02:00
description :
2015-03-28 15:17:12 +01:00
- Time limit ( in seconds ) for the URL generated and returned by S3 / Walrus when performing a mode = put or mode = geturl operation .
2013-07-04 16:55:06 +02:00
required : false
2013-10-08 14:42:03 +02:00
default : 600
2013-07-04 16:55:06 +02:00
aliases : [ ]
2015-06-30 15:04:15 +02:00
headers :
description :
- Custom headers for PUT operation , as a dictionary of ' key=value ' and ' key=value,key=value ' .
required : false
default : null
2015-07-28 20:50:39 +02:00
version_added : " 2.0 "
2015-06-25 19:36:07 +02:00
marker :
description :
- Specifies the key to start with when using list mode . Object keys are returned in alphabetical order , starting with key after the marker in order .
required : false
default : null
version_added : " 2.0 "
max_keys :
description :
- Max number of results to return in list mode , set this if you want to retrieve fewer than the default 1000 keys .
required : false
default : 1000
version_added : " 2.0 "
2013-11-01 15:23:01 +01:00
metadata :
description :
- Metadata for PUT operation , as a dictionary of ' key=value ' and ' key=value,key=value ' .
required : false
default : null
2014-03-11 19:48:39 +01:00
version_added : " 1.6 "
2015-02-24 19:24:23 +01:00
mode :
description :
2016-01-15 06:43:54 +01:00
- Switches the module behaviour between put ( upload ) , get ( download ) , geturl ( return download url , Ansible 1.3 + ) , getstr ( download object as string ( 1.3 + ) ) , list ( list keys , Ansible 2.0 + ) , create ( bucket ) , delete ( bucket ) , and delobj ( delete object , Ansible 2.0 + ) .
2015-02-24 19:24:23 +01:00
required : true
2016-01-15 06:43:54 +01:00
choices : [ ' get ' , ' put ' , ' delete ' , ' create ' , ' geturl ' , ' getstr ' , ' delobj ' , ' list ' ]
2015-02-24 19:24:23 +01:00
object :
description :
- Keyname of the object inside the bucket . Can be used to create " virtual directories " , see examples .
required : false
default : null
2015-08-19 20:30:21 +02:00
permission :
description :
2015-09-08 12:00:37 +02:00
- This option let ' s the user set the canned permissions on the object/bucket that are created. The permissions that can be set are ' private ' , ' public - read ' , ' public - read - write ' , ' authenticated - read ' . Multiple permissions can be specified as a list.
2015-08-19 20:30:21 +02:00
required : false
default : private
version_added : " 2.0 "
2015-06-25 19:36:07 +02:00
prefix :
description :
- Limits the response to keys that begin with the specified prefix for list mode
required : false
default : null
version_added : " 2.0 "
2015-05-14 14:47:07 +02:00
version :
description :
- Version ID of the object inside the bucket . Can be used to get a specific version of a file if versioning is enabled in the target bucket .
required : false
default : null
aliases : [ ]
version_added : " 2.0 "
2015-02-24 19:24:23 +01:00
overwrite :
description :
2015-12-31 02:04:41 +01:00
- Force overwrite either locally on the filesystem or remotely with the object / key . Used with PUT and GET operations . Boolean or one of [ Always , Never , Different ] , new in 2.0
2015-02-24 19:24:23 +01:00
required : false
default : true
version_added : " 1.2 "
2014-09-09 01:02:08 +02:00
region :
description :
2014-12-25 01:04:25 +01:00
- " AWS region to create the bucket in. If not set then the value of the AWS_REGION and EC2_REGION environment variables are checked, followed by the aws_region and ec2_region settings in the Boto config file. If none of those are set the region defaults to the S3 Location: US Standard. Prior to ansible 1.8 this parameter could be specified but had no effect. "
2014-09-09 01:02:08 +02:00
required : false
default : null
version_added : " 1.8 "
feature pull request: catch and retry recoverable errors
boto can throw SSLError when timeouts occur (among other SSL errors). Catch these so proper JSON can be returned, and also add the ability to retry the operation.
There's an open issue in boto for this: https://github.com/boto/boto/issues/2409
Here's a sample stacktrace that inspired me to work on this. I'm on 1.7, but there's no meaningful differences in the 1.8 release that would affect this. I've added line breaks to the trace for readability.
failed to parse: Traceback (most recent call last):
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 2031, in <module> main()
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 353, in main download_s3file(module, s3, bucket, obj, dest)
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 234, in download_s3file key.get_contents_to_filename(dest)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1665, in get_contents_to_filename response_headers=response_headers)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1603, in get_contents_to_file response_headers=response_headers)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1435, in get_file query_args=None)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1488, in _get_file_internal for bytes in self:
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 368, in next data = self.resp.read(self.BufferSize)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 416, in read return httplib.HTTPResponse.read(self, amt)
File "/usr/lib/python2.7/httplib.py", line 567, in read s = self.fp.read(amt)
File "/usr/lib/python2.7/socket.py", line 380, in read data = self._sock.recv(left)
File "/usr/lib/python2.7/ssl.py", line 341, in recv return self.read(buflen)
File "/usr/lib/python2.7/ssl.py", line 260, in read return self._sslobj.read(len) ssl.SSLError: The read operation timed out
2014-12-30 01:38:08 +01:00
retries :
description :
- On recoverable failure , how many times to retry before actually failing .
required : false
default : 0
2015-05-27 15:55:33 +02:00
version_added : " 2.0 "
2015-02-24 19:24:23 +01:00
s3_url :
2015-10-14 21:54:04 +02:00
description :
2015-07-21 02:05:10 +02:00
- S3 URL endpoint for usage with Eucalypus , fakes3 , etc . Otherwise assumes AWS
2015-02-24 19:24:23 +01:00
default : null
aliases : [ S3_URL ]
src :
2015-10-14 21:54:04 +02:00
description :
2015-07-21 02:05:10 +02:00
- The source file path when performing a PUT operation .
2015-02-24 19:24:23 +01:00
required : false
default : null
aliases : [ ]
version_added : " 1.3 "
2014-03-11 19:48:39 +01:00
2013-03-16 12:18:43 +01:00
requirements : [ " boto " ]
2015-06-30 15:04:15 +02:00
author :
2015-06-15 20:41:22 +02:00
- " Lester Wade (@lwade) "
2014-12-25 01:04:25 +01:00
extends_documentation_fragment : aws
2013-03-16 12:18:43 +01:00
'''
2013-04-26 04:22:48 +02:00
EXAMPLES = '''
# Simple PUT operation
2013-07-04 16:55:06 +02:00
- s3 : bucket = mybucket object = / my / desired / key . txt src = / usr / local / myfile . txt mode = put
2014-12-01 21:14:57 +01:00
2013-07-04 16:55:06 +02:00
# Simple GET operation
- s3 : bucket = mybucket object = / my / desired / key . txt dest = / usr / local / myfile . txt mode = get
2014-12-01 21:14:57 +01:00
2015-05-14 14:47:07 +02:00
# Get a specific version of an object.
- s3 : bucket = mybucket object = / my / desired / key . txt version = 48 c9ee5131af7a716edc22df9772aa6f dest = / usr / local / myfile . txt mode = get
2013-11-01 15:23:01 +01:00
# PUT/upload with metadata
2014-03-03 03:45:53 +01:00
- s3 : bucket = mybucket object = / my / desired / key . txt src = / usr / local / myfile . txt mode = put metadata = ' Content-Encoding=gzip,Cache-Control=no-cache '
2014-12-01 21:14:57 +01:00
2015-06-30 15:04:15 +02:00
# PUT/upload with custom headers
- s3 : bucket = mybucket object = / my / desired / key . txt src = / usr / local / myfile . txt mode = put headers = x - amz - grant - full - control = emailAddress = owner @example.com
2014-11-15 01:07:29 +01:00
# List keys simple
- s3 : bucket = mybucket mode = list
# List keys all options
- s3 : bucket = mybucket mode = list prefix = / my / desired / marker = / my / desired / 0023. txt max_keys = 472
2013-07-04 16:55:06 +02:00
# Create an empty bucket
2015-08-19 20:30:21 +02:00
- s3 : bucket = mybucket mode = create permission = public - read
2014-12-01 21:14:57 +01:00
# Create a bucket with key as directory, in the EU region
- s3 : bucket = mybucket object = / my / directory / path mode = create region = eu - west - 1
2013-07-04 16:55:06 +02:00
# Delete a bucket and all contents
- s3 : bucket = mybucket mode = delete
2015-05-14 05:33:50 +02:00
2015-12-31 02:04:41 +01:00
# GET an object but dont download if the file checksums match. New in 2.0
2015-05-14 05:33:50 +02:00
- s3 : bucket = mybucket object = / my / desired / key . txt dest = / usr / local / myfile . txt mode = get overwrite = different
2015-06-11 15:43:15 +02:00
# Delete an object from a bucket
- s3 : bucket = mybucket object = / my / desired / key . txt mode = delobj
2013-04-26 04:22:48 +02:00
'''
2013-03-16 12:18:43 +01:00
import os
import urlparse
feature pull request: catch and retry recoverable errors
boto can throw SSLError when timeouts occur (among other SSL errors). Catch these so proper JSON can be returned, and also add the ability to retry the operation.
There's an open issue in boto for this: https://github.com/boto/boto/issues/2409
Here's a sample stacktrace that inspired me to work on this. I'm on 1.7, but there's no meaningful differences in the 1.8 release that would affect this. I've added line breaks to the trace for readability.
failed to parse: Traceback (most recent call last):
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 2031, in <module> main()
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 353, in main download_s3file(module, s3, bucket, obj, dest)
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 234, in download_s3file key.get_contents_to_filename(dest)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1665, in get_contents_to_filename response_headers=response_headers)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1603, in get_contents_to_file response_headers=response_headers)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1435, in get_file query_args=None)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1488, in _get_file_internal for bytes in self:
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 368, in next data = self.resp.read(self.BufferSize)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 416, in read return httplib.HTTPResponse.read(self, amt)
File "/usr/lib/python2.7/httplib.py", line 567, in read s = self.fp.read(amt)
File "/usr/lib/python2.7/socket.py", line 380, in read data = self._sock.recv(left)
File "/usr/lib/python2.7/ssl.py", line 341, in recv return self.read(buflen)
File "/usr/lib/python2.7/ssl.py", line 260, in read return self._sslobj.read(len) ssl.SSLError: The read operation timed out
2014-12-30 01:38:08 +01:00
from ssl import SSLError
2013-03-16 12:18:43 +01:00
try :
import boto
2014-10-31 15:46:32 +01:00
import boto . ec2
2014-09-09 00:59:24 +02:00
from boto . s3 . connection import Location
2015-04-02 01:16:54 +02:00
from boto . s3 . connection import OrdinaryCallingFormat
2014-12-25 01:04:25 +01:00
from boto . s3 . connection import S3Connection
2015-09-08 12:00:37 +02:00
from boto . s3 . acl import CannedACLStrings
2015-04-02 01:16:54 +02:00
HAS_BOTO = True
2013-03-16 12:18:43 +01:00
except ImportError :
2015-04-02 01:16:54 +02:00
HAS_BOTO = False
2015-05-14 14:47:07 +02:00
def key_check ( module , s3 , bucket , obj , version = None ) :
2013-07-04 16:55:06 +02:00
try :
bucket = s3 . lookup ( bucket )
2015-05-14 14:47:07 +02:00
key_check = bucket . get_key ( obj , version_id = version )
2013-07-04 16:55:06 +02:00
except s3 . provider . storage_response_error , e :
2015-05-14 14:47:07 +02:00
if version is not None and e . status == 400 : # If a specified version doesn't exist a 400 is returned.
key_check = None
else :
module . fail_json ( msg = str ( e ) )
2013-07-04 16:55:06 +02:00
if key_check :
return True
else :
return False
2015-05-14 14:47:07 +02:00
def keysum ( module , s3 , bucket , obj , version = None ) :
2013-07-04 16:55:06 +02:00
bucket = s3 . lookup ( bucket )
2015-05-14 14:47:07 +02:00
key_check = bucket . get_key ( obj , version_id = version )
2014-03-28 21:47:46 +01:00
if not key_check :
return None
md5_remote = key_check . etag [ 1 : - 1 ]
etag_multipart = ' - ' in md5_remote # Check for multipart, etag is not md5
if etag_multipart is True :
module . fail_json ( msg = " Files uploaded with multipart of s3 are not supported with checksum, unable to compute checksum. " )
2013-07-04 16:55:06 +02:00
return md5_remote
def bucket_check ( module , s3 , bucket ) :
try :
result = s3 . lookup ( bucket )
except s3 . provider . storage_response_error , e :
module . fail_json ( msg = str ( e ) )
if result :
return True
else :
return False
2015-04-24 17:03:36 +02:00
def create_bucket ( module , s3 , bucket , location = None ) :
if location is None :
location = Location . DEFAULT
2013-07-04 16:55:06 +02:00
try :
2014-09-09 00:59:24 +02:00
bucket = s3 . create_bucket ( bucket , location = location )
2015-09-08 12:00:37 +02:00
for acl in module . params . get ( ' permission ' ) :
bucket . set_acl ( acl )
2013-07-04 16:55:06 +02:00
except s3 . provider . storage_response_error , e :
module . fail_json ( msg = str ( e ) )
if bucket :
return True
2014-11-15 01:07:29 +01:00
def get_bucket ( module , s3 , bucket ) :
try :
return s3 . lookup ( bucket )
except s3 . provider . storage_response_error , e :
module . fail_json ( msg = str ( e ) )
def list_keys ( module , bucket_object , prefix , marker , max_keys ) :
all_keys = bucket_object . get_all_keys ( prefix = prefix , marker = marker , max_keys = max_keys )
2015-06-25 19:37:17 +02:00
keys = [ x . key for x in all_keys ]
2014-11-15 01:07:29 +01:00
module . exit_json ( msg = " LIST operation complete " , s3_keys = keys )
2013-07-04 16:55:06 +02:00
def delete_bucket ( module , s3 , bucket ) :
try :
bucket = s3 . lookup ( bucket )
bucket_contents = bucket . list ( )
bucket . delete_keys ( [ key . name for key in bucket_contents ] )
bucket . delete ( )
return True
except s3 . provider . storage_response_error , e :
module . fail_json ( msg = str ( e ) )
def delete_key ( module , s3 , bucket , obj ) :
try :
bucket = s3 . lookup ( bucket )
bucket . delete_key ( obj )
module . exit_json ( msg = " Object deleted from bucket %s " % bucket , changed = True )
except s3 . provider . storage_response_error , e :
module . fail_json ( msg = str ( e ) )
2015-03-28 15:17:12 +01:00
2013-07-31 12:51:57 +02:00
def create_dirkey ( module , s3 , bucket , obj ) :
2013-07-04 16:55:06 +02:00
try :
bucket = s3 . lookup ( bucket )
2013-07-31 12:51:57 +02:00
key = bucket . new_key ( obj )
key . set_contents_from_string ( ' ' )
module . exit_json ( msg = " Virtual directory %s created in bucket %s " % ( obj , bucket . name ) , changed = True )
2013-07-04 16:55:06 +02:00
except s3 . provider . storage_response_error , e :
module . fail_json ( msg = str ( e ) )
def path_check ( path ) :
if os . path . exists ( path ) :
2015-03-28 15:17:12 +01:00
return True
2013-07-04 16:55:06 +02:00
else :
return False
2015-02-24 19:24:23 +01:00
2015-06-30 15:04:15 +02:00
def upload_s3file ( module , s3 , bucket , obj , src , expiry , metadata , encrypt , headers ) :
2013-04-02 19:19:11 +02:00
try :
2013-07-04 16:55:06 +02:00
bucket = s3 . lookup ( bucket )
2013-11-01 15:23:01 +01:00
key = bucket . new_key ( obj )
if metadata :
for meta_key in metadata . keys ( ) :
key . set_metadata ( meta_key , metadata [ meta_key ] )
2015-06-30 15:04:15 +02:00
key . set_contents_from_filename ( src , encrypt_key = encrypt , headers = headers )
2015-09-08 12:00:37 +02:00
for acl in module . params . get ( ' permission ' ) :
key . set_acl ( acl )
2013-04-02 19:19:11 +02:00
url = key . generate_url ( expiry )
2013-07-04 16:55:06 +02:00
module . exit_json ( msg = " PUT operation complete " , url = url , changed = True )
except s3 . provider . storage_copy_error , e :
module . fail_json ( msg = str ( e ) )
2015-05-14 14:47:07 +02:00
def download_s3file ( module , s3 , bucket , obj , dest , retries , version = None ) :
feature pull request: catch and retry recoverable errors
boto can throw SSLError when timeouts occur (among other SSL errors). Catch these so proper JSON can be returned, and also add the ability to retry the operation.
There's an open issue in boto for this: https://github.com/boto/boto/issues/2409
Here's a sample stacktrace that inspired me to work on this. I'm on 1.7, but there's no meaningful differences in the 1.8 release that would affect this. I've added line breaks to the trace for readability.
failed to parse: Traceback (most recent call last):
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 2031, in <module> main()
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 353, in main download_s3file(module, s3, bucket, obj, dest)
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 234, in download_s3file key.get_contents_to_filename(dest)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1665, in get_contents_to_filename response_headers=response_headers)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1603, in get_contents_to_file response_headers=response_headers)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1435, in get_file query_args=None)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1488, in _get_file_internal for bytes in self:
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 368, in next data = self.resp.read(self.BufferSize)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 416, in read return httplib.HTTPResponse.read(self, amt)
File "/usr/lib/python2.7/httplib.py", line 567, in read s = self.fp.read(amt)
File "/usr/lib/python2.7/socket.py", line 380, in read data = self._sock.recv(left)
File "/usr/lib/python2.7/ssl.py", line 341, in recv return self.read(buflen)
File "/usr/lib/python2.7/ssl.py", line 260, in read return self._sslobj.read(len) ssl.SSLError: The read operation timed out
2014-12-30 01:38:08 +01:00
# retries is the number of loops; range/xrange needs to be one
# more to get that count of loops.
bucket = s3 . lookup ( bucket )
2015-05-14 14:47:07 +02:00
key = bucket . get_key ( obj , version_id = version )
2015-05-27 16:03:29 +02:00
for x in range ( 0 , retries + 1 ) :
feature pull request: catch and retry recoverable errors
boto can throw SSLError when timeouts occur (among other SSL errors). Catch these so proper JSON can be returned, and also add the ability to retry the operation.
There's an open issue in boto for this: https://github.com/boto/boto/issues/2409
Here's a sample stacktrace that inspired me to work on this. I'm on 1.7, but there's no meaningful differences in the 1.8 release that would affect this. I've added line breaks to the trace for readability.
failed to parse: Traceback (most recent call last):
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 2031, in <module> main()
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 353, in main download_s3file(module, s3, bucket, obj, dest)
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 234, in download_s3file key.get_contents_to_filename(dest)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1665, in get_contents_to_filename response_headers=response_headers)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1603, in get_contents_to_file response_headers=response_headers)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1435, in get_file query_args=None)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1488, in _get_file_internal for bytes in self:
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 368, in next data = self.resp.read(self.BufferSize)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 416, in read return httplib.HTTPResponse.read(self, amt)
File "/usr/lib/python2.7/httplib.py", line 567, in read s = self.fp.read(amt)
File "/usr/lib/python2.7/socket.py", line 380, in read data = self._sock.recv(left)
File "/usr/lib/python2.7/ssl.py", line 341, in recv return self.read(buflen)
File "/usr/lib/python2.7/ssl.py", line 260, in read return self._sslobj.read(len) ssl.SSLError: The read operation timed out
2014-12-30 01:38:08 +01:00
try :
key . get_contents_to_filename ( dest )
module . exit_json ( msg = " GET operation complete " , changed = True )
except s3 . provider . storage_copy_error , e :
module . fail_json ( msg = str ( e ) )
except SSLError as e :
# actually fail on last pass through the loop.
2015-05-27 16:03:29 +02:00
if x > = retries :
feature pull request: catch and retry recoverable errors
boto can throw SSLError when timeouts occur (among other SSL errors). Catch these so proper JSON can be returned, and also add the ability to retry the operation.
There's an open issue in boto for this: https://github.com/boto/boto/issues/2409
Here's a sample stacktrace that inspired me to work on this. I'm on 1.7, but there's no meaningful differences in the 1.8 release that would affect this. I've added line breaks to the trace for readability.
failed to parse: Traceback (most recent call last):
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 2031, in <module> main()
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 353, in main download_s3file(module, s3, bucket, obj, dest)
File "/home/ubuntu/.ansible/tmp/ansible-tmp-1419895753.17-160808281985012/s3", line 234, in download_s3file key.get_contents_to_filename(dest)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1665, in get_contents_to_filename response_headers=response_headers)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1603, in get_contents_to_file response_headers=response_headers)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1435, in get_file query_args=None)
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 1488, in _get_file_internal for bytes in self:
File "/usr/local/lib/python2.7/dist-packages/boto/s3/key.py", line 368, in next data = self.resp.read(self.BufferSize)
File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 416, in read return httplib.HTTPResponse.read(self, amt)
File "/usr/lib/python2.7/httplib.py", line 567, in read s = self.fp.read(amt)
File "/usr/lib/python2.7/socket.py", line 380, in read data = self._sock.recv(left)
File "/usr/lib/python2.7/ssl.py", line 341, in recv return self.read(buflen)
File "/usr/lib/python2.7/ssl.py", line 260, in read return self._sslobj.read(len) ssl.SSLError: The read operation timed out
2014-12-30 01:38:08 +01:00
module . fail_json ( msg = " s3 download failed; %s " % e )
# otherwise, try again, this may be a transient timeout.
pass
2013-04-02 19:19:11 +02:00
2015-05-14 14:47:07 +02:00
def download_s3str ( module , s3 , bucket , obj , version = None ) :
2013-07-23 03:03:00 +02:00
try :
bucket = s3 . lookup ( bucket )
2015-05-14 14:47:07 +02:00
key = bucket . get_key ( obj , version_id = version )
2013-07-23 03:03:00 +02:00
contents = key . get_contents_as_string ( )
module . exit_json ( msg = " GET operation complete " , contents = contents , changed = True )
except s3 . provider . storage_copy_error , e :
module . fail_json ( msg = str ( e ) )
2013-10-09 18:10:33 +02:00
def get_download_url ( module , s3 , bucket , obj , expiry , changed = True ) :
2013-07-04 16:55:06 +02:00
try :
bucket = s3 . lookup ( bucket )
key = bucket . lookup ( obj )
url = key . generate_url ( expiry )
2013-10-09 18:10:33 +02:00
module . exit_json ( msg = " Download url: " , url = url , expiry = expiry , changed = changed )
2013-07-04 16:55:06 +02:00
except s3 . provider . storage_response_error , e :
module . fail_json ( msg = str ( e ) )
2014-01-21 11:27:50 +01:00
def is_fakes3 ( s3_url ) :
""" Return True if s3_url has scheme fakes3:// """
if s3_url is not None :
2014-11-04 09:52:43 +01:00
return urlparse . urlparse ( s3_url ) . scheme in ( ' fakes3 ' , ' fakes3s ' )
2014-01-21 11:27:50 +01:00
else :
return False
2013-10-16 19:19:01 +02:00
def is_walrus ( s3_url ) :
""" Return True if it ' s Walrus endpoint, not S3
We assume anything other than * . amazonaws . com is Walrus """
if s3_url is not None :
o = urlparse . urlparse ( s3_url )
return not o . hostname . endswith ( ' amazonaws.com ' )
else :
return False
2015-02-24 19:24:23 +01:00
2013-03-16 12:18:43 +01:00
def main ( ) :
2014-03-12 01:19:03 +01:00
argument_spec = ec2_argument_spec ( )
2014-02-09 00:35:26 +01:00
argument_spec . update ( dict (
2013-07-04 16:55:06 +02:00
bucket = dict ( required = True ) ,
2013-10-02 09:57:54 +02:00
dest = dict ( default = None ) ,
2015-02-24 19:24:23 +01:00
encrypt = dict ( default = True , type = ' bool ' ) ,
2013-06-01 18:09:04 +02:00
expiry = dict ( default = 600 , aliases = [ ' expiration ' ] ) ,
2015-06-30 15:04:15 +02:00
headers = dict ( type = ' dict ' ) ,
2014-11-15 01:07:29 +01:00
marker = dict ( default = None ) ,
max_keys = dict ( default = 1000 ) ,
2015-05-14 05:33:50 +02:00
metadata = dict ( type = ' dict ' ) ,
2014-11-15 01:07:29 +01:00
mode = dict ( choices = [ ' get ' , ' put ' , ' delete ' , ' create ' , ' geturl ' , ' getstr ' , ' delobj ' , ' list ' ] , required = True ) ,
2015-02-24 19:24:23 +01:00
object = dict ( ) ,
2015-09-08 12:00:37 +02:00
permission = dict ( type = ' list ' , default = [ ' private ' ] ) ,
2015-05-14 14:47:07 +02:00
version = dict ( default = None ) ,
2015-02-24 19:24:23 +01:00
overwrite = dict ( aliases = [ ' force ' ] , default = ' always ' ) ,
2014-11-15 01:07:29 +01:00
prefix = dict ( default = None ) ,
2015-05-27 16:03:29 +02:00
retries = dict ( aliases = [ ' retry ' ] , type = ' int ' , default = 0 ) ,
2015-02-24 19:24:23 +01:00
s3_url = dict ( aliases = [ ' S3_URL ' ] ) ,
src = dict ( ) ,
2013-11-01 15:23:01 +01:00
) ,
2013-03-16 12:18:43 +01:00
)
2014-02-09 00:35:26 +01:00
module = AnsibleModule ( argument_spec = argument_spec )
2013-03-16 12:18:43 +01:00
2015-04-02 01:16:54 +02:00
if not HAS_BOTO :
module . fail_json ( msg = ' boto required for this module ' )
2013-07-04 16:55:06 +02:00
bucket = module . params . get ( ' bucket ' )
2015-02-24 19:24:23 +01:00
encrypt = module . params . get ( ' encrypt ' )
expiry = int ( module . params [ ' expiry ' ] )
2013-10-02 09:57:54 +02:00
if module . params . get ( ' dest ' ) :
dest = os . path . expanduser ( module . params . get ( ' dest ' ) )
2015-06-30 15:04:15 +02:00
headers = module . params . get ( ' headers ' )
2014-11-15 01:07:29 +01:00
marker = module . params . get ( ' marker ' )
max_keys = module . params . get ( ' max_keys ' )
2015-02-24 19:24:23 +01:00
metadata = module . params . get ( ' metadata ' )
2013-07-04 16:55:06 +02:00
mode = module . params . get ( ' mode ' )
2015-02-24 19:24:23 +01:00
obj = module . params . get ( ' object ' )
2015-05-14 14:47:07 +02:00
version = module . params . get ( ' version ' )
2013-06-01 18:09:04 +02:00
overwrite = module . params . get ( ' overwrite ' )
2014-11-15 01:07:29 +01:00
prefix = module . params . get ( ' prefix ' )
2015-05-27 16:03:29 +02:00
retries = module . params . get ( ' retries ' )
2015-02-24 19:24:23 +01:00
s3_url = module . params . get ( ' s3_url ' )
src = module . params . get ( ' src ' )
2013-11-12 20:13:05 +01:00
2015-09-08 12:00:37 +02:00
for acl in module . params . get ( ' permission ' ) :
if acl not in CannedACLStrings :
module . fail_json ( msg = ' Unknown permission specified: %s ' % str ( acl ) )
2015-10-14 21:54:04 +02:00
if overwrite not in [ ' always ' , ' never ' , ' different ' ] :
2015-06-30 15:04:15 +02:00
if module . boolean ( overwrite ) :
overwrite = ' always '
else :
2015-10-14 21:54:04 +02:00
overwrite = ' never '
2015-05-14 05:33:50 +02:00
2014-12-25 01:04:25 +01:00
region , ec2_url , aws_connect_kwargs = get_aws_connection_info ( module )
2014-09-09 00:59:24 +02:00
if region in ( ' us-east-1 ' , ' ' , None ) :
# S3ism for the US Standard region
location = Location . DEFAULT
else :
# Boto uses symbolic names for locations but region strings will
# actually work fine for everything except us-east-1 (US Standard)
location = region
2013-07-04 16:55:06 +02:00
if module . params . get ( ' object ' ) :
obj = os . path . expanduser ( module . params [ ' object ' ] )
2013-03-16 12:18:43 +01:00
# allow eucarc environment variables to be used if ansible vars aren't set
if not s3_url and ' S3_URL ' in os . environ :
s3_url = os . environ [ ' S3_URL ' ]
2013-08-13 15:30:56 +02:00
2015-07-30 19:46:42 +02:00
# bucket names with .'s in them need to use the calling_format option,
# otherwise the connection will fail. See https://github.com/boto/boto/issues/2836
# for more details.
if ' . ' in bucket :
aws_connect_kwargs [ ' calling_format ' ] = OrdinaryCallingFormat ( )
2014-01-21 11:27:50 +01:00
# Look at s3_url and tweak connection settings
# if connecting to Walrus or fakes3
2015-03-26 02:40:13 +01:00
try :
if is_fakes3 ( s3_url ) :
2014-01-21 11:27:50 +01:00
fakes3 = urlparse . urlparse ( s3_url )
2014-12-25 01:04:25 +01:00
s3 = S3Connection (
2014-11-04 09:52:43 +01:00
is_secure = fakes3 . scheme == ' fakes3s ' ,
2014-01-21 11:27:50 +01:00
host = fakes3 . hostname ,
port = fakes3 . port ,
2014-12-25 01:04:25 +01:00
calling_format = OrdinaryCallingFormat ( ) ,
* * aws_connect_kwargs
)
2015-03-26 02:40:13 +01:00
elif is_walrus ( s3_url ) :
2013-03-16 12:18:43 +01:00
walrus = urlparse . urlparse ( s3_url ) . hostname
2015-03-30 05:56:44 +02:00
s3 = boto . connect_walrus ( walrus , * * aws_connect_kwargs )
2015-03-26 02:40:13 +01:00
else :
2015-07-30 19:46:42 +02:00
s3 = boto . s3 . connect_to_region ( location , is_secure = True , * * aws_connect_kwargs )
2015-03-26 16:23:32 +01:00
# use this as fallback because connect_to_region seems to fail in boto + non 'classic' aws accounts in some cases
if s3 is None :
2015-03-30 05:56:44 +02:00
s3 = boto . connect_s3 ( * * aws_connect_kwargs )
2015-03-26 16:23:32 +01:00
2015-03-26 02:40:13 +01:00
except boto . exception . NoAuthHandlerFound , e :
module . fail_json ( msg = ' No Authentication Handler found: %s ' % str ( e ) )
except Exception , e :
module . fail_json ( msg = ' Failed to connect to S3: %s ' % str ( e ) )
if s3 is None : # this should never happen
module . fail_json ( msg = ' Unknown error, failed to create s3 connection, no information from boto. ' )
2015-03-03 02:12:54 +01:00
2013-07-04 16:55:06 +02:00
# If our mode is a GET operation (download), go through the procedure as appropriate ...
if mode == ' get ' :
2015-03-03 02:12:54 +01:00
2013-07-04 16:55:06 +02:00
# First, we check to see if the bucket exists, we get "bucket" returned.
bucketrtn = bucket_check ( module , s3 , bucket )
if bucketrtn is False :
2015-09-14 15:57:48 +02:00
module . fail_json ( msg = " Source bucket cannot be found " , failed = True )
2013-03-16 12:18:43 +01:00
2013-07-04 16:55:06 +02:00
# Next, we check to see if the key in the bucket exists. If it exists, it also returns key_matches md5sum check.
2015-05-14 14:47:07 +02:00
keyrtn = key_check ( module , s3 , bucket , obj , version = version )
2013-07-04 16:55:06 +02:00
if keyrtn is False :
2015-05-14 14:47:07 +02:00
if version is not None :
module . fail_json ( msg = " Key %s with version id %s does not exist. " % ( obj , version ) , failed = True )
else :
module . fail_json ( msg = " Key %s does not exist. " % obj , failed = True )
2013-03-16 12:18:43 +01:00
2015-07-24 15:38:11 +02:00
# If the destination path doesn't exist or overwrite is True, no need to do the md5um etag check, so just download.
2013-07-04 16:55:06 +02:00
pathrtn = path_check ( dest )
2015-07-24 15:38:11 +02:00
if pathrtn is False or overwrite == ' always ' :
2015-07-30 20:49:16 +02:00
download_s3file ( module , s3 , bucket , obj , dest , retries , version = version )
2013-05-02 21:27:12 +02:00
2015-03-28 15:17:12 +01:00
# Compare the remote MD5 sum of the object with the local dest md5sum, if it already exists.
2013-07-04 16:55:06 +02:00
if pathrtn is True :
2015-05-14 14:47:07 +02:00
md5_remote = keysum ( module , s3 , bucket , obj , version = version )
2014-11-14 02:58:00 +01:00
md5_local = module . md5 ( dest )
2013-07-04 16:55:06 +02:00
if md5_local == md5_remote :
sum_matches = True
2015-05-14 05:33:50 +02:00
if overwrite == ' always ' :
2015-05-14 14:47:07 +02:00
download_s3file ( module , s3 , bucket , obj , dest , retries , version = version )
2013-07-04 16:55:06 +02:00
else :
2015-05-14 05:33:50 +02:00
module . exit_json ( msg = " Local and remote object are identical, ignoring. Use overwrite=always parameter to force. " , changed = False )
2013-03-16 12:18:43 +01:00
else :
2013-07-04 16:55:06 +02:00
sum_matches = False
2015-05-14 14:47:07 +02:00
2015-05-14 05:33:50 +02:00
if overwrite in ( ' always ' , ' different ' ) :
2015-05-14 14:47:07 +02:00
download_s3file ( module , s3 , bucket , obj , dest , retries , version = version )
2013-07-04 16:55:06 +02:00
else :
2015-03-11 16:59:38 +01:00
module . exit_json ( msg = " WARNING: Checksums do not match. Use overwrite parameter to force download. " )
2015-03-28 15:17:12 +01:00
# Firstly, if key_matches is TRUE and overwrite is not enabled, we EXIT with a helpful message.
2015-05-14 05:33:50 +02:00
if sum_matches is True and overwrite == ' never ' :
2013-07-04 16:55:06 +02:00
module . exit_json ( msg = " Local and remote object are identical, ignoring. Use overwrite parameter to force. " , changed = False )
2015-03-11 16:59:38 +01:00
# if our mode is a PUT operation (upload), go through the procedure as appropriate ...
2013-07-04 16:55:06 +02:00
if mode == ' put ' :
2013-04-02 19:19:11 +02:00
2013-07-04 16:55:06 +02:00
# Use this snippet to debug through conditionals:
# module.exit_json(msg="Bucket return %s"%bucketrtn)
2013-04-02 19:19:11 +02:00
2013-07-04 16:55:06 +02:00
# Lets check the src path.
pathrtn = path_check ( src )
if pathrtn is False :
module . fail_json ( msg = " Local object for PUT does not exist " , failed = True )
2015-03-11 16:59:38 +01:00
2013-07-04 16:55:06 +02:00
# Lets check to see if bucket exists to get ground truth.
bucketrtn = bucket_check ( module , s3 , bucket )
2013-10-11 17:01:54 +02:00
if bucketrtn is True :
keyrtn = key_check ( module , s3 , bucket , obj )
2013-07-04 16:55:06 +02:00
# Lets check key state. Does it exist and if it does, compute the etag md5sum.
if bucketrtn is True and keyrtn is True :
md5_remote = keysum ( module , s3 , bucket , obj )
2014-11-14 02:58:00 +01:00
md5_local = module . md5 ( src )
2015-06-04 08:28:57 +02:00
2013-07-04 16:55:06 +02:00
if md5_local == md5_remote :
sum_matches = True
2015-05-14 05:33:50 +02:00
if overwrite == ' always ' :
2015-06-30 15:04:15 +02:00
upload_s3file ( module , s3 , bucket , obj , src , expiry , metadata , encrypt , headers )
2013-07-04 16:55:06 +02:00
else :
2013-10-09 18:25:09 +02:00
get_download_url ( module , s3 , bucket , obj , expiry , changed = False )
2013-07-04 16:55:06 +02:00
else :
sum_matches = False
2015-05-14 05:33:50 +02:00
if overwrite in ( ' always ' , ' different ' ) :
2015-06-30 15:04:15 +02:00
upload_s3file ( module , s3 , bucket , obj , src , expiry , metadata , encrypt , headers )
2013-07-04 16:55:06 +02:00
else :
2015-03-11 16:59:38 +01:00
module . exit_json ( msg = " WARNING: Checksums do not match. Use overwrite parameter to force upload. " )
2014-09-09 00:59:24 +02:00
2013-07-04 16:55:06 +02:00
# If neither exist (based on bucket existence), we can create both.
2014-09-09 00:59:24 +02:00
if bucketrtn is False and pathrtn is True :
create_bucket ( module , s3 , bucket , location )
2015-06-30 15:04:15 +02:00
upload_s3file ( module , s3 , bucket , obj , src , expiry , metadata , encrypt , headers )
2013-03-16 12:18:43 +01:00
2013-07-04 16:55:06 +02:00
# If bucket exists but key doesn't, just upload.
if bucketrtn is True and pathrtn is True and keyrtn is False :
2015-06-30 15:04:15 +02:00
upload_s3file ( module , s3 , bucket , obj , src , expiry , metadata , encrypt , headers )
2014-09-09 00:59:24 +02:00
2015-06-11 15:43:15 +02:00
# Delete an object from a bucket, not the entire bucket
if mode == ' delobj ' :
if obj is None :
module . fail_json ( msg = " object parameter is required " , failed = True ) ;
if bucket :
bucketrtn = bucket_check ( module , s3 , bucket )
if bucketrtn is True :
deletertn = delete_key ( module , s3 , bucket , obj )
if deletertn is True :
module . exit_json ( msg = " Object %s deleted from bucket %s . " % ( obj , bucket ) , changed = True )
else :
module . fail_json ( msg = " Bucket does not exist. " , changed = False )
else :
module . fail_json ( msg = " Bucket parameter is required. " , failed = True )
# Delete an entire bucket, including all objects in the bucket
2013-07-04 16:55:06 +02:00
if mode == ' delete ' :
if bucket :
bucketrtn = bucket_check ( module , s3 , bucket )
if bucketrtn is True :
deletertn = delete_bucket ( module , s3 , bucket )
if deletertn is True :
module . exit_json ( msg = " Bucket %s and all keys have been deleted. " % bucket , changed = True )
else :
2013-10-07 14:59:03 +02:00
module . fail_json ( msg = " Bucket does not exist. " , changed = False )
2013-03-16 12:18:43 +01:00
else :
2013-07-04 16:55:06 +02:00
module . fail_json ( msg = " Bucket parameter is required. " , failed = True )
2015-03-28 15:17:12 +01:00
2014-11-15 01:07:29 +01:00
# Support for listing a set of keys
if mode == ' list ' :
bucket_object = get_bucket ( module , s3 , bucket )
# If the bucket does not exist then bail out
if bucket_object is None :
module . fail_json ( msg = " Target bucket ( %s ) cannot be found " % bucket , failed = True )
list_keys ( module , bucket_object , prefix , marker , max_keys )
2013-07-04 16:55:06 +02:00
# Need to research how to create directories without "populating" a key, so this should just do bucket creation for now.
# WE SHOULD ENABLE SOME WAY OF CREATING AN EMPTY KEY TO CREATE "DIRECTORY" STRUCTURE, AWS CONSOLE DOES THIS.
if mode == ' create ' :
2015-03-28 15:17:12 +01:00
if bucket and not obj :
2013-07-04 16:55:06 +02:00
bucketrtn = bucket_check ( module , s3 , bucket )
if bucketrtn is True :
module . exit_json ( msg = " Bucket already exists. " , changed = False )
else :
2014-09-09 00:59:24 +02:00
module . exit_json ( msg = " Bucket created successfully " , changed = create_bucket ( module , s3 , bucket , location ) )
2013-07-04 16:55:06 +02:00
if bucket and obj :
2013-07-31 12:51:57 +02:00
bucketrtn = bucket_check ( module , s3 , bucket )
if obj . endswith ( ' / ' ) :
dirobj = obj
else :
dirobj = obj + " / "
if bucketrtn is True :
keyrtn = key_check ( module , s3 , bucket , dirobj )
2015-03-28 15:17:12 +01:00
if keyrtn is True :
2013-07-31 12:51:57 +02:00
module . exit_json ( msg = " Bucket %s and key %s already exists. " % ( bucket , obj ) , changed = False )
2015-03-28 15:17:12 +01:00
else :
2013-07-31 12:51:57 +02:00
create_dirkey ( module , s3 , bucket , dirobj )
if bucketrtn is False :
2014-09-09 00:59:24 +02:00
created = create_bucket ( module , s3 , bucket , location )
2013-07-31 12:51:57 +02:00
create_dirkey ( module , s3 , bucket , dirobj )
2013-07-04 16:55:06 +02:00
# Support for grabbing the time-expired URL for an object in S3/Walrus.
if mode == ' geturl ' :
if bucket and obj :
bucketrtn = bucket_check ( module , s3 , bucket )
if bucketrtn is False :
module . fail_json ( msg = " Bucket %s does not exist. " % bucket , failed = True )
else :
keyrtn = key_check ( module , s3 , bucket , obj )
if keyrtn is True :
get_download_url ( module , s3 , bucket , obj , expiry )
else :
module . fail_json ( msg = " Key %s does not exist. " % obj , failed = True )
else :
module . fail_json ( msg = " Bucket and Object parameters must be set " , failed = True )
2013-04-02 19:19:11 +02:00
2013-07-23 03:03:00 +02:00
if mode == ' getstr ' :
if bucket and obj :
bucketrtn = bucket_check ( module , s3 , bucket )
if bucketrtn is False :
module . fail_json ( msg = " Bucket %s does not exist. " % bucket , failed = True )
else :
2015-05-14 14:47:07 +02:00
keyrtn = key_check ( module , s3 , bucket , obj , version = version )
2013-07-23 03:03:00 +02:00
if keyrtn is True :
2015-05-14 14:47:07 +02:00
download_s3str ( module , s3 , bucket , obj , version = version )
2013-07-23 03:03:00 +02:00
else :
2015-05-14 14:47:07 +02:00
if version is not None :
module . fail_json ( msg = " Key %s with version id %s does not exist. " % ( obj , version ) , failed = True )
else :
module . fail_json ( msg = " Key %s does not exist. " % obj , failed = True )
2013-07-23 03:03:00 +02:00
2013-10-11 17:28:47 +02:00
module . exit_json ( failed = False )
2013-11-12 20:13:05 +01:00
# import module snippets
from ansible . module_utils . basic import *
from ansible . module_utils . ec2 import *
2013-03-16 12:18:43 +01:00
main ( )