Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
b520ad5
add initial olvm oci requirements
Jan 13, 2025
2cdd309
reset ingress egress to defaults
Jan 13, 2025
761052a
fix dns labels for subnets
Jan 13, 2025
5749579
fix oci vars template
Jan 13, 2025
e7676bb
add host setup
Jan 13, 2025
407ea46
add private subnet vnic
Jan 14, 2025
c1681b4
fix vnic subnet2 name
Jan 14, 2025
4ce731f
fix subnet2 vnic
Jan 14, 2025
817ea95
get instance facts for each instance
Jan 15, 2025
cdf29c2
add get vnic attach facts
Jan 15, 2025
8d1de4d
add serial for secondary vnic
Jan 15, 2025
568c107
grab first array of instances
Jan 15, 2025
35dce4e
fix element
Jan 15, 2025
422a2d2
get and print ip address
Jan 15, 2025
eddfd46
add retry and key_by for vnic
Jan 15, 2025
83894b0
update ansible collections reqs
Jan 15, 2025
3b38f3b
sort secondary vnic on subnet
Jan 15, 2025
73650bc
sort vnic ip by subnet
Jan 15, 2025
34bbb5f
print full output of secondary nic
Jan 16, 2025
21af1b8
json query to limit vnic attachments
Jan 16, 2025
78b1812
test json_query
Jan 16, 2025
eb16375
fix subnet json query
Jan 16, 2025
a3324e8
try json_query again
Jan 16, 2025
b87ece5
another subnet json_query
Jan 16, 2025
3b15bd1
another subnet json_query
Jan 16, 2025
ecfc0f4
another subnet json_query
Jan 16, 2025
4635d9c
another subnet json_query
Jan 16, 2025
fdcbee9
add print hosts and secondary vnic details
Jan 23, 2025
889b82c
update print hosts and secondary nic query
Jan 23, 2025
31903e4
quote ssh common and print subnet2 id
Jan 23, 2025
e009e8c
add lifecycle to compute_instance_facts query
Jan 23, 2025
c709c2d
fix second vnic display name and add fetch ip
Jan 24, 2025
ed1fea0
add debug condition and add to vnic2 ip search
Jan 24, 2025
55b3bd3
add network_vnic_facts
Jan 24, 2025
89e69da
update sec vnic ip
Jan 24, 2025
649bc29
add mac address lookup
Jan 24, 2025
73b397a
add nmcli bits
Jan 24, 2025
5d34355
fix requirements
Jan 24, 2025
084cc4b
fix var for secondary vnic facts
Jan 24, 2025
868293d
fix typo in get interface check
Jan 24, 2025
83776b9
fix nmcli play
Jan 24, 2025
d444529
add sudo to nmcli
Jan 24, 2025
2ee3928
add ovirt-engine install bits
Jan 24, 2025
95db586
move olvm install play and add sudo
Jan 24, 2025
e86f289
remove create kvm vms
Jan 24, 2025
bcfd7d3
fix olvm install steps
Jan 27, 2025
790a360
fix ovirt yum pub repo links
Jan 27, 2025
d542ab4
fix module for ini_file
Jan 27, 2025
e186dba
add retry for dnf
Jan 28, 2025
d3f88bc
add vnc client instance
Jan 28, 2025
09f7a52
remove var option for passwordless ssh
Jan 28, 2025
b59e661
fix var in passwordless
Jan 29, 2025
b6adfbe
add regex to builing host file
Jan 29, 2025
6f21497
fix public ip for ini file
Jan 29, 2025
7d373fc
fix ip for ini file
Jan 29, 2025
e958fdb
change get primary ip method
Jan 29, 2025
a0868be
fix primary ip get
Jan 29, 2025
6a630ea
fix var print for subnet1
Jan 29, 2025
a9c9b69
fix expect resp
Jan 29, 2025
ba0096a
add missing pexpect
Jan 29, 2025
e76148b
change vnc and fix engine install
Jan 29, 2025
ce78171
fix usergroup missing in vnc setup
Jan 29, 2025
b3e8695
fix location of engine-setup
Jan 29, 2025
527edb5
run engine-setup only on olvm server
Jan 29, 2025
29a9869
add timeout of 600s to engine-setup
Jan 31, 2025
0b4d8b0
add hostname to secondary vnic for dns
Feb 13, 2025
0eb3fb4
add passwordless ssh for root
Feb 13, 2025
b23c3c4
add retry for dnf install of vnc and desktop
Feb 13, 2025
cc7e6da
add vdsm port and icmp to ingress and egress
Feb 14, 2025
a6c8005
fix ingress port order for min and max
Feb 14, 2025
ca5896e
add vdsm entries to hosts file
Feb 16, 2025
b8fdfd1
fix inventory short lookup
Feb 16, 2025
3da569e
add dig short to kvm host
Feb 16, 2025
b991da3
fix typo in domain
Feb 16, 2025
6be2a5b
move block storage domain code
Feb 17, 2025
f188597
add loop control var
Feb 17, 2025
124600f
fix typo in create storage yml
Feb 17, 2025
ec74474
add ovirt scripts
Feb 18, 2025
69ac10d
add ovirt vars to defaults
Feb 18, 2025
3488b89
move olvm public key and add download ol9 qcow
Feb 18, 2025
4054750
fix logic for getting secondary fqdn and adding to hosts file
Feb 18, 2025
0dc5d1b
put host file config in block
Feb 19, 2025
6dba815
add pause after host file config
Feb 19, 2025
f3ec0bd
loop over kvm ip results for all groups
Feb 19, 2025
c2b06ac
template add kvm secondary fqdn to hosts file
Feb 19, 2025
b8dedf4
fix hosts template and qcow download
Feb 19, 2025
f992430
add ova and move ovirt tasks
Feb 19, 2025
e833b70
update ovirt plays remove key from vlan vnic attachment
Feb 20, 2025
2a6bf5f
add loop var to build ini inventory groups
Feb 21, 2025
e4ff951
rework code into separate playbooks
Feb 22, 2025
c034331
add noqa to run_once tasks
Feb 22, 2025
83631c3
rework additional playbooks
Feb 22, 2025
beea6bd
refactor more code
Feb 22, 2025
90570f3
adjust ini hosts addition
Feb 22, 2025
d7cc67d
update vcn settings and tweak olvm engine deploy
Feb 23, 2025
4a5868d
fix private route table to service gateway
Feb 23, 2025
357e16b
further adjustments to vcn
Feb 23, 2025
c12af52
adjust vars for fqdn and add public rt to vlan
Feb 24, 2025
55374a0
rename playbooks and add conditional for playbooks
Feb 25, 2025
4aed888
delete pub and priv route tables
Feb 26, 2025
0481b3e
merge in olvm install
Feb 28, 2025
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
249 changes: 249 additions & 0 deletions olvm/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
---
# Copyright (c) 2024 2025 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: Launch an instance
oracle.oci.oci_compute_instance:
availability_domain: "{{ my_availability_domain }}"
compartment_id: "{{ my_compartment_id }}"
name: "{{ item.value.instance_name | default('instance-'~timestamp) }}"
image_id: "{{ ol_image_id }}"
shape: "{{ instance_shape }}"
shape_config:
ocpus: "{{ item.value.instance_ocpus }}"
memory_in_gbs: "{{ item.value.instance_memory }}"
create_vnic_details:
assign_public_ip: true
hostname_label: "{{ item.value.instance_name | default('instance-'~timestamp) }}"
display_name: "public"
subnet_id: "{{ my_subnet1_id }}"
metadata:
ssh_authorized_keys: "{{ lookup('file', lookup('env', 'HOME') + '/.ssh/' + private_key + '.pub') }}"
agent_config:
is_monitoring_disabled: false
is_management_disabled: false
are_all_plugins_disabled: false
plugins_config:
-
name: "OS Management Service Agent"
desired_state: DISABLED
key_by: [compartment_id, availability_domain, display_name]
register: result
vars:
timestamp: "{{ now().strftime('%Y%m%d-%H%M%S') }}"
retries: 10
delay: 30
until: result is not failed

