mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-04-09 04:10:27 -07:00
This commit is contained in:
parent
8b9a2c70dd
commit
2b35fbf404
3 changed files with 48 additions and 8 deletions
|
@ -92,14 +92,14 @@ options:
|
||||||
type: str
|
type: str
|
||||||
max_duration:
|
max_duration:
|
||||||
description:
|
description:
|
||||||
- Subscription writes a new output file if the specified value of max duration is exceeded. Min: 1m, max: 10m.
|
- Subscription writes a new output file if the specified value of max duration is exceeded. Min: 60s, max: 600s.
|
||||||
required: true
|
required: true
|
||||||
type: str
|
type: str
|
||||||
max_bytes:
|
max_bytes:
|
||||||
description:
|
description:
|
||||||
- Cloud Storage Subscription writes a new output file if the specified value of max bytes is exceeded. Min: 1KB, max: 10GiB.
|
- Cloud Storage Subscription writes a new output file if the specified value of max bytes is exceeded. Min: 1000, max: 10737418240.
|
||||||
required: false
|
required: false
|
||||||
type: str
|
type: int
|
||||||
max_messages:
|
max_messages:
|
||||||
description:
|
description:
|
||||||
- Cloud Storage Subscription writes a new output file if the specified number of messages is exceeded. Min: 1000.
|
- Cloud Storage Subscription writes a new output file if the specified number of messages is exceeded. Min: 1000.
|
||||||
|
@ -643,7 +643,7 @@ def main():
|
||||||
file_suffix=dict(type='str'),
|
file_suffix=dict(type='str'),
|
||||||
file_datetime_format=dict(type='str'),
|
file_datetime_format=dict(type='str'),
|
||||||
max_duration=dict(type='str'),
|
max_duration=dict(type='str'),
|
||||||
max_bytes=dict(type='str'),
|
max_bytes=dict(type='int'),
|
||||||
max_messages=dict(type='int'),
|
max_messages=dict(type='int'),
|
||||||
output_format=dict(type='str'),
|
output_format=dict(type='str'),
|
||||||
write_metadata=dict(type='bool'),
|
write_metadata=dict(type='bool'),
|
||||||
|
@ -999,6 +999,20 @@ class SubscriptionCloudStorageConfig(object):
|
||||||
else {},
|
else {},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
storageConfig = {
|
||||||
|
u'bucket': self.request.get('bucket', {}),
|
||||||
|
u'filenamePrefix': self.request.get('filenamePrefix', {}),
|
||||||
|
u'filenameSuffix': self.request.get('filenameSuffix', {}),
|
||||||
|
u'filenameDatetimeFormat': self.request.get('filenameDatetimeFormat', {}),
|
||||||
|
u'maxDuration': self.request.get('maxDuration', {}),
|
||||||
|
u'maxBytes': self.request.get('maxBytes', {}),
|
||||||
|
u'maxMessages': self.request.get('maxMessages', {}),
|
||||||
|
u'avroConfig': {'writeMetadata': self.request.get('avroConfig', {}).get('writeMetadata', False),
|
||||||
|
'useTopicSchema': self.request.get('avroConfig', {}).get('useTopicSchema', False)}
|
||||||
|
if self.request.get('avroConfig', {})
|
||||||
|
else {},
|
||||||
|
}
|
||||||
|
return remove_nones_from_dict(storageConfig) if self.request else storageConfig
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -32,6 +32,8 @@ SERVICE_LIST=(
|
||||||
|
|
||||||
REQUIRED_ROLE_LIST=(
|
REQUIRED_ROLE_LIST=(
|
||||||
"roles/storage.objectAdmin"
|
"roles/storage.objectAdmin"
|
||||||
|
"roles/storage.legacyBucketReader"
|
||||||
|
"roles/storage.objectCreator"
|
||||||
"roles/source.admin"
|
"roles/source.admin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,13 @@
|
||||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||||
state: present
|
state: present
|
||||||
register: topic
|
register: topic
|
||||||
|
- name: Create a bucket
|
||||||
|
google.cloud.gcp_storage_bucket:
|
||||||
|
name: topic-subscription-bucket
|
||||||
|
project: "{{ gcp_project }}"
|
||||||
|
auth_kind: "{{ gcp_cred_kind }}"
|
||||||
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||||
|
state: present
|
||||||
- name: Delete a subscription
|
- name: Delete a subscription
|
||||||
google.cloud.gcp_pubsub_subscription:
|
google.cloud.gcp_pubsub_subscription:
|
||||||
name: "{{ resource_name }}"
|
name: "{{ resource_name }}"
|
||||||
|
@ -73,11 +80,20 @@
|
||||||
that:
|
that:
|
||||||
- result.changed == false
|
- result.changed == false
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
- name: Update ack_deadline_seconds of a subscription that already exists
|
- name: Update cloudStorageConfig of a subscription that already exists
|
||||||
google.cloud.gcp_pubsub_subscription:
|
google.cloud.gcp_pubsub_subscription:
|
||||||
name: "{{ resource_name }}"
|
name: "{{ resource_name }}"
|
||||||
topic: "{{ topic }}"
|
topic: "{{ topic }}"
|
||||||
ack_deadline_seconds: 500
|
ack_deadline_seconds: 300
|
||||||
|
cloud_storage: {
|
||||||
|
bucket: "topic-subscription-bucket",
|
||||||
|
file_prefix: "test_",
|
||||||
|
file_suffix: "_test",
|
||||||
|
max_bytes: 10737418240,
|
||||||
|
max_duration: "600s",
|
||||||
|
output_format: "avro",
|
||||||
|
write_metadata: true
|
||||||
|
}
|
||||||
project: "{{ gcp_project }}"
|
project: "{{ gcp_project }}"
|
||||||
auth_kind: "{{ gcp_cred_kind }}"
|
auth_kind: "{{ gcp_cred_kind }}"
|
||||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||||
|
@ -92,7 +108,7 @@
|
||||||
google.cloud.gcp_pubsub_subscription:
|
google.cloud.gcp_pubsub_subscription:
|
||||||
name: "{{ resource_name }}"
|
name: "{{ resource_name }}"
|
||||||
topic: "{{ topic }}"
|
topic: "{{ topic }}"
|
||||||
ack_deadline_seconds: 500
|
ack_deadline_seconds: 300
|
||||||
project: "{{ gcp_project }}"
|
project: "{{ gcp_project }}"
|
||||||
auth_kind: "{{ gcp_cred_kind }}"
|
auth_kind: "{{ gcp_cred_kind }}"
|
||||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||||
|
@ -119,7 +135,7 @@
|
||||||
google.cloud.gcp_pubsub_subscription:
|
google.cloud.gcp_pubsub_subscription:
|
||||||
name: "{{ resource_name }}"
|
name: "{{ resource_name }}"
|
||||||
topic: "{{ topic }}"
|
topic: "{{ topic }}"
|
||||||
ack_deadline_seconds: 500
|
ack_deadline_seconds: 300
|
||||||
project: "{{ gcp_project }}"
|
project: "{{ gcp_project }}"
|
||||||
auth_kind: "{{ gcp_cred_kind }}"
|
auth_kind: "{{ gcp_cred_kind }}"
|
||||||
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||||
|
@ -141,3 +157,11 @@
|
||||||
state: absent
|
state: absent
|
||||||
register: topic
|
register: topic
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
|
- name: Delete a bucket
|
||||||
|
google.cloud.gcp_storage_bucket:
|
||||||
|
name: topic-subscription-bucket
|
||||||
|
project: "{{ gcp_project }}"
|
||||||
|
auth_kind: "{{ gcp_cred_kind }}"
|
||||||
|
service_account_file: "{{ gcp_cred_file | default(omit) }}"
|
||||||
|
state: absent
|
||||||
|
|
Loading…
Add table
Reference in a new issue