Skip to content

Commit 426f041

Browse files
author
William Graef
committed
add block volumes to instance by count
1 parent b7eb1d8 commit 426f041

File tree

3 files changed

+44
-35
lines changed

3 files changed

+44
-35
lines changed

ol/block.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
# Copyright (c) 2024 Oracle and/or its affiliates.
3+
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
4+
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
5+
# See LICENSE.TXT for details.
6+
7+
- name: Add block volumes to the instance
8+
when:
9+
- add_block_storage
10+
block:
11+
- name: Create block volume
12+
oracle.oci.oci_blockstorage_volume:
13+
compartment_id: "{{ my_compartment_id }}"
14+
availability_domain: "{{ my_availability_domain }}"
15+
display_name: "blockvolume-{{ item.value.instance_name | default('instance-'~timestamp) }}"
16+
size_in_gbs: "{{ block_volume_size_in_gbs }}"
17+
register: result
18+
vars:
19+
timestamp: "{{ now().strftime('%Y%m%d-%H%M%S') }}"
20+
retries: 10
21+
delay: 30
22+
until: result is not failed
23+
24+
- name: Set the block volume id
25+
ansible.builtin.set_fact:
26+
volume_id: "{{ result.volume.id }}"
27+
28+
- name: Attach the block volume
29+
oracle.oci.oci_compute_volume_attachment:
30+
instance_id: "{{ instance_id }}"
31+
type: paravirtualized
32+
volume_id: "{{ volume_id }}"
33+
compartment_id: "{{ my_compartment_id }}"
34+
is_read_only: false
35+
is_shareable: false
36+
retries: 10
37+
delay: 30
38+
until: result is not failed

ol/build.yml

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -75,39 +75,9 @@
7575
ansible.builtin.set_fact:
7676
instance_public_ip: "{{ result.vnic.public_ip }}"
7777

78-
# - name: Add block volume to worker nodes for ceph storage
79-
# when:
80-
# - item.value.type == "worker"
81-
# - add_ceph_block_storage
82-
# block:
83-
# - name: Create block volume for ceph storage
84-
# oracle.oci.oci_blockstorage_volume:
85-
# compartment_id: "{{ my_compartment_id }}"
86-
# availability_domain: "{{ my_availability_domain }}"
87-
# display_name: "blockvolume-{{ item.value.instance_name | default('instance-'~timestamp) }}"
88-
# size_in_gbs: "{{ ceph_volume_size_in_gbs }}"
89-
# register: result
90-
# vars:
91-
# timestamp: "{{ now().strftime('%Y%m%d-%H%M%S') }}"
92-
# retries: 10
93-
# delay: 30
94-
# until: result is not failed
95-
96-
# - name: Set the ceph storage block volume id
97-
# ansible.builtin.set_fact:
98-
# volume_id: "{{ result.volume.id }}"
99-
100-
# - name: Attach ceph storage block volume
101-
# oracle.oci.oci_compute_volume_attachment:
102-
# instance_id: "{{ instance_id }}"
103-
# type: paravirtualized
104-
# volume_id: "{{ volume_id }}"
105-
# compartment_id: "{{ my_compartment_id }}"
106-
# is_read_only: false
107-
# is_shareable: false
108-
# retries: 10
109-
# delay: 30
110-
# until: result is not failed
78+
- name: Add block storage to an instance
79+
ansible.builtin.include_tasks: "block.yml"
80+
loop: "{{ query('sequence', 'start=1 end='+(block_count)|string) }}"
11181

11282
- name: Print the public and private ip of the newly created instance
11383
ansible.builtin.debug:

ol/default_vars.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ username: "oracle"
1313
usergroup: "{{ username }}"
1414
user_default_password: "oracle"
1515
debug_enabled: false
16-
#ceph_volume_size_in_gbs: 50
17-
#add_ceph_deployments: false
16+
add_block_storage: false
17+
block_volume_size_in_gbs: 50
18+
block_count: 1
1819

1920
use_vnc: false
2021
vnc_port: "1"

0 commit comments

Comments
 (0)