- name: Print instance details
ansible.builtin.debug:
msg:
- "Launched a new instance:"
- "{{ result }}"
when: debug_enabled

- name: Set the compute instance id
ansible.builtin.set_fact:
my_instance_id: "{{ result.instance.id }}"

- name: Set the compute instance display_name
ansible.builtin.set_fact:
instance_display_name: "{{ result.instance.display_name }}"

# - name: Get the primary vnic attachment details of instance
# oracle.oci.oci_compute_vnic_attachment_facts:
# compartment_id: "{{ my_compartment_id }}"
# instance_id: "{{ my_instance_id }}"
# register: result
# retries: 10
# delay: 30
# until: result is not failed

# - name: Get primary vnic details
# oracle.oci.oci_network_vnic_facts:
# vnic_id: "{{ result.vnic_attachments[0].vnic_id }}"
# register: result
# retries: 10
# delay: 30
# until: result is not failed

- name: Set the instance primary private ip address
ansible.builtin.set_fact:
instance_private_ip: "{{ result.instance.primary_private_ip }}"

- name: Set the instance primary public ip address
ansible.builtin.set_fact:
instance_public_ip: "{{ result.instance.primary_public_ip }}"

- name: Add secondary private subnet vnic_attachment
when: item.value.type == "engine"
block:
- name: Create subnet2 vnic_attachment
oracle.oci.oci_compute_vnic_attachment:
compartment_id: "{{ my_compartment_id }}"
create_vnic_details:
assign_public_ip: false
assign_private_dns_record: true
display_name: "vdsm"
hostname_label: "vdsm"
subnet_id: "{{ my_subnet2_id }}"
display_name: "vdsm"
instance_id: "{{ my_instance_id }}"
key_by: [compartment_id, display_name]
register: engine_subnet2
retries: 10
delay: 30
until: engine_subnet2 is not failed

