Skip to content
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
140 changes: 140 additions & 0 deletions olvm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Install Oracle Linux Virtualization Manager in Oracle Cloud Infrastructure (OCI)

This sample includes a series of playbooks that:

- Deploy the OCI resources for an Oracle Linux Virtualization Manager installation
- Virtual Private Network (VCN), Subnets, VLAN (L2), etc.
- An engine and several KVM hosts
- Block Storage

- Provisions a 3-node (default) Oracle Linux Virtualization Manager installation using the included `defaults_vars.yml` file.

## Prerequisites

- Ansible Core (< 2.16 due to compatibility with Python 3.6 in Oracle Linux 8)
- Oracle Cloud Infrastructure SDK for Python
- Ovirt Python SDK version 4
- Python modules - jmespath, passlib
- Access to an OCI tenancy with the proper resources
- SSH public and private key pair for use to connect to the OCI instances

The easiest way to do this is using a Python Virtual environment. For example, on macOS:

1. Create a directory for the virtual environment.

```shell
mkdir python-env
cd python-env
```

1. Create the Python virtual environment.

```shell
python3 -m venv ansible2.16
```

1. Activate the Python virtual environment.

```shell
source ansible2.16/bin/activate
```

1. Install Ansible in the virtual environment.

```shell
python3 -m pip install ansible-core==2.16
```

1. Verify the installation.

```shell
ansible --version
```

The output should report the version as 2.16 if everything installs correctly.

1. Install the OCI SDK for Python

```shell
pip install oci
```

1. Install the oVirt 4 Python SDK

```shell
pip install ovirt-engine-sdk-python
```

1. Install Jmespath and Passlib Python modules.

```shell
pip install jmespath
pip install passlib
```

## Instructions

1. Create a custom variables file.

Rather than modify the `default_vars.yml` file directly, create a new YAML custom variables file. Provide values specific to your tenancy and environment.

> ```text
> ad_placement: <Enter the OCI Availability Domain to use [1,2,3]>
> compartment_id: <Enter the OCID for the compartment within your tenancy>
> private_key: <Enter the name of your SSH key without the extension>
> ```

- The `private_key` variable defaults to looking for the file `id_rsa` in your local users $HOME/.ssh directory
- If your OCI configuration file om `~/.oci/config` has multiple profiles, then also set the variable `oci_config_section` to the profile name.

> Sample:
>
> ```shell
> cat << EOF | tee sample.yml > /dev/null
> ad_placement: 2
> compartment_id: "ocid1.compartment.oc1..aaa..............zzz"
> private_key: "my_sshkey"
> EOF
> ```

1. Install the required collections:

```shell
ansible-galaxy collection install -r requirements.yml
```

1. (Optional) Create an inventory file for localhost.

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.

```shell
cat << EOF | tee hosts > /dev/null
localhost ansible_connection=local ansible_connection=local ansible_python_interpreter=/usr/bin/python3.6
EOF
```

1. Deploy the environment.

```shell
ansible-playbook create_instance.yml -e "@<name of custom vars file>.yml"
```

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.

> Sample:
>
> ```shell
> ansible-playbook create_instance.yml -e "@sample.yml" -e debug_enabled=true
> ```

## Install Oracle Linux Virtualization Engine

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:

- **install_engine:** Runs the *provision_olvm_engine.yml* playbook, which installs the packages for the engine and KVM hosts and then executes `engine-setup`.
- **copy_engine_publickey:** Runs the *provision_olvm_engine_publickey.yml* playbook, which copies the engine public key to each KVM host.
- **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).

## Related Links

Explore our other tutorials and labs on our [Oracle Linux Training Station](www.oracle.com/goto/oltrain).
8 changes: 8 additions & 0 deletions olvm/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- name: Launch an instance
oracle.oci.oci_compute_instance:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
availability_domain: "{{ my_availability_domain }}"
compartment_id: "{{ my_compartment_id }}"
name: "{{ item.value.instance_name | default('instance-'~timestamp) }}"
Expand Down Expand Up @@ -88,6 +90,8 @@
block:
- name: Create subnet2 vnic_attachment
oracle.oci.oci_compute_vnic_attachment:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
create_vnic_details:
assign_public_ip: false
Expand All @@ -113,6 +117,8 @@
block:
- name: Create subnet2 vnic_attachment
oracle.oci.oci_compute_vnic_attachment:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
create_vnic_details:
assign_public_ip: false
Expand All @@ -138,6 +144,8 @@
block:
- name: Create vlan vnic_attachment
oracle.oci.oci_compute_vnic_attachment:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
create_vnic_details:
assign_public_ip: false
Expand Down
6 changes: 6 additions & 0 deletions olvm/configure_secondary_nic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

