Skip to content

Commit

Permalink
add block volumes to instance by count
Browse files Browse the repository at this point in the history
  • Loading branch information
bgraef committed Aug 12, 2024
1 parent b7eb1d8 commit 426f041
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 35 deletions.
38 changes: 38 additions & 0 deletions ol/block.yml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 3 additions & 33 deletions ol/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions ol/default_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 426f041

Please sign in to comment.