oci_bucket - Create,update and delete oci buckets

New in version 2.5.

Synopsis

  • Creates OCI bucket if not present.
  • Update OCI bucket, if present.
  • Delete OCI bucket, if present.

Requirements

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

Parameters

Parameter Choices/Defaults Comments
api_user
The OCID of the user, on whose behalf, OCI APIs are invoked. If not set, then the value of the OCI_USER_OCID environment variable, if any, is used. This option is required if the user is not specified through a configuration file (See config_file_location). To get the user's OCID, please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm.
api_user_fingerprint
Fingerprint for the key pair being used. If not set, then the value of the OCI_USER_FINGERPRINT environment variable, if any, is used. This option is required if the key fingerprint is not specified through a configuration file (See config_file_location). To get the key pair's fingerprint value please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm.
api_user_key_file
Full path and filename of the private key (in PEM format). If not set, then the value of the OCI_USER_KEY_FILE variable, if any, is used. This option is required if the private key is not specified through a configuration file (See config_file_location). If the key is encrypted with a pass-phrase, the api_user_key_pass_phrase option must also be provided.
api_user_key_pass_phrase
Passphrase used by the key referenced in api_user_key_file, if it is encrypted. If not set, then the value of the OCI_USER_KEY_PASS_PHRASE variable, if any, is used. This option is required if the key passphrase is not specified through a configuration file (See config_file_location).
auth_type
    Choices:
  • api_key ←
  • instance_principal
The type of authentication to use for making API requests. By default auth_type="api_key" based authentication is performed and the API key (see api_user_key_file) in your config file will be used. If this 'auth_type' module option is not specified, the value of the OCI_ANSIBLE_AUTH_TYPE, if any, is used. Use auth_type="instance_principal" to use instance principal based authentication when running ansible playbooks within an OCI compute instance.
compartment_id
Identifier of the compartment in which the bucket is available or should be available. Mandatory for state=present. Not required for state=absent
config_file_location
Path to configuration file. If not set then the value of the OCI_CONFIG_FILE environment variable, if any, is used. Otherwise, defaults to ~/.oci/config.
config_profile_name Default:
DEFAULT
The profile to load from the config file referenced by config_file_location. If not set, then the value of the OCI_CONFIG_PROFILE environment variable, if any, is used. Otherwise, defaults to the "DEFAULT" profile in config_file_location.
force
bool
    Choices:
  • no ←
  • yes
If force='no' and the bucket contains objects, bucket will not be deleted. To delete a bucket which has objects, force='yes' should be specified.
metadata
Use defined metadata dict(str,str) for the bucket. Limit is 4KB.
name
required
Name of the bucket. Bucket name must be unique within a namespace. For naming conventions, refer https://docs.us-phoenix-1.oraclecloud.com/Content/Object/Tasks/managingbuckets.htm
namespace_name
required
Name of the namespace in which the bucket is available or should be available
public_access_type
    Choices:
  • ObjectRead
  • NoPublicAccess ←
The type of public access of the bucket. By default, no public access is allowed on the bucket. If public_access_type=ObjectRead, user can perform read operation on the bucket.
region
The Oracle Cloud Infrastructure region to use for all OCI API requests. If not set, then the value of the OCI_REGION variable, if any, is used. This option is required if the region is not specified through a configuration file (See config_file_location). Please refer to https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/regions.htm for more information on OCI regions.
state
required
    Choices:
  • present ←
  • absent
Decides whether to create,update or delete bucket. For state=present, if the bucket does not exist, it gets created. If it exists, it gets updated. For state=absent, the bucket gets deleted.
tenancy
OCID of your tenancy. If not set, then the value of the OCI_TENANCY variable, if any, is used. This option is required if the tenancy OCID is not specified through a configuration file (See config_file_location). To get the tenancy OCID, please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm

Examples

#Note: These examples do not set authentication details.

#Bucket creation or update
- name: Create or Update bucket
  oci_bucket:
    namespace_name: 'ansibletestspace'
    compartment_id: 'ocid1.compartment.oc1..xxxxxEXAMPLExxxxx'
    name: 'AnsibleTestBucket'
    public_access_type: 'NoPublicAccess'
    metadata:
        project: 'Test Project'
    state: 'present'

#Delete bucket
- name: Delete bucket with 'force' to delete the bucket
        along with all the containing objects
  oci_bucket:
    namespace_name: 'ansibletestspace'
    name: 'AnsibleTestBucket'
    force: 'yes'
    state: 'absent'

Return Values

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

Key Returned Description
bucket
string
success
Attributes of the created/updated bucket. Applicable only for create and update.

Sample:
{'name': 'AnsibleTestBucket', 'compartment_id': 'ocid1....62xq', 'namespace': 'ansibletestspace', 'created_by': 'ocid1.user.oc1..xxxxxEXAMPLExxxxx..qndq', 'etag': 'cb734ffe-da3a-48f4-....-161fd4604cf1', 'time_created': '2017-10-01T11:30:33.655000+00:00', 'public_access_type': 'ObjectRead', 'metadata': {}}


Status

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

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

Author

  • Debayan Gupta(@debayan_gupta)

Hint

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