Skip to content

Commit f12785f

Browse files
Merge pull request #87 from AmedeeBulle/ol9-ovm
feat(olss): ✨ support ol9 on ovm
2 parents a2cec8a + 2b4f2be commit f12785f

File tree

5 files changed

+182
-2
lines changed

5 files changed

+182
-2
lines changed

oracle-linux-image-tools/cloud/ovm/ol8-slim/env.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44

55
# Add additional kernel (Image will have both UEK and RHCK installed)
66
EXTRA_KERNEL="no"
7+
8+
# Keep kernel-modules packages for OVM.
9+
readonly KERNEL_MODULES="yes"
10+
readonly
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Default parameter for the OVM cloud on OL8.
2+
# Do NOT change anything in this file, customisation must be done in separate
3+
# env file.
4+
5+
# Add additional kernel (Image will have both UEK and RHCK installed)
6+
EXTRA_KERNEL="no"
7+
8+
# Keep kernel-modules packages for OVM
9+
readonly KERNEL_MODULES="yes"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Validate parameters
4+
#
5+
# Copyright (c) 2023 Oracle and/or its affiliates.
6+
# Licensed under the Universal Permissive License v 1.0 as shown at
7+
# https://oss.oracle.com/licenses/upl
8+
#
9+
# Description: this module provides:
10+
# cloud_distr::validate: parameter validation
11+
#
12+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
13+
#
14+
15+
#######################################
16+
# Parameter validation
17+
# Globals:
18+
# EXTRA_KERNEL
19+
# Arguments:
20+
# None
21+
# Returns:
22+
# None
23+
#######################################
24+
cloud_distr::validate() {
25+
[[ "${EXTRA_KERNEL,,}" =~ ^(yes)|(no)$ ]] || error "EXTRA_KERNEL must be yes or no"
26+
readonly EXTRA_KERNEL
27+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Packer provisioning script for OVM on OL9
4+
#
5+
# Copyright (c) 2023, Oracle and/or its affiliates.
6+
# Licensed under the Universal Permissive License v 1.0 as shown at
7+
# https://oss.oracle.com/licenses/upl
8+
#
9+
# Description: OVM on OL9 specific provisioning. This module provides 2
10+
# functions, both are optional.
11+
# cloud_distr::provision: provision the instance
12+
# cloud_distr::cleanup: instance cleanup before shutdown
13+
#
14+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
15+
#
16+
17+
#######################################
18+
# Configure serial ports
19+
# Globals:
20+
# None
21+
# Arguments:
22+
# None
23+
# Returns:
24+
# None
25+
#######################################
26+
cloud_distr::serial_cfg() {
27+
cat > /usr/lib/systemd/system/serial_console.service <<-EOF
28+
# This file is part of systemd.
29+
#
30+
# systemd is free software; you can redistribute it and/or modify it
31+
# under the terms of the GNU Lesser General Public License as published by
32+
# the Free Software Foundation; either version 2.1 of the License, or
33+
# (at your option) any later version.
34+
35+
[Unit]
36+
Description=Serial Getty on serial_console
37+
Documentation=man:agetty(8) man:systemd-getty-generator(8)
38+
Documentation=http://0pointer.de/blog/projects/serial-console.html
39+
BindsTo=dev-serial_console.device
40+
After=dev-%i.device systemd-user-sessions.service plymouth-quit-wait.service
41+
After=rc-local.service
42+
43+
# If additional gettys are spawned during boot then we should make
44+
# sure that this is synchronized before getty.target, even though
45+
# getty.target didn't actually pull it in.
46+
Before=getty.target
47+
IgnoreOnIsolate=yes
48+
Conflicts=serial-getty@ttyS0.service serial-getty@hvc0.service
49+
ConditionPathIsSymbolicLink=/dev/serial_console
50+
51+
[Service]
52+
ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 serial_console $TERM
53+
Type=idle
54+
Restart=always
55+
UtmpIdentifier=serial_console
56+
TTYPath=/dev/serial_console
57+
TTYReset=yes
58+
TTYVHangup=yes
59+
KillMode=process
60+
IgnoreSIGPIPE=no
61+
SendSIGHUP=yes
62+
63+
[Install]
64+
WantedBy=getty.target
65+
EOF
66+
67+
echo "KERNEL==\"ttyS0\", DEVPATH==\"/devices/pnp0/*\", SYMLINK+=\"serial_console\"" > /etc/udev/rules.d/50-udev.rules
68+
echo "KERNEL==\"hvc0\", DEVPATH==\"/devices/virtual/*\", SYMLINK+=\"serial_console\"" >> /etc/udev/rules.d/50-udev.rules
69+
systemctl enable serial_console.service
70+
}
71+
72+
#######################################
73+
# Configure additional kernel
74+
# This will install RHCK if UEK is already there or the opposite
75+
# Assumes that we have a single kernel installed
76+
# Globals:
77+
# DRACUT_CMD, KERNEL, KERNEL_MODULES, UEK_RELEASE
78+
# Arguments:
79+
# None
80+
# Returns:
81+
# None
82+
#######################################
83+
cloud_distr::additional_kernel() {
84+
local kernel kernel_version
85+
86+
# Select kernel to install
87+
# shellcheck disable=SC2153
88+
if [[ "${KERNEL,,}" = "uek" ]]; then
89+
kernel="kernel"
90+
else
91+
if [[ ${KERNEL_MODULES,,} == "yes" ]]; then
92+
kernel="kernel-uek"
93+
else
94+
kernel="kernel-uek-core"
95+
fi
96+
dnf config-manager --set-enabled "ol9_UEKR7"
97+
fi
98+
99+
echo_message "Adding kernel: ${kernel}"
100+
dnf install -y ${kernel}
101+
kernel_version=$(rpm -q ${kernel} --qf "%{VERSION}-%{RELEASE}.%{ARCH}")
102+
echo_message "Installed kernel: ${kernel_version}"
103+
104+
# Regenerate initrd
105+
${DRACUT_CMD} -f "/boot/initramfs-${kernel_version}.img" "${kernel_version}"
106+
107+
# Ensure grub is properly setup
108+
grub2-mkconfig -o /boot/grub2/grub.cfg
109+
}
110+
111+
#######################################
112+
# Provisioning module
113+
# Globals:
114+
# EXTRA_KERNEL
115+
# Arguments:
116+
# None
117+
# Returns:
118+
# None
119+
#######################################
120+
cloud_distr::provision()
121+
{
122+
cloud_distr::serial_cfg
123+
if [[ "${EXTRA_KERNEL,,}" = "yes" ]]; then
124+
cloud_distr::additional_kernel
125+
fi
126+
}
127+
128+
#######################################
129+
# Cleanup module
130+
# Globals:
131+
# None
132+
# Arguments:
133+
# None
134+
# Returns:
135+
# None
136+
#######################################
137+
cloud_distr::cleanup()
138+
{
139+
:
140+
}

oracle-linux-image-tools/cloud/ovm/provision.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ cloud::install_vmapilibxenstore()
103103
python-simplejson \
104104
xenstoreprovider \
105105
libxenstore
106-
elif [[ "${ORACLE_RELEASE}" = "8" ]]; then
107-
dnf install --enablerepo ol8_addons -y \
106+
elif [[ "${ORACLE_RELEASE}" =~ ^(8|9)$ ]]; then
107+
dnf install --enablerepo "ol${ORACLE_RELEASE}_addons" -y \
108108
libovmapi \
109109
libovmapi-devel \
110110
ovmd \

0 commit comments

Comments
 (0)