Skip to content

Commit 4e23b88

Browse files
authored
Merge pull request #45 from bgraef/main
add code for olam kvm lab
2 parents 2c12407 + b248e44 commit 4e23b88

File tree

6 files changed

+147
-6
lines changed

6 files changed

+147
-6
lines changed

olam/create_instance.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@
323323
- use_olae_only
324324

325325
- name: Install Oracle Linux Automation Manager
326-
ansible.builtin.include_tasks: deploy_olam_tasks.yml
326+
ansible.builtin.include_tasks: deploy_olam_single.yml
327327
vars:
328328
control_node_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}"
329329
when:
@@ -334,14 +334,18 @@
334334
ansible.builtin.import_playbook: update_all_rpms.yml
335335
when: update_all
336336

337-
- name: Install free ipa server
338-
ansible.builtin.import_playbook: deploy_free_ipa.yml
337+
- name: Provision free ipa server
338+
ansible.builtin.import_playbook: provision_free_ipa.yml
339339
when: use_freeipa
340340

341-
- name: Install git server
342-
ansible.builtin.import_playbook: deploy_git_server.yml
341+
- name: Provision git server
342+
ansible.builtin.import_playbook: provision_git_server.yml
343343
when: use_git
344344

345+
- name: Provision kvm server
346+
ansible.builtin.import_playbook: provision_kvm.yml
347+
when: use_kvm
348+
345349
- name: Print instances
346350
hosts: all
347351
become: true

olam/default_vars.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,20 @@ passwordless_ssh: true
2323
olam_single_host: false
2424
use_olae_only: false
2525
use_freeipa: false
26-
use_git: false
26+
use_git: false
27+
28+
use_kvm: false
29+
create_vm: false
30+
ol8_base_image_name: OL8U10_x86_64-kvm-b237.qcow2
31+
ol8_base_image_url: https://yum.oracle.com/templates/OracleLinux/OL8/u10/x86_64/{{ ol8_base_image_name }}
32+
ol8_base_image_sha: 53a5eee27c59f335ba1bdb0afc2c3273895f128dd238b51a78f46ad515cbc662
33+
ol9_base_image_name: OL9U5_x86_64-kvm-b253.qcow2
34+
ol9_base_image_url: https://yum.oracle.com/templates/OracleLinux/OL9/u5/x86_64/{{ ol9_base_image_name }}
35+
ol9_base_image_sha: 3b00bbbefc8e78dd28d9f538834fb9e2a03d5ccdc2cadf2ffd0036c0a8f02021
36+
libvirt_pool_dir: "/var/lib/libvirt/images"
37+
vm_name: ol9-dev
38+
vm_vcpus: 2
39+
vm_ram_mb: 2048
40+
vm_net: default
41+
vm_root_pass:
42+
cleanup_tmp: no
File renamed without changes.
File renamed without changes.
File renamed without changes.

olam/provision_kvm.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
# Copyright (c) 2024 Oracle and/or its affiliates.
3+
# This software is made available to you under the terms of the Universal Permissive License (UPL), Version 1.0.
4+
# The Universal Permissive License (UPL), Version 1.0 (see COPYING or https://oss.oracle.com/licenses/upl)
5+
# See LICENSE.TXT for details.
6+
7+
- name: Install a KVM server
8+
hosts: kvm-server
9+
vars_files:
10+
- default_vars.yml
11+
become: true
12+
13+
tasks:
14+
15+
- name: Install Oracle Linux 8 virtualization packages
16+
ansible.builtin.dnf:
17+
name:
18+
- "@virt"
19+
- virt-install
20+
- virt-viewer
21+
- containers-common
22+
- cockpit
23+
- cockpit-machines
24+
state: present
25+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
26+
27+
- name: Install Oracle Linux 9 virtualization packages
28+
ansible.builtin.dnf:
29+
name:
30+
- qemu-kvm
31+
- libvirt
32+
- virt-install
33+
- virt-viewer
34+
- containers-common
35+
- cockpit
36+
- cockpit-machines
37+
state: present
38+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '9'
39+
40+
- name: Start and enable Oracle Linux 8 monolithic virtualization services
41+
ansible.builtin.systemd:
42+
state: started
43+
name: libvirtd.service
44+
enabled: true
45+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '8'
46+
47+
- name: Start and enable Oracle Linux 9 modular 'ro' virtualization services
48+
ansible.builtin.systemd:
49+
state: started
50+
name: "virt{{ item }}d-ro.socket"
51+
enabled: true
52+
loop:
53+
- qemu
54+
- network
55+
- nodedev
56+
- nwfilter
57+
- secret
58+
- storage
59+
- interface
60+
- proxy
61+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '9'
62+
63+
- name: Start and enable Oracle Linux 9 modular 'admin' virtualization services
64+
ansible.builtin.systemd:
65+
state: started
66+
name: "virt{{ item }}d-admin.socket"
67+
enabled: true
68+
loop:
69+
- qemu
70+
- network
71+
- nodedev
72+
- nwfilter
73+
- secret
74+
- storage
75+
- interface
76+
- proxy
77+
when: ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '9'
78+
79+
- name: Start and enable cockpit
80+
ansible.builtin.systemd:
81+
state: started
82+
name: cockpit.socket
83+
enabled: true
84+
85+
- name: Open firewall for cockpit and virsh
86+
ansible.posix.firewalld:
87+
zone: public
88+
service: "{{ item }}"
89+
permanent: true
90+
state: enabled
91+
immediate: true
92+
loop:
93+
- libvirt
94+
- libvirt-tls
95+
96+
- name: Add user to libvirt and qemu group
97+
ansible.builtin.user:
98+
name: "{{ username }}"
99+
groups: libvirt,qemu
100+
append: true
101+
102+
- name: Reset ssh connection to allow user changes to affect 'current login user'
103+
ansible.builtin.meta: reset_connection
104+
105+
# - name: Deploy VM1
106+
# vars:
107+
# base_image_name: "{{ ol8_base_image_name }}"
108+
# base_image_url: "{{ ol8_base_image_url }}"
109+
# base_image_sha: "{{ ol8_base_image_sha }}"
110+
# vm_name: ol8-dev
111+
# ansible.builtin.import_tasks: provision_kvm_vm.yml
112+
# when: create_vm
113+
114+
# - name: Deploy VM2
115+
# vars:
116+
# base_image_name: "{{ ol9_base_image_name }}"
117+
# base_image_url: "{{ ol9_base_image_url }}"
118+
# base_image_sha: "{{ ol9_base_image_sha }}"
119+
# vm_name: ol9-dev
120+
# ansible.builtin.import_tasks: provision_kvm_vm.yml
121+
# when: create_vm

0 commit comments

Comments
 (0)