oci_vnic_attachment - Create a secondary VNIC and attach it to a compute instance, detach or delete VNIC attachments from a compute instance.

New in version 2.5.

Synopsis

  • This module allows the user to create a secondary VNIC and attach it to a compute instance, detach a secondary VNIC attachment from a compute instance, and delete the secondary VNIC.

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.
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
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.
display_name
A user-friendly name to be associated with the VNIC attachment. This does not have to be unique, and can be changed later.

aliases: name
instance_id
The OCID of the instance to which the secondary VNIC must be attached. Required when a secondary VNIC needs to be created and attached to an instance with state=present.
nic_index
Specifies the physical network interface card (NIC) the VNIC will use. Defaults to 0. Certain bare metal instance shapes have two active physical NICs (0 and 1). When a secondary VNIC is added to one of these instances, the NIC that the VNIC will use can be specified using nic_index. This option may be specified while creating a VNIC and attaching to an instance using state=present.
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
    Choices:
  • present ←
  • absent
The state of the VNIC attachment that must be asserted to. When state=present, and the VNIC attachment doesn't exist, the secondary VNIC is created with the specified details, and is attached to the specified compute instance. When state=absent, the secondary VNIC is detached from the compute instance and 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
vnic
Details for creating a new secondary VNIC. This option must be specified when a secondary VNIC needs to be created and associated with an instance using state=present.

aliases: create_vnic_details
display_name
A user-friendly name for the VNIC. Does not have to be unique.
hostname_label
The hostname for the VNIC's primary private IP. Used for DNS. The value is the hostname portion of the primary private IP's fully qualified domain name (FQDN) (for example, bminstance-1 in FQDN bminstance-1.subnet123.vcn1.oraclevcn.com). Must be unique across all VNICs in the subnet and comply with RFC 952 and RFC 1123.
subnet_id
required
The OCID of the subnet to create the VNIC in.
defined_tags
Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm.
freeform_tags
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 https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm.
skip_source_dest_check Default:
no
Determines whether the source/destination check is disabled on the VNIC. Defaults to false, which means the check is performed.
private_ip
The private IP to assign to the VNIC. Must be an available IP address within the subnet's CIDR. If you don't specify a value, Oracle automatically assigns a private IP address from the subnet. This is the VNIC's primary private IP address.
assign_public_ip
Determines whether the secondary VNIC should be assigned a public IP address. If not set and the VNIC is being created in a private subnet (that is, where prohibitPublicIpOnVnic = true in the Subnet), then no public IP address is assigned. If not set and the subnet is public prohibitPublicIpOnVnic = false, then a public IP address is assigned. If set to true and prohibitPublicIpOnVnic = true, an error is returned.
vnic_attachment_id
The OCID of the VNIC attachment. Required when a secondary VNIC needs to be detached from a compute instance and deleted using state=absent.

aliases: id
wait
bool
    Choices:
  • no
  • yes ←
Whether to wait for create or delete operation to complete.
wait_timeout Default:
1200
Time, in seconds, to wait when wait=yes.
wait_until
The lifecycle state to wait for the resource to transition into when wait=yes. By default, when wait=yes, we wait for the resource to get into ACTIVE/ATTACHED/AVAILABLE/PROVISIONED/ RUNNING applicable lifecycle state during create operation & to get into DELETED/DETACHED/ TERMINATED lifecycle state during delete operation.

Examples

- name: Create a new secondary VNIC and attach it to the specified compute instance
  oci_vnic_attachment:
    name: sec-vnic1-to-instance1
    instance_id: "ocid1.instance.oc1.phx.xxxxxEXAMPLExxxxx....dszaitd3da"
    nicindex: 1
    vnic:
        hostname_label: "myinstance1_1"
        private_ip: "10.0.0.6"
        subnet_id: "ocid1.subnet.oc1.phx.xxxxxEXAMPLExxxxx...5iddusmpqpaoa"

- name: Detach a secondary VNIC from an instance and delete the VNIC
  oci_vnic_attachment:
        id: "ocid1.vnic.oc1.phx.xxxxxEXAMPLExxxxx...lxasdsadgdq"
        state: "absent"

Return Values

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

Key Returned Description
vnic_attachment
complex
On success
Details of the VNIC attachment

Sample:
{'lifecycle_state': 'DETACHED', 'availability_domain': 'BnQb:PHX-AD-1', 'display_name': 'sec_vnic_1_for_my_instance', 'compartment_id': 'ocid1.compartment.oc1..xxxxxEXAMPLExxxxx...m62xq', 'subnet_id': 'ocid1.subnet.oc1.phx.xxxxxEXAMPLExxxxx...mpqpaoa', 'time_created': '2017-11-26T16:24:35.487000+00:00', 'instance_id': 'ocid1.instance.oc1.phx.xxxxxEXAMPLExxxxx...qkwr6q', 'vnic_id': 'ocid1.vnic.oc1.phx.xxxxxEXAMPLExxxxx...mv2beqa', 'vlan_tag': 41, 'id': 'ocid1.vnicattachment.oc1.phx.xxxxxEXAMPLExxxxx...3momq'}
  lifecycle_state
string
always
The current state of the VNIC attachment.

Sample:
DETACHED
  availability_domain
string
always
The Availability Domain of the instance.

Sample:
Uocm:PHX-AD-1
  display_name
string
always
A user-friendly name. Does not have to be unique.

Sample:
sec_vnic1_for_my_instance
  compartment_id
string
always
The OCID of the compartment the VNIC attachment is in, which is the same compartment the instance is in.

Sample:
ocid1.compartment.oc1..xxxxxEXAMPLExxxxx...m62xq
  subnet_id
string
always
The OCID of the VNIC's subnet.

Sample:
ocid1.subnet.oc1.phx.xxxxxEXAMPLExxxxx...mpqpaoa
  time_created
string
always
The date and time the VNIC attachment was created, in the format defined by RFC3339.

Sample:
2017-11-26 16:24:35.487000
  instance_id
string
always
The OCID of the instance.

Sample:
ocid1.instance.oc1.phx.xxxxxEXAMPLExxxxx...qkwr6q
  vnic_id
string
always
The OCID of the VNIC. Available after the attachment process is complete.

Sample:
ocid1.vnic.oc1.phx.xxxxxEXAMPLExxxxx...mv2beqa
  vlan_tag
string
always
The Oracle-assigned VLAN tag of the attached VNIC. Available after the attachment process is complete.

Sample:
41
  id
string
always
The OCID of the VNIC attachment.

Sample:
ocid1.vnicattachment.oc1.phx.xxxxxEXAMPLExxxxx...3momq


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

  • Sivakumar Thyagarajan (@sivakumart)

Hint

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