oracle.oci.oci_identity_compartment_actions (5.0.0) — module

Perform actions on a Compartment resource in Oracle Cloud Infrastructure

| "added in version" 2.9.0 of oracle.oci"

Authors: Oracle (@oracle)

preview | supported by community

Install collection

Install with ansible-galaxy collection install oracle.oci:==5.0.0


Add to requirements.yml

  collections:
    - name: oracle.oci
      version: 5.0.0

Description

Perform actions on a Compartment resource in Oracle Cloud Infrastructure

For I(action=bulk_delete_resources), deletes multiple resources in the compartment. All resources must be in the same compartment. You must have the appropriate permissions to delete the resources in the request. This API can only be invoked from the tenancy's L(home region,https://docs.cloud.oracle.com/Content/Identity/regions/managingregions.htm#Home). This operation creates a L(WorkRequest,https://docs.cloud.oracle.com/en-us/iaas/api/#/en/workrequests/20160918/WorkRequest/). Use the L(GetWorkRequest,https://docs.cloud.oracle.com/en-us/iaas/api/#/en/workrequests/20160918/WorkRequest/GetWorkRequest) API to monitor the status of the bulk action.

For I(action=bulk_move_resources), moves multiple resources from one compartment to another. All resources must be in the same compartment. This API can only be invoked from the tenancy's L(home region,https://docs.cloud.oracle.com/Content/Identity/regions/managingregions.htm#Home). To move resources, you must have the appropriate permissions to move the resource in both the source and target compartments. This operation creates a L(WorkRequest,https://docs.cloud.oracle.com/en-us/iaas/api/#/en/workrequests/20160918/WorkRequest/). Use the L(GetWorkRequest,https://docs.cloud.oracle.com/en-us/iaas/api/#/en/workrequests/20160918/WorkRequest/GetWorkRequest) API to monitor the status of the bulk action.

For I(action=move), move the compartment to a different parent compartment in the same tenancy. When you move a compartment, all its contents (subcompartments and resources) are moved with it. Note that the `CompartmentId` that you specify in the path is the compartment that you want to move. **IMPORTANT**: After you move a compartment to a new parent compartment, the access policies of the new parent take effect and the policies of the previous parent no longer apply. Ensure that you are aware of the implications for the compartment contents before you move it. For more information, see L(Moving a Compartment,https://docs.cloud.oracle.com/Content/Identity/compartments/managingcompartments.htm#MoveCompartment).

For I(action=recover), recover the compartment from DELETED state to ACTIVE state.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Perform action bulk_delete_resources on compartment
  oci_identity_compartment_actions:
    # required
    resources:
    - # required
      identifier: identifier_example
      entity_type: entity_type_example

      # optional
      metadata: null
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    action: bulk_delete_resources
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Perform action bulk_move_resources on compartment
  oci_identity_compartment_actions:
    # required
    resources:
    - # required
      identifier: identifier_example
      entity_type: entity_type_example

      # optional
      metadata: null
    target_compartment_id: "ocid1.targetcompartment.oc1..xxxxxxEXAMPLExxxxxx"
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    action: bulk_move_resources
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Perform action move on compartment
  oci_identity_compartment_actions:
    # required
    target_compartment_id: "ocid1.targetcompartment.oc1..xxxxxxEXAMPLExxxxxx"
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    action: move
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Perform action recover on compartment
  oci_identity_compartment_actions:
    # required
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
    action: recover

Inputs

    
wait:
    default: true
    description: Whether to wait for create or delete operation to complete.
    type: bool

action:
    choices:
    - bulk_delete_resources
    - bulk_move_resources
    - move
    - recover
    description:
    - The action to perform on the Compartment.
    required: true
    type: str

region:
    description:
    - 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 C(config_file_location)).
      Please refer to U(https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/regions.htm)
      for more information on OCI regions.
    type: str

tenancy:
    description:
    - 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 C(config_file_location)). To get the tenancy OCID, please
      refer U(https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm)
    type: str

api_user:
    description:
    - 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 C(config_file_location)).
      To get the user's OCID, please refer U(https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm).
    type: str

