Skip to content

Commit da81f9c

Browse files
authored
Merge pull request #69 from bgraef/main
merge in state file and other updates
2 parents 0a21eb9 + 05cf1c7 commit da81f9c

File tree

8 files changed

+220
-1
lines changed

8 files changed

+220
-1
lines changed

olvm/README.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Install Oracle Linux Virtualization Manager in Oracle Cloud Infrastructure (OCI)
2+
3+
This sample includes a series of playbooks that:
4+
5+
- Deploy the OCI resources for an Oracle Linux Virtualization Manager installation
6+
- Virtual Private Network (VCN), Subnets, VLAN (L2), etc.
7+
- An engine and several KVM hosts
8+
- Block Storage
9+
10+
- Provisions a 3-node (default) Oracle Linux Virtualization Manager installation using the included `defaults_vars.yml` file.
11+
12+
## Prerequisites
13+
14+
- Ansible Core (< 2.16 due to compatibility with Python 3.6 in Oracle Linux 8)
15+
- Oracle Cloud Infrastructure SDK for Python
16+
- Ovirt Python SDK version 4
17+
- Python modules - jmespath, passlib
18+
- Access to an OCI tenancy with the proper resources
19+
- SSH public and private key pair for use to connect to the OCI instances
20+
21+
The easiest way to do this is using a Python Virtual environment. For example, on macOS:
22+
23+
1. Create a directory for the virtual environment.
24+
25+
```shell
26+
mkdir python-env
27+
cd python-env
28+
```
29+
30+
1. Create the Python virtual environment.
31+
32+
```shell
33+
python3 -m venv ansible2.16
34+
```
35+
36+
1. Activate the Python virtual environment.
37+
38+
```shell
39+
source ansible2.16/bin/activate
40+
```
41+
42+
1. Install Ansible in the virtual environment.
43+
44+
```shell
45+
python3 -m pip install ansible-core==2.16
46+
```
47+
48+
1. Verify the installation.
49+
50+
```shell
51+
ansible --version
52+
```
53+
54+
The output should report the version as 2.16 if everything installs correctly.
55+
56+
1. Install the OCI SDK for Python
57+
58+
```shell
59+
pip install oci
60+
```
61+
62+
1. Install the oVirt 4 Python SDK
63+
64+
```shell
65+
pip install ovirt-engine-sdk-python
66+
```
67+
68+
1. Install Jmespath and Passlib Python modules.
69+
70+
```shell
71+
pip install jmespath
72+
pip install passlib
73+
```
74+
75+
## Instructions
76+
77+
1. Create a custom variables file.
78+
79+
Rather than modify the `default_vars.yml` file directly, create a new YAML custom variables file. Provide values specific to your tenancy and environment.
80+
81+
> ```text
82+
> ad_placement: <Enter the OCI Availability Domain to use [1,2,3]>
83+
> compartment_id: <Enter the OCID for the compartment within your tenancy>
84+
> private_key: <Enter the name of your SSH key without the extension>
85+
> ```
86+
87+
- The `private_key` variable defaults to looking for the file `id_rsa` in your local users $HOME/.ssh directory
88+
- If your OCI configuration file om `~/.oci/config` has multiple profiles, then also set the variable `oci_config_section` to the profile name.
89+
90+
> Sample:
91+
>
92+
> ```shell
93+
> cat << EOF | tee sample.yml > /dev/null
94+
> ad_placement: 2
95+
> compartment_id: "ocid1.compartment.oc1..aaa..............zzz"
96+
> private_key: "my_sshkey"
97+
> EOF
98+
> ```
99+
100+
1. Install the required collections:
101+
102+
```shell
103+
ansible-galaxy collection install -r requirements.yml
104+
```
105+
106+
1. (Optional) Create an inventory file for localhost.
107+
108+
The control node requires this step in environments that use non-venv environments for Python and Ansible to ensure that Ansible can find the OCI and oVirt modules.
109+
110+
```shell
111+
cat << EOF | tee hosts > /dev/null
112+
localhost ansible_connection=local ansible_connection=local ansible_python_interpreter=/usr/bin/python3.6
113+
EOF
114+
```
115+
116+
1. Deploy the environment.
117+
118+
```shell
119+
ansible-playbook create_instance.yml -e "@<name of custom vars file>.yml"
120+
```
121+
122+
You can pass extra variables or variable files on the `ansible-playbook` command line using `-e` or `--extra-vars`. Ansible treats these variables as having the highest precedence and reads them from the command line from left to right.
123+
124+
> Sample:
125+
>
126+
> ```shell
127+
> ansible-playbook create_instance.yml -e "@sample.yml" -e debug_enabled=true
128+
> ```
129+
130+
## Install Oracle Linux Virtualization Engine
131+
132+
The `default_vars.yml` file contains several variables that enable you to automate steps in the setup and configuration of Oracle Linux Virtualization Manager. Here is a list of those variables and what they do:
133+
134+
- **install_engine:** Runs the *provision_olvm_engine.yml* playbook, which installs the packages for the engine and KVM hosts and then executes `engine-setup`.
135+
- **copy_engine_publickey:** Runs the *provision_olvm_engine_publickey.yml* playbook, which copies the engine public key to each KVM host.
136+
- **config_olvm:** Runs a series of *ovirt* playbooks that configure Oracle Linux Virtualization Manager based on the steps provided in the associated [lab](https://luna.oracle.com/lab/c912c867-a5cd-420e-9ee5-ee9017b2b957).
137+
138+
## Related Links
139+
140+
Explore our other tutorials and labs on our [Oracle Linux Training Station](www.oracle.com/goto/oltrain).

olvm/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- name: Launch an instance
88
oracle.oci.oci_compute_instance:
9+
config_file_location: "{{ oci_config_file | default(omit) }}"
10+
config_profile_name: "{{ oci_config_section | default(omit) }}"
911
availability_domain: "{{ my_availability_domain }}"
1012
compartment_id: "{{ my_compartment_id }}"
1113
name: "{{ item.value.instance_name | default('instance-'~timestamp) }}"
@@ -88,6 +90,8 @@
8890
block:
8991
- name: Create subnet2 vnic_attachment
9092
oracle.oci.oci_compute_vnic_attachment:
93+
config_file_location: "{{ oci_config_file | default(omit) }}"
94+
config_profile_name: "{{ oci_config_section | default(omit) }}"
9195
compartment_id: "{{ my_compartment_id }}"
9296
create_vnic_details:
9397
assign_public_ip: false
@@ -113,6 +117,8 @@
113117
block:
114118
- name: Create subnet2 vnic_attachment
115119
oracle.oci.oci_compute_vnic_attachment:
120+
config_file_location: "{{ oci_config_file | default(omit) }}"
121+
config_profile_name: "{{ oci_config_section | default(omit) }}"
116122
compartment_id: "{{ my_compartment_id }}"
117123
create_vnic_details:
118124
assign_public_ip: false
@@ -138,6 +144,8 @@
138144
block:
139145
- name: Create vlan vnic_attachment
140146
oracle.oci.oci_compute_vnic_attachment:
147+
config_file_location: "{{ oci_config_file | default(omit) }}"
148+
config_profile_name: "{{ oci_config_section | default(omit) }}"
141149
compartment_id: "{{ my_compartment_id }}"
142150
create_vnic_details:
143151
assign_public_ip: false

olvm/configure_secondary_nic.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
- name: Get instance details
1717
oracle.oci.oci_compute_instance_facts:
18+
config_file_location: "{{ oci_config_file | default(omit) }}"
19+
config_profile_name: "{{ oci_config_section | default(omit) }}"
1820
compartment_id: "{{ my_compartment_id }}"
1921
display_name: "{{ inventory_hostname }}"
2022
sort_by: TIMECREATED
@@ -33,6 +35,8 @@
3335

3436
- name: Get vnic attachments of a specific instance
3537
oracle.oci.oci_compute_vnic_attachment_facts:
38+
config_file_location: "{{ oci_config_file | default(omit) }}"
39+
config_profile_name: "{{ oci_config_section | default(omit) }}"
3640
compartment_id: "{{ my_compartment_id }}"
3741
instance_id: "{{ instance_details.instances[0].id }}"
3842
delegate_to: localhost
@@ -64,6 +68,8 @@
6468

6569
- name: Get secondary vnic facts
6670
oracle.oci.oci_network_vnic_facts:
71+
config_file_location: "{{ oci_config_file | default(omit) }}"
72+
config_profile_name: "{{ oci_config_section | default(omit) }}"
6773
vnic_id: "{{ secondary_vnic_id[0] }}"
6874
delegate_to: localhost
6975
register: secondary_vnic_facts

olvm/create_block_storage.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- name: Create block volume for vm storage
88
oracle.oci.oci_blockstorage_volume:
9+
config_file_location: "{{ oci_config_file | default(omit) }}"
10+
config_profile_name: "{{ oci_config_section | default(omit) }}"
911
compartment_id: "{{ my_compartment_id }}"
1012
availability_domain: "{{ my_availability_domain }}"
1113
display_name: "{{ storage_name }}"
@@ -28,6 +30,8 @@
2830

2931
- name: Attach shared block volume for vm storage
3032
oracle.oci.oci_compute_volume_attachment:
33+
config_file_location: "{{ oci_config_file | default(omit) }}"
34+
config_profile_name: "{{ oci_config_section | default(omit) }}"
3135
instance_id: "{{ my_instance_id }}"
3236
type: paravirtualized
3337
volume_id: "{{ volume_id }}"

olvm/create_instance.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
- name: Get list availbility domains
5656
oracle.oci.oci_identity_availability_domain_facts:
57-
config_file_location: "{{ coi_config_file | default(omit) }}"
57+
config_file_location: "{{ oci_config_file | default(omit) }}"
5858
config_profile_name: "{{ oci_config_section | default(omit) }}"
5959
compartment_id: "{{ my_tenancy_id }}"
6060
region: "{{ my_region_id }}"
@@ -118,6 +118,8 @@
118118

119119
- name: Create a virtual cloud network
120120
oracle.oci.oci_network_vcn:
121+
config_file_location: "{{ oci_config_file | default(omit) }}"
122+
config_profile_name: "{{ oci_config_section | default(omit) }}"
121123
compartment_id: "{{ my_compartment_id }}"
122124
display_name: "OLV-VCN"
123125
cidr_blocks: "10.0.0.0/16"
@@ -139,6 +141,8 @@
139141

140142
- name: Create internet gateway
141143
oracle.oci.oci_network_internet_gateway:
144+
config_file_location: "{{ oci_config_file | default(omit) }}"
145+
config_profile_name: "{{ oci_config_section | default(omit) }}"
142146
compartment_id: "{{ my_compartment_id }}"
143147
vcn_id: "{{ my_vcn_id }}"
144148
is_enabled: true
@@ -161,6 +165,8 @@
161165

162166
- name: Get list of services
163167
oracle.oci.oci_network_service_facts:
168+
config_file_location: "{{ oci_config_file | default(omit) }}"
169+
config_profile_name: "{{ oci_config_section | default(omit) }}"
164170
register: result
165171
retries: 10
166172
delay: 30
@@ -187,6 +193,8 @@
187193

188194
- name: Create service gateway
189195
oracle.oci.oci_network_service_gateway:
196+
config_file_location: "{{ oci_config_file | default(omit) }}"
197+
config_profile_name: "{{ oci_config_section | default(omit) }}"
190198
compartment_id: "{{ my_compartment_id }}"
191199
services:
192200
- service_id: "{{ my_service_id }}"
@@ -210,6 +218,8 @@
210218

211219
- name: Create route table for public subnet
212220
oracle.oci.oci_network_route_table:
221+
config_file_location: "{{ oci_config_file | default(omit) }}"
222+
config_profile_name: "{{ oci_config_section | default(omit) }}"
213223
compartment_id: "{{ my_compartment_id }}"
214224
vcn_id: "{{ my_vcn_id }}"
215225
display_name: "Default Route Table for OLV-VCN"
@@ -236,6 +246,8 @@
236246

237247
- name: Create route table for private subnet
238248
oracle.oci.oci_network_route_table:
249+
config_file_location: "{{ oci_config_file | default(omit) }}"
250+
config_profile_name: "{{ oci_config_section | default(omit) }}"
239251
compartment_id: "{{ my_compartment_id }}"
240252
vcn_id: "{{ my_vcn_id }}"
241253
display_name: "Route Table for Private Subnet-OLV-VCN"
@@ -294,6 +306,8 @@
294306

295307
- name: Create security_list
296308
oracle.oci.oci_network_security_list:
309+
config_file_location: "{{ oci_config_file | default(omit) }}"
310+
config_profile_name: "{{ oci_config_section | default(omit) }}"
297311
display_name: "Default Security List for OLV-VCN"
298312
compartment_id: "{{ my_compartment_id }}"
299313
vcn_id: "{{ my_vcn_id }}"
@@ -316,6 +330,8 @@
316330

317331
- name: Create public subnet
318332
oracle.oci.oci_network_subnet:
333+
config_file_location: "{{ oci_config_file | default(omit) }}"
334+
config_profile_name: "{{ oci_config_section | default(omit) }}"
319335
compartment_id: "{{ my_compartment_id }}"
320336
vcn_id: "{{ my_vcn_id }}"
321337
cidr_block: "{{ subnet1_cidr_block }}"
@@ -345,6 +361,8 @@
345361

346362
- name: Create private subnet
347363
oracle.oci.oci_network_subnet:
364+
config_file_location: "{{ oci_config_file | default(omit) }}"
365+
config_profile_name: "{{ oci_config_section | default(omit) }}"
348366
compartment_id: "{{ my_compartment_id }}"
349367
vcn_id: "{{ my_vcn_id }}"
350368
cidr_block: "{{ subnet2_cidr_block }}"
@@ -383,6 +401,8 @@
383401

384402
- name: Get image
385403
oracle.oci.oci_compute_image_facts:
404+
config_file_location: "{{ oci_config_file | default(omit) }}"
405+
config_profile_name: "{{ oci_config_section | default(omit) }}"
386406
compartment_id: "{{ my_compartment_id }}"
387407
operating_system: "{{ os }}"
388408
operating_system_version: "{{ os_version }}"

olvm/create_vlan.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
- name: Create network_security_group
88
oracle.oci.oci_network_security_group:
9+
config_file_location: "{{ oci_config_file | default(omit) }}"
10+
config_profile_name: "{{ oci_config_section | default(omit) }}"
911
compartment_id: "{{ my_compartment_id }}"
1012
vcn_id: "{{ my_vcn_id }}"
1113
display_name: "L2 Network"
@@ -26,6 +28,8 @@
2628

2729
- name: Perform action add on network_security_group_security_rule
2830
oracle.oci.oci_network_security_group_security_rule_actions:
31+
config_file_location: "{{ oci_config_file | default(omit) }}"
32+
config_profile_name: "{{ oci_config_section | default(omit) }}"
2933
network_security_group_id: "{{ my_l2_vlan_nsg_id }}"
3034
action: add
3135
security_rules:
@@ -46,6 +50,8 @@
4650

4751
- name: Create a vlan
4852
oracle.oci.oci_network_vlan:
53+
config_file_location: "{{ oci_config_file | default(omit) }}"
54+
config_profile_name: "{{ oci_config_section | default(omit) }}"
4955
cidr_block: "{{ vlan_cidr_block }}"
5056
compartment_id: "{{ my_compartment_id }}"
5157
display_name: "VLAN-VMs"

olvm/requirements.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ collections:
1414
- freeipa.ansible_freeipa
1515
- community.libvirt
1616
- oracle.oci
17+
- ovirt.ovirt

0 commit comments

Comments
 (0)