Add configuration to make logs public
Change-Id: I5d196623df402bc4eb02bbb13e557da38a849018
This commit is contained in:
parent
9721093097
commit
5f9dcd987f
@ -58,9 +58,10 @@ MAX_UPLOAD_THREADS = 24
|
|||||||
|
|
||||||
|
|
||||||
class Uploader():
|
class Uploader():
|
||||||
def __init__(self, bucket, endpoint=None, prefix=None,
|
def __init__(self, bucket, public, endpoint=None, prefix=None,
|
||||||
dry_run=False, aws_access_key=None, aws_secret_key=None):
|
dry_run=False, aws_access_key=None, aws_secret_key=None):
|
||||||
self.dry_run = dry_run
|
self.dry_run = dry_run
|
||||||
|
self.public = public
|
||||||
if dry_run:
|
if dry_run:
|
||||||
self.url = 'http://dry-run-url.com/a/path/'
|
self.url = 'http://dry-run-url.com/a/path/'
|
||||||
return
|
return
|
||||||
@ -167,17 +168,22 @@ class Uploader():
|
|||||||
# compressed as with .tar.gz tarballs.
|
# compressed as with .tar.gz tarballs.
|
||||||
content_encoding = file_detail.encoding
|
content_encoding = file_detail.encoding
|
||||||
data = open(file_detail.full_path, 'rb')
|
data = open(file_detail.full_path, 'rb')
|
||||||
self.bucket.upload_fileobj(
|
|
||||||
data,
|
extra_args = dict(
|
||||||
relative_path,
|
|
||||||
ExtraArgs=dict(
|
|
||||||
ContentType=file_detail.mimetype,
|
ContentType=file_detail.mimetype,
|
||||||
ContentEncoding=content_encoding
|
ContentEncoding=content_encoding
|
||||||
)
|
)
|
||||||
|
if self.public:
|
||||||
|
extra_args['ACL'] = 'public-read'
|
||||||
|
|
||||||
|
self.bucket.upload_fileobj(
|
||||||
|
data,
|
||||||
|
relative_path,
|
||||||
|
ExtraArgs=extra_args
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def run(bucket, files, endpoint=None,
|
def run(bucket, public, files, endpoint=None,
|
||||||
indexes=True, parent_links=True, topdir_parent_link=False,
|
indexes=True, parent_links=True, topdir_parent_link=False,
|
||||||
partition=False, footer='index_footer.html',
|
partition=False, footer='index_footer.html',
|
||||||
prefix=None, aws_access_key=None, aws_secret_key=None):
|
prefix=None, aws_access_key=None, aws_secret_key=None):
|
||||||
@ -210,6 +216,7 @@ def run(bucket, files, endpoint=None,
|
|||||||
|
|
||||||
# Upload.
|
# Upload.
|
||||||
uploader = Uploader(bucket,
|
uploader = Uploader(bucket,
|
||||||
|
public,
|
||||||
endpoint,
|
endpoint,
|
||||||
prefix,
|
prefix,
|
||||||
aws_access_key=aws_access_key,
|
aws_access_key=aws_access_key,
|
||||||
@ -223,6 +230,7 @@ def ansible_main():
|
|||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
bucket=dict(required=True, type='str'),
|
bucket=dict(required=True, type='str'),
|
||||||
|
public=dict(required=True, type='bool'),
|
||||||
files=dict(required=True, type='list'),
|
files=dict(required=True, type='list'),
|
||||||
partition=dict(type='bool', default=False),
|
partition=dict(type='bool', default=False),
|
||||||
indexes=dict(type='bool', default=True),
|
indexes=dict(type='bool', default=True),
|
||||||
@ -237,7 +245,9 @@ def ansible_main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
p = module.params
|
p = module.params
|
||||||
url, failures = run(p.get('bucket'), p.get('files'),
|
url, failures = run(p.get('bucket'),
|
||||||
|
p.get('public'),
|
||||||
|
p.get('files'),
|
||||||
p.get('endpoint'),
|
p.get('endpoint'),
|
||||||
indexes=p.get('indexes'),
|
indexes=p.get('indexes'),
|
||||||
parent_links=p.get('parent_links'),
|
parent_links=p.get('parent_links'),
|
||||||
@ -264,6 +274,8 @@ def cli_main():
|
|||||||
help='show debug information')
|
help='show debug information')
|
||||||
parser.add_argument('--endpoint',
|
parser.add_argument('--endpoint',
|
||||||
help='http endpoint of s3 service')
|
help='http endpoint of s3 service')
|
||||||
|
parser.add_argument('--no-public', action='store_true',
|
||||||
|
help='do not make logs public')
|
||||||
parser.add_argument('--prefix',
|
parser.add_argument('--prefix',
|
||||||
help='Prepend this path to the object names when '
|
help='Prepend this path to the object names when '
|
||||||
'uploading')
|
'uploading')
|
||||||
@ -280,6 +292,7 @@ def cli_main():
|
|||||||
|
|
||||||
url = run(args.bucket, args.files,
|
url = run(args.bucket, args.files,
|
||||||
prefix=args.prefix,
|
prefix=args.prefix,
|
||||||
|
public=not args.no_public,
|
||||||
endpoint=args.endpoint)
|
endpoint=args.endpoint)
|
||||||
print(url)
|
print(url)
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@ installed in the Ansible environment on the Zuul executor.
|
|||||||
Note that you will want to set this to a value that uniquely
|
Note that you will want to set this to a value that uniquely
|
||||||
identifies your Zuul installation.
|
identifies your Zuul installation.
|
||||||
|
|
||||||
|
.. zuul:rolevar:: zuul_log_bucket_public
|
||||||
|
:default: true
|
||||||
|
|
||||||
|
Set to false to make logs private.
|
||||||
|
|
||||||
.. zuul:rolevar:: zuul_log_path
|
.. zuul:rolevar:: zuul_log_path
|
||||||
:default: Generated by the role `set-zuul-log-path-fact`
|
:default: Generated by the role `set-zuul-log-path-fact`
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
zuul_log_partition: false
|
zuul_log_partition: false
|
||||||
zuul_log_create_indexes: true
|
zuul_log_create_indexes: true
|
||||||
|
zuul_log_bucket_public: true
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
endpoint: "{{ upload_logs_s3_endpoint | default(omit) }}"
|
endpoint: "{{ upload_logs_s3_endpoint | default(omit) }}"
|
||||||
partition: "{{ zuul_log_partition }}"
|
partition: "{{ zuul_log_partition }}"
|
||||||
bucket: "{{ zuul_log_bucket }}"
|
bucket: "{{ zuul_log_bucket }}"
|
||||||
|
public: "{{ zuul_log_bucket_public }}"
|
||||||
prefix: "{{ zuul_log_path }}"
|
prefix: "{{ zuul_log_path }}"
|
||||||
indexes: "{{ zuul_log_create_indexes }}"
|
indexes: "{{ zuul_log_create_indexes }}"
|
||||||
aws_access_key: "{{ zuul_log_aws_access_key }}"
|
aws_access_key: "{{ zuul_log_aws_access_key }}"
|
||||||
|
Loading…
Reference in New Issue
Block a user