oracle.oci.oci_container_instances_container – Manage a Container resource in Oracle Cloud Infrastructure

Note

This plugin is part of the oracle.oci collection (version 5.3.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_container_instances_container.

New in version 2.9.0: of oracle.oci

Synopsis

Requirements

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

Parameters

Parameter Choices/Defaults Comments
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
  • security_token
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.
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 in which to list resources.
Required for update when environment variable OCI_USE_NAME_AS_IDENTIFIER is set.
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.
container_id
string
The OCID of the container.
Required for update using state=present when environment variable OCI_USE_NAME_AS_IDENTIFIER is not set.

aliases: id
defined_tags
dictionary
Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{"foo-namespace": {"bar-key": "value"}}`.
This parameter is updatable.
display_name
string
A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
Required for update when environment variable OCI_USE_NAME_AS_IDENTIFIER is set.
This parameter is updatable when OCI_USE_NAME_AS_IDENTIFIER is not set.

aliases: name
freeform_tags
dictionary
Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`
This parameter is updatable.
realm_specific_endpoint_template_enabled
boolean
    Choices:
  • no
  • yes
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.
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.
state
string
    Choices:
  • present ←
The state of the Container.
Use state=present to update an existing a Container.
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: Update container
  oci_container_instances_container:
    # required
    container_id: "ocid1.container.oc1..xxxxxxEXAMPLExxxxxx"

    # optional
    display_name: display_name_example
    freeform_tags: {'Department': 'Finance'}
    defined_tags: {'Operations': {'CostCenter': 'US'}}

- name: Update container using name (when environment variable OCI_USE_NAME_AS_IDENTIFIER is set)
  oci_container_instances_container:
    # required
    display_name: display_name_example
    compartment_id: "ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx"

    # optional
    freeform_tags: {'Department': 'Finance'}
    defined_tags: {'Operations': {'CostCenter': 'US'}}

Return Values

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

Key Returned Description
container
complex
on success
Details of the Container resource acted upon by the current operation

Sample:
{'arguments': [], 'availability_domain': 'Uocm:PHX-AD-1', 'command': [], 'compartment_id': 'ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx', 'container_instance_id': 'ocid1.containerinstance.oc1..xxxxxxEXAMPLExxxxxx', 'container_restart_attempt_count': 56, 'defined_tags': {'Operations': {'CostCenter': 'US'}}, 'display_name': 'display_name_example', 'environment_variables': {}, 'exit_code': 56, 'fault_domain': 'FAULT-DOMAIN-1', 'freeform_tags': {'Department': 'Finance'}, 'health_checks': [{'command': [], 'failure_action': 'KILL', 'failure_threshold': 56, 'headers': [{'name': 'name_example', 'value': 'value_example'}], 'health_check_type': 'HTTP', 'initial_delay_in_seconds': 56, 'interval_in_seconds': 56, 'name': 'name_example', 'path': 'path_example', 'port': 56, 'status': 'HEALTHY', 'status_details': 'status_details_example', 'success_threshold': 56, 'timeout_in_seconds': 56}], 'id': 'ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx', 'image_url': 'image_url_example', 'is_resource_principal_disabled': True, 'lifecycle_details': 'lifecycle_details_example', 'lifecycle_state': 'CREATING', 'resource_config': {'memory_limit_in_gbs': 3.4, 'vcpus_limit': 3.4}, 'security_context': {'is_non_root_user_check_enabled': True, 'is_root_file_system_readonly': True, 'run_as_group': 56, 'run_as_user': 56, 'security_context_type': 'LINUX'}, 'system_tags': {}, 'time_created': '2013-10-20T19:20:30+01:00', 'time_terminated': '2013-10-20T19:20:30+01:00', 'time_updated': '2013-10-20T19:20:30+01:00', 'volume_mounts': [{'is_read_only': True, 'mount_path': 'mount_path_example', 'partition': 56, 'sub_path': 'sub_path_example', 'volume_name': 'volume_name_example'}], 'working_directory': 'working_directory_example'}
 
arguments
list / elements=string
on success
A list of string arguments for the ENTRYPOINT process of the container.
Many containers use an ENTRYPOINT process pointing to a shell `/bin/bash`. For those containers, you can use the argument list to specify the main command in the container process.

 
availability_domain
string
on success
The availability domain where the container instance that hosts the container runs.

Sample:
Uocm:PHX-AD-1
 
command
list / elements=string
on success
This command overrides ENTRYPOINT process of the container. If you do not specify this command, the existing ENTRYPOINT process defined in the image is the default.

 
compartment_id
string
on success
The OCID of the compartment that contains the container.

Sample:
ocid1.compartment.oc1..xxxxxxEXAMPLExxxxxx
 
container_instance_id
string
on success
The OCID of the container instance that the container is running on.

Sample:
ocid1.containerinstance.oc1..xxxxxxEXAMPLExxxxxx
 
container_restart_attempt_count
integer
on success
The number of container restart attempts. Depending on the restart policy, a restart might be attempted after a health check failure or a container exit.

Sample:
56
 
defined_tags
dictionary
on success
Defined tags for this resource. Each key is predefined and scoped to a namespace. Example: `{"foo-namespace": {"bar-key": "value"}}`.

Sample:
{'Operations': {'CostCenter': 'US'}}
 
display_name
string
on success
A user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.

Sample:
display_name_example
 
environment_variables
dictionary
on success
A map of additional environment variables to set in the environment of the ENTRYPOINT process of the container. These variables are in addition to any variables already defined in the container's image.

 
exit_code
integer
on success
The exit code of the container process when it stopped running.

Sample:
56
 
fault_domain
string
on success
The fault domain of the container instance that hosts the container runs.

Sample:
FAULT-DOMAIN-1
 
freeform_tags
dictionary
on success
Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only. Example: `{"bar-key": "value"}`

Sample:
{'Department': 'Finance'}
 
health_checks
complex
on success
List of container health checks

   
command
list / elements=string
on success
The list of strings that will be simplified to a single command for checking the status of the container.

   
failure_action
string
on success
The action will be triggered when the container health check fails. There are two types of action: KILL or NONE. The default action is KILL. If failure action is KILL, the container will be subject to the container restart policy.

Sample:
KILL
   
failure_threshold
integer
on success
Number of consecutive failures at which we consider the check failed.

Sample:
56
   
headers
complex
on success
Container health check HTTP headers.

     
name
string
on success
Container HTTP header Key.

Sample:
name_example
     
value
string
on success
Container HTTP header value.

Sample:
value_example
   
health_check_type
string
on success
Container health check type.

Sample:
HTTP
   
initial_delay_in_seconds
integer
on success
The initial delay in seconds before start checking container health status.

Sample:
56
   
interval_in_seconds
integer
on success
Number of seconds between two consecutive runs for checking container health.

Sample:
56
   
name
string
on success
Health check name.

Sample:
name_example
   
path
string
on success
Container health check HTTP path.

Sample:
path_example
   
port
integer
on success
Container health check HTTP port.

Sample:
56
   
status
string
on success
Status of container

Sample:
HEALTHY
   
status_details
string
on success
A message describing the current status in more details.

Sample:
status_details_example
   
success_threshold
integer
on success
Number of consecutive successes at which we consider the check succeeded again after it was in failure state.

Sample:
56
   
timeout_in_seconds
integer
on success
Length of waiting time in seconds before marking health check failed.

Sample:
56
 
id
string
on success
The OCID of the container.

Sample:
ocid1.resource.oc1..xxxxxxEXAMPLExxxxxx
 
image_url
string
on success
The container image information. Currently only supports public Docker registry.
You can provide either the image name (containerImage), image name with version (containerImagev1), or complete Docker image URL `docker.io/library/containerImage:latest`.
If you do not provide a registry, the registry defaults to public Docker hub `docker.io/library`. The registry used for the container image must be reachable over the VNIC of the container instance.

Sample:
image_url_example
 
is_resource_principal_disabled
boolean
on success
Determines if the container will have access to the container instance resource principal.
This method utilizes resource principal version 2.2. For more information on how to use the exposed resource principal elements, see https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdk_authentication_methods.htm#sdk_authentication_methods_resource_principal.

Sample:
True
 
lifecycle_details
string
on success
A message that describes the current state of the container in more detail. Can be used to provide actionable information.

Sample:
lifecycle_details_example
 
lifecycle_state
string
on success
The current state of the container.

Sample:
CREATING
 
resource_config
complex
on success

   
memory_limit_in_gbs
float
on success
The maximum amount of memory that can be consumed by the container's process. If you do not set a value, then the process may use all available memory on the instance.

Sample:
3.4
   
vcpus_limit
float
on success
The maximum amount of CPUs that can be consumed by the container's process.
If you do not set a value, then the process may use all available CPU resources on the container instance.
CPU usage is defined in terms of logical CPUs. This means that the maximum possible value on an E3 ContainerInstance with 1 OCPU is 2.0.

Sample:
3.4
 
security_context
complex
on success

   
is_non_root_user_check_enabled
boolean
on success
Indicates if the container must run as a non-root user. If true, the service validates the container image at runtime to ensure that it is not going to run with UID 0 (root) and fails the container instance creation if the validation fails.

Sample:
True
   
is_root_file_system_readonly
boolean
on success
Determines if the container will have a read-only root file system. Default value is false.

Sample:
True
   
run_as_group
integer
on success
The group ID (GID) to run the entrypoint process of the container. Uses runtime default if not provided.

Sample:
56
   
run_as_user
integer
on success
The user ID (UID) to run the entrypoint process of the container. Defaults to user specified UID in container image metadata if not provided. This must be provided if runAsGroup is provided.

Sample:
56
   
security_context_type
string
on success
The type of security context

Sample:
LINUX
 
system_tags
dictionary
on success
Usage of system tag keys. These predefined keys are scoped to namespaces. Example: `{"orcl-cloud": {"free-tier-retained": "true"}}`.

 
time_created
string
on success
The time the container was created, in the format defined by RFC 3339.

Sample:
2013-10-20T19:20:30+01:00
 
time_terminated
string
on success
The time when the container last deleted (terminated), in the format defined by RFC 3339.

Sample:
2013-10-20T19:20:30+01:00
 
time_updated
string
on success
The time the container was updated, in the format defined by RFC 3339.

Sample:
2013-10-20T19:20:30+01:00
 
volume_mounts
complex
on success
List of the volume mounts.

   
is_read_only
boolean
on success
Whether the volume was mounted in read-only mode. By default, the volume is mounted with write access.

Sample:
True
   
mount_path
string
on success
Describes the volume access path.

Sample:
mount_path_example
   
partition
integer
on success
If there is more than one partition in the volume, reference this number of partitions. Here is an example: Number Start End Size File system Name Flags 1 1049kB 106MB 105MB fat16 EFI System Partition boot, esp 2 106MB 1180MB 1074MB xfs 3 1180MB 50.0GB 48.8GB lvm

Sample:
56
   
sub_path
string
on success
A sub-path inside the referenced volume.

Sample:
sub_path_example
   
volume_name
string
on success
The name of the volume.

Sample:
volume_name_example
 
working_directory
string
on success
The working directory within the container's filesystem for the container process. If not specified, the default working directory from the image is used.

Sample:
working_directory_example


Authors

  • Oracle (@oracle)