- name: Get instance details
oracle.oci.oci_compute_instance_facts:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
display_name: "{{ inventory_hostname }}"
sort_by: TIMECREATED
Expand All @@ -33,6 +35,8 @@

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

- name: Get secondary vnic facts
oracle.oci.oci_network_vnic_facts:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
vnic_id: "{{ secondary_vnic_id[0] }}"
delegate_to: localhost
register: secondary_vnic_facts
Expand Down
4 changes: 4 additions & 0 deletions olvm/create_block_storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- name: Create block volume for vm storage
oracle.oci.oci_blockstorage_volume:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
availability_domain: "{{ my_availability_domain }}"
display_name: "{{ storage_name }}"
Expand All @@ -28,6 +30,8 @@

- name: Attach shared block volume for vm storage
oracle.oci.oci_compute_volume_attachment:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
instance_id: "{{ my_instance_id }}"
type: paravirtualized
volume_id: "{{ volume_id }}"
Expand Down
22 changes: 21 additions & 1 deletion olvm/create_instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

- name: Get list availbility domains
oracle.oci.oci_identity_availability_domain_facts:
config_file_location: "{{ coi_config_file | default(omit) }}"
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_tenancy_id }}"
region: "{{ my_region_id }}"
Expand Down Expand Up @@ -118,6 +118,8 @@

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

- name: Create internet gateway
oracle.oci.oci_network_internet_gateway:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
vcn_id: "{{ my_vcn_id }}"
is_enabled: true
Expand All @@ -161,6 +165,8 @@

- name: Get list of services
oracle.oci.oci_network_service_facts:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
register: result
retries: 10
delay: 30
Expand All @@ -187,6 +193,8 @@

- name: Create service gateway
oracle.oci.oci_network_service_gateway:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
services:
- service_id: "{{ my_service_id }}"
Expand All @@ -210,6 +218,8 @@

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

- name: Create route table for private subnet
oracle.oci.oci_network_route_table:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
vcn_id: "{{ my_vcn_id }}"
display_name: "Route Table for Private Subnet-OLV-VCN"
Expand Down Expand Up @@ -294,6 +306,8 @@

- name: Create security_list
oracle.oci.oci_network_security_list:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
display_name: "Default Security List for OLV-VCN"
compartment_id: "{{ my_compartment_id }}"
vcn_id: "{{ my_vcn_id }}"
Expand All @@ -316,6 +330,8 @@

- name: Create public subnet
oracle.oci.oci_network_subnet:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
vcn_id: "{{ my_vcn_id }}"
cidr_block: "{{ subnet1_cidr_block }}"
Expand Down Expand Up @@ -345,6 +361,8 @@

- name: Create private subnet
oracle.oci.oci_network_subnet:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
vcn_id: "{{ my_vcn_id }}"
cidr_block: "{{ subnet2_cidr_block }}"
Expand Down Expand Up @@ -383,6 +401,8 @@

- name: Get image
oracle.oci.oci_compute_image_facts:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
operating_system: "{{ os }}"
operating_system_version: "{{ os_version }}"
Expand Down
6 changes: 6 additions & 0 deletions olvm/create_vlan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- name: Create network_security_group
oracle.oci.oci_network_security_group:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
compartment_id: "{{ my_compartment_id }}"
vcn_id: "{{ my_vcn_id }}"
display_name: "L2 Network"
Expand All @@ -26,6 +28,8 @@

- name: Perform action add on network_security_group_security_rule
oracle.oci.oci_network_security_group_security_rule_actions:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
network_security_group_id: "{{ my_l2_vlan_nsg_id }}"
action: add
security_rules:
Expand All @@ -46,6 +50,8 @@

- name: Create a vlan
oracle.oci.oci_network_vlan:
config_file_location: "{{ oci_config_file | default(omit) }}"
config_profile_name: "{{ oci_config_section | default(omit) }}"
cidr_block: "{{ vlan_cidr_block }}"
compartment_id: "{{ my_compartment_id }}"
display_name: "VLAN-VMs"
Expand Down
1 change: 1 addition & 0 deletions olvm/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ collections:
- freeipa.ansible_freeipa
- community.libvirt
- oracle.oci
- ovirt.ovirt
Loading