Oracle Cloud Infrastructure (OCI) Ansible Collection

repository·master·Indexed 41 days ago

https://github.com/oracle/oci-ansible-collection

A collection of Ansible modules for provisioning and managing Oracle Cloud Infrastructure (OCI) resources. It serves as the modern replacement for legacy oci-ansible-modules, providing wider service coverage and faster updates. Compatible with Ansible Tower and AWX, the collection includes samples for managing compute instances, block volumes, auto scaling policies, and custom images.

Tokens
106.7K
Snippets
210
Records
400
Agent score
47%

What's inside OCI Ansible Collection

  1. Patch Oracle Cloud Infrastructure Database Systems

    master

    This solution provides automation for patching Oracle Cloud Infrastructure (OCI) database systems using the OCI Ansible collection. It supports two primary patching strategies:

    1. Tag-based patching: Discovers and patches database systems sequentially based on specific tags defined within a compartment or tenancy.
    2. Non-tag based patching: Patches database systems sequentially using one or more provided Oracle Cloud Identifiers (OCIDs).

    The automation can patch both Grid Infrastructure and the database itself via API calls without requiring direct login to the database nodes.

  2. Capabilities of the DB System sample

    master

    The database_db_system sample provides a comprehensive workflow for OCI Co-managed DB Systems, including:

    • Provisioning: Sets up a Virtual Machine DB System.
    • Inspection: Retrieves facts for a specific DB System and lists available DB Homes.
    • Networking: Collects VNIC information for a specified DB system and extracts Public and Private IPs of the DB Node.
    • Data Protection: Creates backups from an initial database and restores databases from the latest backup.
    • Database Management: Creates new databases from backups, updates database fields, and lists/inspects databases within a specified DB Home.
  3. Overview of oci_opsi_resource_usage_facts functionality

    master

    The oracle.oci.oci_opsi_resource_usage_facts module fetches details about a ResourceUsage resource in Oracle Cloud Infrastructure.

    Key behaviors:

    • Usage Ranking: It uses a cumulative distribution function to rank usage data points per database within a specified time period. For each database, the minimum data point with a ranking greater than the percentile value is included in the summation.
    • Usage Change: It uses linear regression functions to calculate the usage change percentage.
    • Compartment Aggregation: If compartmentIdInSubtree is specified, the module aggregates resources in the specified compartment and all of its sub-compartments.
  4. Set the time range for host insights analysis

    master

    You can specify the time period for the host insights analysis using either analysis_time_interval or a combination of time_interval_start and time_interval_end.

    Option 1: Relative Interval

    Use analysis_time_interval to specify a period in ISO 8601 format relative to the current time.

    • Default: P30D (last 30 days).
    • Examples: P90D (90 days), P4W (4 weeks), P2M (2 months), P1Y (12 months).
    • Limit: Maximum value is P25M (25 months).
    • Note: If this is set, time_interval_start and time_interval_end are ignored.

    Option 2: Absolute Range

    Use time_interval_start and time_interval_end for specific UTC timestamps in ISO 8601 format (yyyy-MM-ddThh:mm:ssZ).

    • time_interval_start: Inclusive start time. Minimum allowed is 2 years prior to current day.
    • time_interval_end: Exclusive end time. If not specified, the current time is used.
  5. Authentication options for OCI Ansible modules

    master

    The oci_opsi_tablespace_usage_trend_facts module supports several authentication methods via the auth_type parameter. If not specified, it defaults to api_key.

    Supported auth_type values:

    • api_key: (Default) Uses an API key defined in your OCI configuration file.
    • instance_principal: Used when running playbooks within an OCI compute instance.
    • instance_obo_user: Instance Oracle By Owner user.
    • resource_principal: Used for resource-based authentication.
    • security_token: Uses a security token for authentication.

    API Key Authentication Parameters:

    If using auth_type: api_key, you may need to provide the following if they are not in your config_file_location:

    • api_user: The OCID of the user.
    • api_user_fingerprint: Fingerprint for the key pair.
    • api_user_key_file: Full path to the private key (PEM format).
    • api_user_key_pass_phrase: Passphrase if the private key is encrypted.

    Instance Principal Authentication:

    • auth_purpose: Can be set to service_principal when using auth_type: instance_principal.
  6. Set the analysis time interval for storage usage trends

    master

    To specify the time period for the storage usage trend analysis, use either analysis_time_interval or the combination of time_interval_start and time_interval_end.

    Option 1: analysis_time_interval

    Specify a duration in ISO 8601 format relative to the current time.

    • Default: P30D (last 30 days).
    • Examples: P90D (90 days), P4W (4 weeks), P2M (2 months), P1Y (12 months).
    • Constraint: Maximum allowed is 25 months (P25M).
    • Note: If this is set, time_interval_start and time_interval_end are ignored.

    Option 2: time_interval_start and time_interval_end

    Specify absolute timestamps in UTC (ISO 8601 format, e.g., 2019-10-30T00:00:00Z).

    • time_interval_start: Inclusive start time. Minimum allowed is 2 years prior to the current day.
    • time_interval_end: Exclusive end time. If not specified, the current time is used.
  7. Configure batch atomicity for metric data posting

    master

    The module allows you to control the batch atomicity behavior for PostMetricData requests. This determines how the service handles validation errors within a batch of metric objects:

    • NON_ATOMIC (default): Requires a partial pass. At least one metric object in the request must pass validation. Objects that fail validation are identified in the returned summary along with their error messages.
    • ATOMIC: Requires a full pass. All metric objects in the request must pass validation for the operation to succeed.
  8. Manage usage plans by name using OCI_USE_NAME_AS_IDENTIFIER

    master

    By default, the oci_apigateway_usage_plan module requires a usage_plan_id for updates and deletions. However, if you set the environment variable OCI_USE_NAME_AS_IDENTIFIER, you can manage usage plans using their display_name instead of their OCID. When this variable is set, you must provide the compartment_id alongside the display_name to identify the resource.

    - name: Update usage_plan using name
      oci_apigateway_usage_plan:
        # required when OCI_USE_NAME_AS_IDENTIFIER is set
        compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
        display_name: display_name_example
        entitlements:
        - name: name_example
          targets:
          - deployment_id: "ocid1.deployment.oc1..xxxxxxEXAMPLExxxxxx"
    
    - name: Delete usage_plan using name
      oci_apigateway_usage_plan:
        # required when OCI_USE_NAME_AS_IDENTIFIER is set
        compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"
        display_name: display_name_example
        state: absent
  9. Configure authentication for oci_resource_manager_job_detailed_log_content_facts

    master

    The oci_resource_manager_job_detailed_log_content_facts module supports several authentication methods via the auth_type parameter.

    Authentication Types

    • api_key (Default): Uses an API key defined in your OCI configuration file. Requires api_user, api_user_fingerprint, and api_user_key_file if not provided in the config file.
    • instance_principal: Used when running Ansible playbooks within an OCI compute instance. Can be used with auth_purpose=service_principal.
    • instance_obo_user: On-behalf-of user authentication.
    • resource_principal: Used for resource-based authentication.
    • security_token: Uses a security token for authentication.

    API Key Parameters

    If using auth_type=api_key, you may need to specify:

    • api_user: The OCID of the user.
    • api_user_fingerprint: The fingerprint for the key pair.
    • api_user_key_file: Full path to the private key (PEM format).
    • api_user_key_pass_phrase: Passphrase if the private key is encrypted.
  10. Configure authentication for OCI Ansible modules

    master

    The OCI Ansible collection supports multiple authentication methods via the auth_type parameter. If not specified, it defaults to api_key.

    Supported auth_type values:

    • api_key: Uses an API key defined in a configuration file or via explicit parameters.
    • instance_principal: Uses instance principal-based authentication (useful when running playbooks within an OCI compute instance).
    • instance_obo_user: On-behalf-of user authentication.
    • resource_principal: Uses resource principal-based authentication.
    • security_token: Uses a security token.

    API Key Authentication Parameters: If using auth_type="api_key", you can provide credentials directly or rely on the OCI configuration file:

    • api_user: The OCID of the user. (Fallback: OCI_USER_ID env var).
    • api_user_fingerprint: Fingerprint for the key pair. (Fallback: OCI_USER_FINGERPRINT env var).
    • api_user_key_file: Full path to the private key in PEM format. (Fallback: OCI_USER_KEY_FILE env var).
    • api_user_key_pass_phrase: Passphrase if the private key is encrypted. (Fallback: OCI_USER_KEY_PASS_PHRASE env var).

    Instance Principal Specifics:

    • auth_purpose: Can be set to service_principal when using auth_type="instance_principal".
  11. Configure authentication for oci_apigateway_usage_plan_facts

    master

    The oci_apigateway_usage_plan_facts module supports several authentication methods via the auth_type parameter.

    • api_key (default): Uses an API key defined in your OCI configuration file. Requires api_user, api_user_fingerprint, and api_user_key_file. If the private key is encrypted, you must also provide api_user_key_pass_phrase.
    • instance_principal: Used when running Ansible playbooks within an OCI compute instance. Can be used with auth_purpose=service_principal.
    • resource_principal: Uses resource principal authentication.
    • instance_obo_user: Uses instance Oracle Borrowed Object authentication.
    • security_token: Uses security token authentication.

    If these parameters are not explicitly set in the module, the collection will attempt to use corresponding environment variables (e.g., OCI_USER_ID, OCI_USER_FINGERPRINT, OCI_USER_KEY_FILE, OCI_USER_KEY_PASS_PHRASE, OCI_ANSIBLE_AUTH_TYPE).

    # Example using API Key authentication
    - name: Get API Gateway Usage Plan facts
      oracle.oci.oci_apigateway_usage_plan_facts:
        auth_type: api_key
        api_user: "<user_ocid>"
        api_user_fingerprint: "<fingerprint>"
        api_user_key_file: "/path/to/private_key.pem"
        api_user_key_pass_phrase: "<passphrase>"
        compartment_id: "<compartment_ocid>"
        usage_plan_id: "<usage_plan_ocid>"
  12. Manage resource idempotency with force_create and key_by

    master

    The oci_monitoring_metric_data module provides options to control how resources are identified and created:

    • force_create (boolean): If set to yes, the module will forcefully create a copy of the resource even if it already exists. By default, the operation is idempotent and will not create a resource if it already exists. Note that force_create is mutually exclusive with key_by.
    • key_by (list of strings): A list of attributes used to uniquely identify an instance of the resource. By default, all attributes of a resource are used for identification.