Documentation

ali_oss_object_facts - Gather facts on bucket objects of Alibaba Cloud OSS.

New in version 1.5.0.

Synopsis

  • This module fetches data from the Open API in Alicloud. The module must be called from within the OSS bucket itself.

Requirements

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

  • footmark
  • 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
OSS bucket name.
object
Bucket object name.

aliases: object_name

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

# Fetch object details in the specified bucket
- name: List objects detail example
  hosts: localhost
  vars:
    alicloud_access_key: <your-alicloud-access-key>
    alicloud_secret_key: <your-alicloud-secret-key>
    alicloud_region: cn-beijing
    bucket: xiaozhubucket
    object: newobject-1
  tasks:
    - name: List all objects in the specified bucket
      ali_oss_object_facts:
        alicloud_access_key: '{{ alicloud_access_key }}'
        alicloud_secret_key: '{{ alicloud_secret_key }}'
        alicloud_region: '{{ alicloud_region }}'
        bucket: '{{ bucket }}'
      register: all_objects_in_bucket
    - debug: var=all_objects_in_bucket

    - name: List all objects that has the prefix of 'object' value in the specified bucket
      ali_oss_object_facts:
        alicloud_access_key: '{{ alicloud_access_key }}'
        alicloud_secret_key: '{{ alicloud_secret_key }}'
        alicloud_region: '{{ alicloud_region }}'
        bucket: '{{ bucket }}'
        object: '{{ object }}'
      register: all_objects_by_name
    - debug: var=all_objects_by_name

Return Values

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

Key Returned Description
object_names
list
when success
List all object's in the specified bucket

Sample:
['newobject-1', 'newobject-2', 'newobject-3']
objects
list
when list
The list all objects that has the prefix of 'object' value in the specified bucket

Sample:
[{'last_modified': '2017-10-26 15:18:38', 'etag': '64C63F0FCB9ABA4F74A3DF3A491BBC7A', 'key': 'newobject-1', 'storage_class': 'Standard', 'type': 'Normal', 'size': '1843 B'}, {'last_modified': '2017-10-26 15:18:38', 'etag': 'BE13E8EF0FB40070727817E1448345A0', 'key': 'newobject-2', 'storage_class': 'Standard', 'type': 'Normal', 'size': '15624 B'}, {'last_modified': '2017-10-26 15:18:40', 'etag': 'A7D40C705F555AD8B0A9557BBCCB1178', 'key': 'newobject-3', 'storage_class': 'Standard', 'type': 'Normal', 'size': '3541 B'}]
total
int
when success
The number of all object's in the specified bucket.

Sample:
3


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.