- name: Print vnic_attachment for subnet2
ansible.builtin.debug:
var: engine_subnet2
when: debug_enabled

- name: Add secondary private subnet vnic_attachment
when: item.value.type == "kvm"
block:
- name: Create subnet2 vnic_attachment
oracle.oci.oci_compute_vnic_attachment:
compartment_id: "{{ my_compartment_id }}"
create_vnic_details:
assign_public_ip: false
assign_private_dns_record: true
display_name: "vdsm{{ item.value.instance_name[-2:] }}"
hostname_label: "vdsm{{ item.value.instance_name[-2:] }}"
subnet_id: "{{ my_subnet2_id }}"
display_name: "vdsm{{ item.value.instance_name[-2:] }}"
instance_id: "{{ my_instance_id }}"
key_by: [compartment_id, display_name]
register: kvm_subnet2
retries: 10
delay: 30
until: kvm_subnet2 is not failed

- name: Print vnic_attachment for subnet2
ansible.builtin.debug:
var: kvm_subnet2
when: debug_enabled

- name: Add vlan vnic to instance
when: item.value.type == "kvm"
block:
- name: Create vlan vnic_attachment
oracle.oci.oci_compute_vnic_attachment:
compartment_id: "{{ my_compartment_id }}"
create_vnic_details:
assign_public_ip: false
display_name: "l2-vm-network"
vlan_id: "{{ my_vlan_id }}"
display_name: "l2-vm-network"
instance_id: "{{ my_instance_id }}"
register: kvm_vlan
retries: 10
delay: 30
until: kvm_vlan is not failed

- name: Print vnic_attachment for vlan
ansible.builtin.debug:
var: kvm_vlan
when: debug_enabled

- name: Add block volumes for vm storage domains
ansible.builtin.include_tasks: create_block_storage.yml
loop:
- "amd-storage-domain-01"
- "amd-storage-domain-02"
loop_control:
loop_var: storage_name
when:
- item.value.type == "kvm"

# - name: Add shared block volume to kvm nodes for vm storage
# when:
# - item.value.type == "kvm"
# - add_vm_block_storage
# block:
# - name: Create block volume for vm storage
# oracle.oci.oci_blockstorage_volume:
# compartment_id: "{{ my_compartment_id }}"
# availability_domain: "{{ my_availability_domain }}"
# display_name: "amd-storage-domain-01"
# size_in_gbs: "{{ blk_volume_size_in_gbs }}"
# key_by: [compartment_id, display_name]
# register: kvm_create_block
# retries: 10
# delay: 30
# until: kvm_create_block is not failed

# - name: Set the block storage block volume id
# ansible.builtin.set_fact:
# volume_id: "{{ kvm_create_block.volume.id }}"

# - name: Attach shared block volume for vm storage
# oracle.oci.oci_compute_volume_attachment:
# instance_id: "{{ my_instance_id }}"
# type: paravirtualized
# volume_id: "{{ volume_id }}"
# compartment_id: "{{ my_compartment_id }}"
# is_read_only: false
# is_shareable: true
# register: kvm_add_block
# retries: 10
# delay: 30
# until: kvm_add_block is not failed

- name: Print the public and private ip of the newly created instance
ansible.builtin.debug:
msg:
- "Instance name: {{ instance_display_name }}"
- " public ip: {{ instance_public_ip }}"
- " private ip: {{ instance_private_ip }}"
when: debug_enabled

- name: Add host to in-memory host file
ansible.builtin.add_host:
name: "{{ instance_display_name }}"
groups: "{{ item.value.type }}"
ansible_user: opc
ansible_private_key_file: "{{ lookup('env', 'HOME') + '/.ssh/' + private_key }}"
ansible_ssh_common_args: "-o StrictHostKeyChecking=no"
ansible_host: "{{ instance_public_ip }}"
ansible_port: 22
instance_ocid: "{{ my_instance_id }}"

- name: Create host ini file
ansible.builtin.lineinfile:
path: hosts
regexp: '^\[{{ host_group }}'
line: "[{{ host_group }}]"
create: true
mode: "0664"
delegate_to: localhost
loop:
- engine
- kvm
loop_control:
loop_var: host_group

