generated from oracle-devrel/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from bgraef/main
add code for olam kvm lab
- Loading branch information
Showing
6 changed files
with
147 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |