Documentation

ali_oss_bucket - Create/Delete/Retrieve Bucket.

New in version 2.4.

Synopsis

  • This module allows the user to manage OSS buckets. Includes support for creating, deleting and retrieving buckets.

Requirements

The below requirements are needed on the host that executes this module.

  • footmark >= 1.1.16
  • python >= 2.6

Parameters

Parameter Choices/Defaults Comments
alicloud_access_key
Aliyun Cloud access key. If not set then the value of environment variable ALICLOUD_ACCESS_KEY, ALICLOUD_ACCESS_KEY_ID will be used instead.

aliases: access_key_id, access_key
alicloud_region
The Aliyun Cloud region to use. If not specified then the value of environment variable ALICLOUD_REGION, ALICLOUD_REGION_ID will be used instead.

aliases: region, region_id
alicloud_secret_key
Aliyun Cloud secret key. If not set then the value of environment variable ALICLOUD_SECRET_KEY, ALICLOUD_SECRET_ACCESS_KEY will be used instead.

aliases: secret_access_key, secret_key
alicloud_security_token
The Aliyun Cloud security token. If not specified then the value of environment variable ALICLOUD_SECURITY_TOKEN will be used instead.

aliases: security_token
bucket
required
Bucket name.

aliases: name
permission
    Choices:
  • private ←
  • public-read
  • public-read-write
This option lets the user set the canned permissions on the bucket that are created.

aliases: acl
state
    Choices:
  • present ←
  • absent
  • list
Create or delete the OSS bucket. List all buckets that has the prefix of 'bucket' value.

Notes

Note

  • If parameters are not set within the module, the following environment variables can be used in decreasing order of precedence ALICLOUD_ACCESS_KEY or ALICLOUD_ACCESS_KEY_ID, ALICLOUD_SECRET_KEY or ALICLOUD_SECRET_ACCESS_KEY, ALICLOUD_REGION or ALICLOUD_REGION_ID, ALICLOUD_SECURITY_TOKEN
  • ALICLOUD_REGION or ALICLOUD_REGION_ID can be typically be used to specify the ALICLOUD region, when required, but this can also be configured in the footmark config file

Examples

#
# provisioning new oss bucket
#

# basic provisioning example to create bucket
- name: create oss bucket
  hosts: localhost
  connection: local
  vars:
    alicloud_access_key: <your-alicloud-access-key-id>
    alicloud_secret_key: <your-alicloud-access-secret-key>
    alicloud_region: cn-hangzhou
    state: present
    bucket: bucketname
    permission: public-read-write
  tasks:
    - name: create oss bucket
      ali_oss_bucket:
        alicloud_access_key: '{{ alicloud_access_key }}'
        alicloud_secret_key: '{{ alicloud_secret_key }}'
        alicloud_region: '{{ alicloud_region }}'
        state: '{{ state }}'
        bucket: '{{ bucket }}'
        permission: '{{ permission }}'
      register: result
    - debug: var=result

# basic provisioning example to delete bucket
- name: delete oss bucket
  hosts: localhost
  connection: local
  vars:
    alicloud_access_key: <your-alicloud-access-key-id>
    alicloud_secret_key: <your-alicloud-access-secret-key>
    alicloud_region: cn-hangzhou
    state: absent
    bucket: bucketname
  tasks:
    - name: delete oss bucket
      ali_oss_bucket:
        alicloud_access_key: '{{ alicloud_access_key }}'
        alicloud_secret_key: '{{ alicloud_secret_key }}'
        alicloud_region: '{{ alicloud_region }}'
        state: '{{ state }}'
        bucket: '{{ bucket }}'
      register: result
    - debug: var=result

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
bucket
dict
on present
the bucket's headers after create bucket or update its acl

Sample:
{'location': 'oss-cn-beijing', 'id': 'xiaozhubucket', 'name': 'xiaozhubucket', 'permission': 'public-read'}
buckets
list
when list
the list all buckets that has the prefix of 'bucket' value in the specified region

Sample:
[{'location': 'oss-cn-beijing', 'id': 'xiaozhubucket', 'name': 'xiaozhubucket', 'permission': 'public-read'}, {'location': 'oss-cn-beijing', 'id': 'xiaozhubucket-2', 'name': 'xiaozhubucket-2', 'permission': 'private'}]
changed
bool
when success
current operation whether changed the resource

Sample:
True


Status

This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.

Author

  • He Guimin (@xiaozhu36)

Hint

If you notice any issues in this documentation you can edit this document to improve it.