Add support for S3 canned permissions. resolves #1939
This commit is contained in:
parent
f2c1eeb54c
commit
2c511a9470
1 changed files with 10 additions and 1 deletions
|
@ -93,6 +93,12 @@ options:
|
||||||
- Keyname of the object inside the bucket. Can be used to create "virtual directories", see examples.
|
- Keyname of the object inside the bucket. Can be used to create "virtual directories", see examples.
|
||||||
required: false
|
required: false
|
||||||
default: null
|
default: null
|
||||||
|
permission:
|
||||||
|
description:
|
||||||
|
- 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'.
|
||||||
|
required: false
|
||||||
|
default: private
|
||||||
|
version_added: "2.0"
|
||||||
prefix:
|
prefix:
|
||||||
description:
|
description:
|
||||||
- Limits the response to keys that begin with the specified prefix for list mode
|
- Limits the response to keys that begin with the specified prefix for list mode
|
||||||
|
@ -167,7 +173,7 @@ EXAMPLES = '''
|
||||||
- s3: bucket=mybucket mode=list prefix=/my/desired/ marker=/my/desired/0023.txt max_keys=472
|
- s3: bucket=mybucket mode=list prefix=/my/desired/ marker=/my/desired/0023.txt max_keys=472
|
||||||
|
|
||||||
# Create an empty bucket
|
# Create an empty bucket
|
||||||
- s3: bucket=mybucket mode=create
|
- s3: bucket=mybucket mode=create permission=public-read
|
||||||
|
|
||||||
# Create a bucket with key as directory, in the EU region
|
# Create a bucket with key as directory, in the EU region
|
||||||
- s3: bucket=mybucket object=/my/directory/path mode=create region=eu-west-1
|
- s3: bucket=mybucket object=/my/directory/path mode=create region=eu-west-1
|
||||||
|
@ -236,6 +242,7 @@ def create_bucket(module, s3, bucket, location=None):
|
||||||
location = Location.DEFAULT
|
location = Location.DEFAULT
|
||||||
try:
|
try:
|
||||||
bucket = s3.create_bucket(bucket, location=location)
|
bucket = s3.create_bucket(bucket, location=location)
|
||||||
|
bucket.set_acl(module.params.get('permission'))
|
||||||
except s3.provider.storage_response_error, e:
|
except s3.provider.storage_response_error, e:
|
||||||
module.fail_json(msg= str(e))
|
module.fail_json(msg= str(e))
|
||||||
if bucket:
|
if bucket:
|
||||||
|
@ -306,6 +313,7 @@ def upload_s3file(module, s3, bucket, obj, src, expiry, metadata, encrypt, heade
|
||||||
key.set_metadata(meta_key, metadata[meta_key])
|
key.set_metadata(meta_key, metadata[meta_key])
|
||||||
|
|
||||||
key.set_contents_from_filename(src, encrypt_key=encrypt, headers=headers)
|
key.set_contents_from_filename(src, encrypt_key=encrypt, headers=headers)
|
||||||
|
key.set_acl(module.params.get('permission'))
|
||||||
url = key.generate_url(expiry)
|
url = key.generate_url(expiry)
|
||||||
module.exit_json(msg="PUT operation complete", url=url, changed=True)
|
module.exit_json(msg="PUT operation complete", url=url, changed=True)
|
||||||
except s3.provider.storage_copy_error, e:
|
except s3.provider.storage_copy_error, e:
|
||||||
|
@ -378,6 +386,7 @@ def main():
|
||||||
metadata = dict(type='dict'),
|
metadata = dict(type='dict'),
|
||||||
mode = dict(choices=['get', 'put', 'delete', 'create', 'geturl', 'getstr', 'delobj', 'list'], required=True),
|
mode = dict(choices=['get', 'put', 'delete', 'create', 'geturl', 'getstr', 'delobj', 'list'], required=True),
|
||||||
object = dict(),
|
object = dict(),
|
||||||
|
permission = dict(choices=['private', 'public-read', 'public-read-write', 'authenticated-read'], default='private'),
|
||||||
version = dict(default=None),
|
version = dict(default=None),
|
||||||
overwrite = dict(aliases=['force'], default='always'),
|
overwrite = dict(aliases=['force'], default='always'),
|
||||||
prefix = dict(default=None),
|
prefix = dict(default=None),
|
||||||
|
|
Loading…
Reference in a new issue