auth_type:
    choices:
    - api_key
    - instance_principal
    - instance_obo_user
    - resource_principal
    - security_token
    default: api_key
    description:
    - The type of authentication to use for making API requests. By default C(auth_type="api_key")
      based authentication is performed and the API key (see I(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 C(auth_type="instance_principal")
      to use instance principal based authentication when running ansible playbooks within
      an OCI compute instance.
    type: str

resources:
    description:
    - The resources to be deleted.
    - Required for I(action=bulk_delete_resources), I(action=bulk_move_resources).
    elements: dict
    suboptions:
      entity_type:
        description:
        - The resource-type. To get the list of supported resource-types use L(ListBulkActionResourceTypes
          API,https://docs.cloud.oracle.com/en- us/iaas/api/#/en/identity/20160918/BulkActionResourceTypeCollection/ListBulkActionResourceTypes/).
        required: true
        type: str
      identifier:
        description:
        - The resource OCID.
        required: true
        type: str
      metadata:
        description:
        - Additional information that helps to identity the resource for bulk action.
        - The APIs to delete and move most resource types only require the resource identifier
          (ocid). But some resource-types require additional identifying information.
        - This information is provided in the resource's public API document. It is also
          available through the L(ListBulkActionResourceTypes API,https://docs.cloud.oracle.com/en-
          us/iaas/api/#/en/identity/20160918/BulkActionResourceTypeCollection/ListBulkActionResourceTypes/).
        - '**Example**: The APIs to delete or move the `buckets` resource-type require
          `namespaceName` and `bucketName` to identify the resource, as shown in the APIs,
          L(DeleteBucket,https://docs.cloud.oracle.com/en-us/iaas/api/#/en/objectstorage/20160918/Bucket/DeleteBucket)
          and L(UpdateBucket,https://docs.cloud.oracle.com/en-us/iaas/api/#/en/objectstorage/20160918/Bucket/UpdateBucket).'
        - To add a bucket for bulk actions, specify `namespaceName` and `bucketName` in
          the metadata property as shown in this example
        - "\"   {\n      \\\"identifier\\\": \\\"<OCID_of_bucket>\\\"\n      \\\"entityType\\\
          \": \\\"bucket\\\",\n      \\\"metadata\\\":\n      {\n        \\\"namespaceName\\\
          \": \\\"sampleNamespace\\\",\n        \\\"bucketName\\\": \\\"sampleBucket\\\
          \"\n      }\n    }\"\n"
        type: dict
    type: list

cert_bundle:
    description:
    - 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.
    type: str

auth_purpose:
    choices:
    - service_principal
    description:
    - The auth purpose which can be used in conjunction with 'auth_type=instance_principal'.
      The default auth_purpose for instance_principal is None.
    type: str

wait_timeout:
    description: Time, in seconds, to wait when I(wait=yes). Defaults to 1200 for most
      of the services but some services might have a longer wait timeout.
    type: int

compartment_id:
    aliases:
    - id
    description:
    - The OCID of the compartment.
    required: true
    type: str

api_user_key_file:
    description:
    - 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 C(config_file_location)).
      If the key is encrypted with a pass-phrase, the C(api_user_key_pass_phrase) option
      must also be provided.
    type: str

config_profile_name:
    description:
    - The profile to load from the config file referenced by C(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 C(config_file_location).
    type: str

api_user_fingerprint:
    description:
    - 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 C(config_file_location)). To
      get the key pair's fingerprint value please refer U(https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm).
    type: str

config_file_location:
    description:
    - 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.
    type: str

target_compartment_id:
    description:
    - The L(OCID,https://docs.cloud.oracle.com/Content/General/Concepts/identifiers.htm)
      of the destination compartment into which to move the resources.
    - Required for I(action=bulk_move_resources), I(action=move).
    type: str

api_user_key_pass_phrase:
    description:
    - Passphrase used by the key referenced in C(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 C(config_file_location)).
    type: str

realm_specific_endpoint_template_enabled:
    description:
    - Enable/Disable realm specific endpoint template for service client. By Default,
      realm specific endpoint template is disabled. If not set, then the value of the
      OCI_REALM_SPECIFIC_SERVICE_ENDPOINT_TEMPLATE_ENABLED variable, if any, is used.
    type: bool

Outputs

compartment:
  contains:
    compartment_id:
      description:
      - The OCID of the parent compartment containing the compartment.
      returned: on success
      sample: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx
      type: str
    defined_tags:
      description:
      - 'Defined tags for this resource. Each key is predefined and scoped to a namespace.
        For more information, see L(Resource Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm).
        Example: `{"Operations": {"CostCenter": "42"}}`'
      returned: on success
      sample:
        Operations:
          CostCenter: US
      type: dict
    description:
      description:
      - The description you assign to the compartment. Does not have to be unique,
        and it's changeable.
      returned: on success
      sample: description_example
      type: str
    freeform_tags:
      description:
      - 'Free-form tags for this resource. Each tag is a simple key-value pair with
        no predefined name, type, or namespace. For more information, see L(Resource
        Tags,https://docs.cloud.oracle.com/Content/General/Concepts/resourcetags.htm).
        Example: `{"Department": "Finance"}`'
      returned: on success
      sample:
        Department: Finance
      type: dict
    id:
      description:
      - The OCID of the compartment.
      returned: on success
      sample: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx
      type: str
    inactive_status:
      description:
      - The detailed status of INACTIVE lifecycleState.
      returned: on success
      sample: 56
      type: int
    is_accessible:
      description:
      - Indicates whether or not the compartment is accessible for the user making
        the request. Returns true when the user has INSPECT permissions directly on
        a resource in the compartment or indirectly (permissions can be on a resource
        in a subcompartment).
      returned: on success
      sample: true
      type: bool
    lifecycle_state:
      description:
      - The compartment's current state. After creating a compartment, make sure its
        `lifecycleState` changes from CREATING to ACTIVE before using it.
      returned: on success
      sample: CREATING
      type: str
    name:
      description:
      - The name you assign to the compartment during creation. The name must be unique
        across all compartments in the parent. Avoid entering confidential information.
      returned: on success
      sample: name_example
      type: str
    time_created:
      description:
      - Date and time the compartment was created, in the format defined by RFC3339.
      - 'Example: `2016-08-25T21:10:29.600Z`'
      returned: on success
      sample: '2013-10-20T19:20:30+01:00'
      type: str
  description:
  - Details of the Compartment resource acted upon by the current operation
  returned: on success
  sample:
    compartment_id: ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx
    defined_tags:
      Operations:
        CostCenter: US
    description: description_example
    freeform_tags:
      Department: Finance
    id: ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx
    inactive_status: 56
    is_accessible: true
    lifecycle_state: CREATING
    name: name_example
    time_created: '2013-10-20T19:20:30+01:00'
  type: complex