damex.cloudflare.cloudflare_r2_bucket module – Ensure Cloudflare R2 buckets
Note
This module is part of the damex.cloudflare collection (version 1.1.1).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install damex.cloudflare.
To use it in a playbook, specify: damex.cloudflare.cloudflare_r2_bucket.
Synopsis
Ensures Cloudflare R2 object storage buckets using the Cloudflare API, see the docs: https://developers.cloudflare.com/r2/.
Parameters
Parameter |
Comments |
|---|---|
Cloudflare account API key. Required together with |
|
Cloudflare account email. Required together with |
|
Cloudflare account identifier. Required if |
|
Cloudflare account name. Required if Resolved to account identifier via the Cloudflare API. |
|
Cloudflare API token. Required if Can be specified in |
|
Bucket location hint. Only used when creating a new bucket. Cannot be changed after bucket creation. Choices:
|
|
Bucket name. |
|
Bucket state. Choices:
|
|
Default storage class for newly uploaded objects. Choices:
|
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Supports check mode. |
|
Support: full |
Supports diff mode. |
Examples
- name: Ensure R2 bucket
damex.cloudflare.cloudflare_r2_bucket:
name: my-bucket
account_id: 023e105f4ecef8ad9ca31a8372d0c353
api_token: "{{ cloudflare_api_token }}"
- name: Ensure R2 bucket in Western Europe
damex.cloudflare.cloudflare_r2_bucket:
name: my-bucket
account_id: 023e105f4ecef8ad9ca31a8372d0c353
api_token: "{{ cloudflare_api_token }}"
location_hint: weur
- name: Ensure R2 bucket with infrequent access storage class
damex.cloudflare.cloudflare_r2_bucket:
name: my-bucket
account_id: 023e105f4ecef8ad9ca31a8372d0c353
api_token: "{{ cloudflare_api_token }}"
storage_class: InfrequentAccess
- name: Ensure R2 bucket is absent
damex.cloudflare.cloudflare_r2_bucket:
name: my-bucket
account_id: 023e105f4ecef8ad9ca31a8372d0c353
api_token: "{{ cloudflare_api_token }}"
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Bucket object from the Cloudflare API. Returned: when state is present |
|
Bucket creation timestamp. Returned: success Sample: |
|
Bucket location. Returned: success Sample: |
|
Bucket name. Returned: success Sample: |
|
Default storage class. Returned: success Sample: |