Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add block volumes to instance by count #28

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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