diff --git a/ol/block.yml b/ol/block.yml new file mode 100644 index 0000000..98eaf3e --- /dev/null +++ b/ol/block.yml @@ -0,0 +1,38 @@ +--- +# Copyright (c) 2024 Oracle and/or its affiliates. +# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0. +# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl) +# See LICENSE.TXT for details. + +- name: Add block volumes to the instance + when: + - add_block_storage + block: + - name: Create block volume + oracle.oci.oci_blockstorage_volume: + compartment_id: "{{ my_compartment_id }}" + availability_domain: "{{ my_availability_domain }}" + display_name: "blockvolume-{{ item.value.instance_name | default('instance-'~timestamp) }}" + size_in_gbs: "{{ block_volume_size_in_gbs }}" + register: result + vars: + timestamp: "{{ now().strftime('%Y%m%d-%H%M%S') }}" + retries: 10 + delay: 30 + until: result is not failed + + - name: Set the block volume id + ansible.builtin.set_fact: + volume_id: "{{ result.volume.id }}" + + - name: Attach the block volume + oracle.oci.oci_compute_volume_attachment: + instance_id: "{{ instance_id }}" + type: paravirtualized + volume_id: "{{ volume_id }}" + compartment_id: "{{ my_compartment_id }}" + is_read_only: false + is_shareable: false + retries: 10 + delay: 30 + until: result is not failed diff --git a/ol/build.yml b/ol/build.yml index b25b92f..74eb009 100644 --- a/ol/build.yml +++ b/ol/build.yml @@ -75,39 +75,9 @@ ansible.builtin.set_fact: instance_public_ip: "{{ result.vnic.public_ip }}" -# - name: Add block volume to worker nodes for ceph storage -# when: -# - item.value.type == "worker" -# - add_ceph_block_storage -# block: -# - name: Create block volume for ceph storage -# oracle.oci.oci_blockstorage_volume: -# compartment_id: "{{ my_compartment_id }}" -# availability_domain: "{{ my_availability_domain }}" -# display_name: "blockvolume-{{ item.value.instance_name | default('instance-'~timestamp) }}" -# size_in_gbs: "{{ ceph_volume_size_in_gbs }}" -# register: result -# vars: -# timestamp: "{{ now().strftime('%Y%m%d-%H%M%S') }}" -# retries: 10 -# delay: 30 -# until: result is not failed - -# - name: Set the ceph storage block volume id -# ansible.builtin.set_fact: -# volume_id: "{{ result.volume.id }}" - -# - name: Attach ceph storage block volume -# oracle.oci.oci_compute_volume_attachment: -# instance_id: "{{ instance_id }}" -# type: paravirtualized -# volume_id: "{{ volume_id }}" -# compartment_id: "{{ my_compartment_id }}" -# is_read_only: false -# is_shareable: false -# retries: 10 -# delay: 30 -# until: result is not failed +- name: Add block storage to an instance + ansible.builtin.include_tasks: "block.yml" + loop: "{{ query('sequence', 'start=1 end='+(block_count)|string) }}" - name: Print the public and private ip of the newly created instance ansible.builtin.debug: diff --git a/ol/default_vars.yml b/ol/default_vars.yml index 1468687..a9d61ba 100644 --- a/ol/default_vars.yml +++ b/ol/default_vars.yml @@ -13,8 +13,9 @@ username: "oracle" usergroup: "{{ username }}" user_default_password: "oracle" debug_enabled: false -#ceph_volume_size_in_gbs: 50 -#add_ceph_deployments: false +add_block_storage: false +block_volume_size_in_gbs: 50 +block_count: 1 use_vnc: false vnc_port: "1"