- name: Add host to ini host file
ansible.builtin.lineinfile:
path: hosts
regexp: '^{{ instance_name }}'
line: >-
{{ instance_name }}
ansible_host={{ instance_ansible_host }}
ansible_user={{ instance_ansible_user }}
ansible_private_key_file={{ instance_ansible_private_key_file }}
ansible_ssh_common_args={{ instance_ansible_ssh_common_args | quote }}
insertafter: '^\[{{ item.value.type }}\]$'
create: true
mode: "664"
delegate_to: localhost
vars:
instance_name: "{{ instance_display_name }}"
instance_ansible_user: opc
instance_ansible_private_key_file: "{{ lookup('env', 'HOME') + '/.ssh/' + private_key }}"
instance_ansible_ssh_common_args: "-o StrictHostKeyChecking=no"
instance_ansible_host: "{{ instance_public_ip }}"
instance_ansible_port: 22
38 changes: 38 additions & 0 deletions olvm/check_instance_available.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# Copyright (c) 2024 2025 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: Configure new instances
hosts: all
gather_facts: false
vars_files:
- default_vars.yml
- oci_vars.yml

tasks:

- name: Wait for systems to become reachable
ansible.builtin.wait_for_connection:
vars:
python_version: "/usr/bin/python3"
ansible_python_interpreter: "{{ python_version if localhost_python_interpreter is defined | default(omit) }}"

- name: Get a set of all available facts
ansible.builtin.setup:

- name: Print in-memory inventory # noqa: run-once[task]
ansible.builtin.debug:
msg: "{{ groups['all'] }}"
delegate_to: localhost
run_once: true
when: debug_enabled

- name: Print all variables/facts known for a host # noqa: run-once[task]
ansible.builtin.debug:
msg: "{{ hostvars[item] }}"
loop: "{{ groups['all'] | flatten(levels=1) }}"
delegate_to: localhost
run_once: true
when: debug_enabled
82 changes: 82 additions & 0 deletions olvm/configure_passwordless_ssh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
# 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: Configure passwordless ssh between hosts
hosts: all
vars_files:
- default_vars.yml
- oci_vars.yml

tasks:

- name: Generate ssh keypair for user
community.crypto.openssh_keypair:
path: ~/.ssh/id_rsa
size: 2048
comment: ol ssh keypair
become: true
become_user: "{{ username }}"

- name: Fetch public key file
ansible.builtin.fetch:
src: "~/.ssh/id_rsa.pub"
dest: "buffer/{{ inventory_hostname }}-id_rsa.pub"
flat: true
become: true
become_user: "{{ username }}"

- name: Copy public key to each destination
ansible.posix.authorized_key:
user: "{{ username }}"
state: present
key: "{{ lookup('file', 'buffer/{{ item }}-id_rsa.pub') }}"
loop: "{{ groups['all'] | flatten(levels=1) }}"
become: true

# - name: Copy public key to each destination for root
# ansible.posix.authorized_key:
# user: "root"
# state: present
# key: "{{ lookup('file', 'buffer/{{ item }}-id_rsa.pub') }}"
# loop: "{{ groups['all'] | flatten(levels=1) }}"
# become: true

- name: Print hostvars for groups
ansible.builtin.debug:
msg: "{{ hostvars[item] }}"
loop: "{{ groups['all'] | flatten(levels=1) }}"
when: debug_enabled

- name: Print vcn subnet_domain_name
ansible.builtin.debug:
var: my_subnet1_domain_name
when: debug_enabled

- name: Accept new ssh fingerprints
ansible.builtin.shell: |
ssh-keyscan -t ecdsa-sha2-nistp256 \
{{ hostvars[item].ansible_hostname }},\
{{ hostvars[item].ansible_default_ipv4.address }},\
{{ hostvars[item].ansible_hostname + '.' + my_subnet1_domain_name }} >> ~/.ssh/known_hosts
with_items:
- "{{ groups['all'] }}"
become: true
become_user: "{{ username }}"
register: result
changed_when: result.rc == 0

# - name: Accept new ssh fingerprints for root
# ansible.builtin.shell: |
# ssh-keyscan -t ecdsa-sha2-nistp256 \
# {{ hostvars[item].ansible_hostname }},\
# {{ hostvars[item].ansible_default_ipv4.address }},\
# {{ hostvars[item].ansible_hostname + '.' + my_subnet1_domain_name }} >> ~/.ssh/known_hosts
# with_items:
# - "{{ groups['all'] }}"
# become: true
# become_user: "root"
# register: result
# changed_when: result.rc == 0
Loading