oracle.oci.oci_identity_tag_actions – Perform actions on a Tag resource in Oracle Cloud Infrastructure

Note

This plugin is part of the oracle.oci collection (version 4.10.0).

You might already have this collection installed if you are using the ansible package. 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 oracle.oci.

To use it in a playbook, specify: oracle.oci.oci_identity_tag_actions.

New in version 2.9.0: of oracle.oci

Synopsis

  • Perform actions on a Tag resource in Oracle Cloud Infrastructure

  • For action=bulk_delete, deletes the specified tag key definitions. This operation triggers a process that removes the tags from all resources in your tenancy. The tag key definitions must be within the same tag namespace. The following actions happen immediately: * If the tag is a cost-tracking tag, the tag no longer counts against your 10 cost-tracking tags limit, even if you do not disable the tag before running this operation. * If the tag is used with dynamic groups, the rules that contain the tag are no longer evaluated against the tag. After you start this operation, the state of the tag changes to DELETING, and tag removal from resources begins. This process can take up to 48 hours depending on the number of resources that are tagged and the regions in which those resources reside. When all tags have been removed, the state changes to DELETED. You cannot restore a deleted tag. After the tag state changes to DELETED, you can use the same tag name again. After you start this operation, you cannot start either the DeleteTag or the CascadeDeleteTagNamespace operation until this process completes. In order to delete tags, you must first retire the tags. Use UpdateTag to retire a tag.

  • For action=bulk_edit, edits the specified list of tag key definitions for the selected resources. This operation triggers a process that edits the tags on all selected resources. The possible actions are: * Add a defined tag when the tag does not already exist on the resource. * Update the value for a defined tag when the tag is present on the resource. * Add a defined tag when it does not already exist on the resource or update the value for a defined tag when the tag is present on the resource. * Remove a defined tag from a resource. The tag is removed from the resource regardless of the tag value. See BulkEditOperationDetails for more information. The edits can include a combination of operations and tag sets. However, multiple operations cannot apply to one key definition in the same request. For example, if one request adds tag set-1 to a resource and sets a tag value to tag set-2, tag set-1 and tag set-2 cannot have any common tag definitions.

  • For action=import_standard_tags, oCI will release Tag Namespaces that our customers can import. These Tag Namespaces will provide Tags for our customers and Partners to provide consistency and enable data reporting.

Requirements

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

Parameters

Parameter Choices/Defaults Comments
action
string / required
    Choices:
  • bulk_delete
  • bulk_edit
  • import_standard_tags
The action to perform on the Tag.
api_user
string
The OCID of the user, on whose behalf, OCI APIs are invoked. If not set, then the value of the OCI_USER_ID 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
string
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
string
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
string
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_purpose
string
    Choices:
  • service_principal
The auth purpose which can be used in conjunction with 'auth_type=instance_principal'. The default auth_purpose for instance_principal is None.
auth_type
string
    Choices:
  • api_key ←
  • instance_principal
  • instance_obo_user
  • resource_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.
bulk_edit_operations
list / elements=dictionary
The operations associated with the request to bulk edit tags.
Required for action=bulk_edit.
defined_tags
dictionary / required
Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags. Example: `{"Operations": {"CostCenter": "42"}}`
operation_type
string / required
    Choices:
  • ADD_WHERE_ABSENT
  • SET_WHERE_PRESENT
  • ADD_OR_SET
  • REMOVE
An enum-like description of the type of operation.
* `ADD_WHERE_ABSENT` adds a defined tag only if the tag does not already exist on the resource. * `SET_WHERE_PRESENT` updates the value for a defined tag only if the tag is present on the resource. * `ADD_OR_SET` combines the first two operations to add a defined tag if it does not already exist on the resource or update the value for a defined tag only if the tag is present on the resource. * `REMOVE` removes the defined tag from the resource. The tag is removed from the resource regardless of the tag value.
cert_bundle
string
The full path to a CA certificate bundle to be used for SSL verification. This will override the default CA certificate bundle. If not set, then the value of the OCI_ANSIBLE_CERT_BUNDLE variable, if any, is used.
compartment_id
string
The OCID of the compartment where the bulk tag edit request is submitted.
Required for action=bulk_edit, action=import_standard_tags.
config_file_location
string
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
string
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.
is_lock_override
boolean
    Choices:
  • no
  • yes
Whether to override locks (if any exist).
Applicable only for action=bulk_delete.
region
string
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.
resources
list / elements=dictionary
The resources to be updated.
Required for action=bulk_edit.
id
string / required
The unique OCID of the resource.
metadata
dictionary
Additional information that identifies the resource for bulk editing of tags. This information is provided in the resource's API documentation.
resource_type
string / required
The type of resource. See BulkEditResourceTypes.
standard_tag_namespace_name
string
The name of standard tag namespace that will be imported in bulk
Required for action=import_standard_tags.
tag_definition_ids
list / elements=string
The OCIDs of the tag definitions to delete
Required for action=bulk_delete.
tenancy
string
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
wait
boolean
    Choices:
  • no
  • yes ←
Whether to wait for create or delete operation to complete.
wait_timeout
integer
Time, in seconds, to wait when wait=yes. Defaults to 1200 for most of the services but some services might have a longer wait timeout.

Examples

- name: Perform action bulk_delete on tag
  oci_identity_tag_actions:
    # required
    tag_definition_ids: [ "tag_definition_ids_example" ]
    action: bulk_delete

    # optional
    is_lock_override: true

- name: Perform action bulk_edit on tag
  oci_identity_tag_actions:
    # required
    resources:
    - # required
      id: "ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx"
      resource_type: resource_type_example

      # optional
      metadata: null
    bulk_edit_operations:
    - # required
      operation_type: ADD_WHERE_ABSENT
      defined_tags: {'Operations': {'CostCenter': 'US'}}
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    action: bulk_edit

- name: Perform action import_standard_tags on tag
  oci_identity_tag_actions:
    # required
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    standard_tag_namespace_name: standard_tag_namespace_name_example
    action: import_standard_tags

Authors

  • Oracle (@oracle)