|
4 | 4 | # The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
|
5 | 5 | # See LICENSE.TXT for details.
|
6 | 6 |
|
7 |
| -- name: Launch an instance |
| 7 | +- name: Launch an instance using PV BV |
8 | 8 | oracle.oci.oci_compute_instance:
|
9 | 9 | availability_domain: "{{ my_availability_domain }}"
|
10 | 10 | compartment_id: "{{ my_compartment_id }}"
|
|
33 | 33 | desired_state: DISABLED
|
34 | 34 | key_by: [compartment_id, availability_domain, display_name]
|
35 | 35 | register: result
|
| 36 | + when: volume_type != "iscsi" |
| 37 | + vars: |
| 38 | + timestamp: "{{ now().strftime('%Y%m%d-%H%M%S') }}" |
| 39 | + retries: 10 |
| 40 | + delay: 30 |
| 41 | + until: result is not failed |
| 42 | + |
| 43 | +- name: Launch an instance using iSCSI BV |
| 44 | + oracle.oci.oci_compute_instance: |
| 45 | + availability_domain: "{{ my_availability_domain }}" |
| 46 | + compartment_id: "{{ my_compartment_id }}" |
| 47 | + name: "{{ item.value.instance_name | default('instance-'~timestamp) }}" |
| 48 | + source_details: |
| 49 | + image_id: "{{ ol_image_id }}" |
| 50 | + source_type: image |
| 51 | + boot_volume_size_in_gbs: "{{ item.value.boot_volume_size_in_gbs | default(50) | int }}" |
| 52 | + shape: "{{ instance_shape }}" |
| 53 | + shape_config: |
| 54 | + ocpus: "{{ instance_ocpus }}" |
| 55 | + memory_in_gbs: "{{ instance_memory }}" |
| 56 | + create_vnic_details: |
| 57 | + assign_public_ip: true |
| 58 | + hostname_label: "{{ item.value.instance_name | default('instance-'~timestamp) }}" |
| 59 | + subnet_id: "{{ my_subnet_id }}" |
| 60 | + metadata: |
| 61 | + ssh_authorized_keys: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/' + private_key + '.pub') }}" |
| 62 | + agent_config: |
| 63 | + is_monitoring_disabled: false |
| 64 | + is_management_disabled: false |
| 65 | + are_all_plugins_disabled: false |
| 66 | + plugins_config: |
| 67 | + - name: "OS Management Service Agent" |
| 68 | + desired_state: DISABLED |
| 69 | + - name: "Block Volume Management" |
| 70 | + desired_state: ENABLED |
| 71 | + key_by: [compartment_id, availability_domain, display_name] |
| 72 | + register: result |
| 73 | + when: volume_type == "iscsi" |
36 | 74 | vars:
|
37 | 75 | timestamp: "{{ now().strftime('%Y%m%d-%H%M%S') }}"
|
38 | 76 | retries: 10
|
|
96 | 134 | - h
|
97 | 135 | - i
|
98 | 136 |
|
| 137 | +- name: Add host level block volume |
| 138 | + when: item.value.add_bv | default('false') | bool |
| 139 | + block: |
| 140 | + - name: Create block volume |
| 141 | + oracle.oci.oci_blockstorage_volume: |
| 142 | + compartment_id: "{{ my_compartment_id }}" |
| 143 | + availability_domain: "{{ my_availability_domain }}" |
| 144 | + display_name: "bv-ocfs2" |
| 145 | + size_in_gbs: "{{ block_volume_size_in_gbs }}" |
| 146 | + key_by: [compartment_id, display_name] |
| 147 | + register: create_bv |
| 148 | + retries: 10 |
| 149 | + delay: 30 |
| 150 | + until: create_bv is not failed |
| 151 | + |
| 152 | + - name: Set the block volume id |
| 153 | + ansible.builtin.set_fact: |
| 154 | + volume_id: "{{ create_bv.volume.id }}" |
| 155 | + |
| 156 | + - name: Attach the block volume |
| 157 | + oracle.oci.oci_compute_volume_attachment: |
| 158 | + instance_id: "{{ instance_id }}" |
| 159 | + type: "{{ volume_type }}" |
| 160 | + volume_id: "{{ volume_id }}" |
| 161 | + compartment_id: "{{ my_compartment_id }}" |
| 162 | + device: "/dev/oracleoci/oraclevdo" |
| 163 | + display_name: "blockvolume-vdo" |
| 164 | + is_agent_auto_iscsi_login_enabled: true |
| 165 | + is_read_only: false |
| 166 | + is_shareable: true |
| 167 | + register: attach_bv |
| 168 | + retries: 10 |
| 169 | + delay: 30 |
| 170 | + until: attach_bv is not failed |
| 171 | + |
| 172 | + |
99 | 173 | - name: Print the public and private ip of the newly created instance
|
100 | 174 | ansible.builtin.debug:
|
101 | 175 | msg:
|
|
0 commit comments