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 code for olam kvm lab #45

Merged
merged 2 commits into from
Dec 20, 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
14 changes: 9 additions & 5 deletions olam/create_instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
- use_olae_only

- name: Install Oracle Linux Automation Manager
ansible.builtin.include_tasks: deploy_olam_tasks.yml
ansible.builtin.include_tasks: deploy_olam_single.yml
vars:
control_node_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
when:
Expand All @@ -334,14 +334,18 @@
ansible.builtin.import_playbook: update_all_rpms.yml
when: update_all

- name: Install free ipa server
ansible.builtin.import_playbook: deploy_free_ipa.yml
- name: Provision free ipa server
ansible.builtin.import_playbook: provision_free_ipa.yml
when: use_freeipa

- name: Install git server
ansible.builtin.import_playbook: deploy_git_server.yml
- name: Provision git server
ansible.builtin.import_playbook: provision_git_server.yml
when: use_git

- name: Provision kvm server
ansible.builtin.import_playbook: provision_kvm.yml
when: use_kvm

- name: Print instances
hosts: all
become: true
Expand Down
18 changes: 17 additions & 1 deletion olam/default_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ passwordless_ssh: true
olam_single_host: false
use_olae_only: false
use_freeipa: false
use_git: false
use_git: false

use_kvm: false
create_vm: false
ol8_base_image_name: OL8U10_x86_64-kvm-b237.qcow2
ol8_base_image_url: https://yum.oracle.com/templates/OracleLinux/OL8/u10/x86_64/{{ ol8_base_image_name }}
ol8_base_image_sha: 53a5eee27c59f335ba1bdb0afc2c3273895f128dd238b51a78f46ad515cbc662
ol9_base_image_name: OL9U5_x86_64-kvm-b253.qcow2
ol9_base_image_url: https://yum.oracle.com/templates/OracleLinux/OL9/u5/x86_64/{{ ol9_base_image_name }}
ol9_base_image_sha: 3b00bbbefc8e78dd28d9f538834fb9e2a03d5ccdc2cadf2ffd0036c0a8f02021
libvirt_pool_dir: "/var/lib/libvirt/images"
vm_name: ol9-dev
vm_vcpus: 2
vm_ram_mb: 2048
vm_net: default
vm_root_pass:
cleanup_tmp: no
File renamed without changes.
File renamed without changes.
File renamed without changes.
121 changes: 121 additions & 0 deletions olam/provision_kvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
---
# 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: Install a KVM server
hosts: kvm-server
vars_files:
- default_vars.yml
become: true

tasks:

- name: Install Oracle Linux 8 virtualization packages
ansible.builtin.dnf:
name:
- "@virt"
- virt-install
- virt-viewer
- containers-common
- cockpit
- cockpit-machines
state: present
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Install Oracle Linux 9 virtualization packages
ansible.builtin.dnf:
name:
- qemu-kvm
- libvirt
- virt-install
- virt-viewer
- containers-common
- cockpit
- cockpit-machines
state: present
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '9'

- name: Start and enable Oracle Linux 8 monolithic virtualization services
ansible.builtin.systemd:
state: started
name: libvirtd.service
enabled: true
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'

- name: Start and enable Oracle Linux 9 modular 'ro' virtualization services
ansible.builtin.systemd:
state: started
name: "virt{{ item }}d-ro.socket"
enabled: true
loop:
- qemu
- network
- nodedev
- nwfilter
- secret
- storage
- interface
- proxy
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '9'

- name: Start and enable Oracle Linux 9 modular 'admin' virtualization services
ansible.builtin.systemd:
state: started
name: "virt{{ item }}d-admin.socket"
enabled: true
loop:
- qemu
- network
- nodedev
- nwfilter
- secret
- storage
- interface
- proxy
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '9'

- name: Start and enable cockpit
ansible.builtin.systemd:
state: started
name: cockpit.socket
enabled: true

- name: Open firewall for cockpit and virsh
ansible.posix.firewalld:
zone: public
service: "{{ item }}"
permanent: true
state: enabled
immediate: true
loop:
- libvirt
- libvirt-tls

- name: Add user to libvirt and qemu group
ansible.builtin.user:
name: "{{ username }}"
groups: libvirt,qemu
append: true

- name: Reset ssh connection to allow user changes to affect 'current login user'
ansible.builtin.meta: reset_connection

# - name: Deploy VM1
# vars:
# base_image_name: "{{ ol8_base_image_name }}"
# base_image_url: "{{ ol8_base_image_url }}"
# base_image_sha: "{{ ol8_base_image_sha }}"
# vm_name: ol8-dev
# ansible.builtin.import_tasks: provision_kvm_vm.yml
# when: create_vm

# - name: Deploy VM2
# vars:
# base_image_name: "{{ ol9_base_image_name }}"
# base_image_url: "{{ ol9_base_image_url }}"
# base_image_sha: "{{ ol9_base_image_sha }}"
# vm_name: ol9-dev
# ansible.builtin.import_tasks: provision_kvm_vm.yml
# when: create_vm