使用 Ansible 改变 Shape OCI 实例

Change Shape OCI instance with Ansible

是否可以通过 Ansible 更改 Oracle 云实例的形状?我没有找到执行此操作的模块(我只找到了获取形状模块)。

您可以使用 oci_instance 模块更改实例的形状,使用如下操作:

- name: Create Instance
  oci_instance:
    name: "example_name"
    image_id: "ocid1.image.oc1.iad.EXAMPLE"
    shape: "VM.Standard2.1"
    compartment_id: "ocid1.compartment.oc1..EXAMPLE"
    availability_domain: "IwGV:US-EXAMPLE-AD-1"
    vnic:
      subnet_id: "ocid1.subnet.oc1.iad.EXAMPLE"
  register: result

- name: Update Instance shape
  oci_instance:
    id: "{{ result.instance.id }}"
    shape: "VM.Standard1.1"
    state: "present"

更改需要一段时间才能反映出来,因为实例需要在形状更改过程后重新启动。您可以在 OCI 控制台页面查看形状变化过程。