Skip to content
Prev Previous commit
Next Next commit
feat(olss): ✨ add ol9-slim distribution
Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com>
  • Loading branch information
AmedeeBulle committed Jul 6, 2022
commit f5c225b73601f5fa29e3be420b98850849b46b2d
3 changes: 2 additions & 1 deletion oracle-linux-image-tools/cloud/olvm/mk-envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
Generate OLVM compatible OVF file.

Copyright (c) 2020-2022 Oracle and/or its affiliates.
Copyright (c) 2020, 2022 Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at
https://oss.oracle.com/licenses/upl

Expand All @@ -26,6 +26,7 @@
'OL6': 5002,
'OL7': 5003,
'OL8': 5006,
'OL9': 5006, # Use OL8 ID for now, to support older OLVM versions
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ vagrant::config()
sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers

# sshd: disable password authentication and DNS checks
ex -s /etc/ssh/sshd_config <<EOF
:%substitute/^\(PasswordAuthentication\) .*$/\1 no/
:%substitute/^#\?\(UseDNS\) .*$/\1 no/
:update
:quit
EOF
if [[ "${ORACLE_RELEASE}" = "9" ]]; then
cat > /etc/ssh/sshd_config.d/90-vagrant.conf <<-EOF
PasswordAuthentication no
UseDNS no
EOF
else
ex -s /etc/ssh/sshd_config <<-EOF
:%substitute/^#\?\(PasswordAuthentication\) .*$/\1 no/
:%substitute/^#\?\(UseDNS\) .*$/\1 no/
:update
:quit
EOF
fi

cat >>/etc/sysconfig/sshd <<EOF

Expand Down Expand Up @@ -123,6 +130,8 @@ EOF
yum install -y "${YUM_VERBOSE}" oraclelinux-developer-release-el6
elif [[ "${ORACLE_RELEASE}" = "8" ]]; then
dnf install -y oracle-epel-release-el8
elif [[ "${ORACLE_RELEASE}" = "9" ]]; then
dnf install -y oracle-epel-release-el9
fi
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ cloud::packer_conf() {
cloud::image_package() {
local cpu="${VAGRANT_VIRTUALBOX_CPU_NUM:-$CPU_NUM}"
local memory="${VAGRANT_VIRTUALBOX_MEM_SIZE:-$MEM_SIZE}"
if [[ "${ORACLE_RELEASE}" = "8" ]]; then
# For OL8 as we don't have image_cleanup (we use distr::seal), we can
if [[ "${ORACLE_RELEASE}" =~ ^[89]$ ]]; then
# For OL8/OL9 as we don't have image_cleanup (we use distr::seal), we can
# import directrly the saved OVA file.
rm System.img
vboxmanage import System.ova \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Packer provisioning script for Vagrant-VirtualBox
#
# Copyright (c) 2020 Oracle and/or its affiliates.
# Copyright (c) 2020, 2022 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl
#
Expand Down Expand Up @@ -69,7 +69,7 @@ cloud::install_agent()

[[ -f ${additions} ]] || echo_error "Guest additions not found"

sh "${additions}"
sh "${additions}" || :
umount /mnt
}

Expand Down
58 changes: 58 additions & 0 deletions oracle-linux-image-tools/distr/ol9-slim/env.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Default parameter for the distribution.
# Do NOT change anything in this file, customisation must be done in separate
# env file.

# Distribution name
DISTR_NAME="OL9U0_x86_64"

# Distribution release
readonly ORACLE_RELEASE=9

# Setup swap?
SETUP_SWAP="yes"

# Root filesystem: xfs, lvm or btrfs
ROOT_FS="xfs"

# Boot command
# Variables MUST be escaped as they are evaluated at build time.
BOOT_COMMAND=( '<up><tab>${CONSOLE} inst.text inst.ks=${KS_CONFIG} setup_swap=${SETUP_SWAP} <enter>' )

# Kernel: uek, rhck
KERNEL="uek"

# Keep rescue kernel: yes, no
# Keeping rescue kernel will increase the image size and is most propbalbly
# not very useful in cloud environment.
# Note that if you enable rescue kernel and due the way BLS config works, you
# will have a second rescue kernel the first time kernel is upgrade as the
# machine-id differs between image build and deployed VM.
RESCUE_KERNEL="no"

# Authselect: default is set to "minimal" which should cover most use cases.
# If an alternative auth profile is needed it can be specified with the
# AUTHSELECT parameter, e.g.:
# AUTHSELECT="select sssd"
AUTHSELECT=""

# Update: yes, security, no
UPDATE_TO_LATEST="yes"

# Keep linux-firmware package? yes, no
# Linux firmware is not needed on VM instances.
# Removing linux firmware is currently not supported on OL9. There is a
# dependency on kernel-uek-modules. In theory we should not need modules on
# vm instances, but not all drivers are in the core packages.
LINUX_FIRMWARE="yes"

# Exclude documentation (man pages, info files, doc files)? yes, no, minimal
# When "yes" is selected, dnf wil be configured to exclude all documentation
# ("tsflags=nodocs" parameter).
# If you plan to re-distribute the image, you might need to keep the
# "/usr/share/doc" directory which contains the packages licence terms.
# The "minimal" option will remove man pages and info files, but will keep the
# "/usr/share/doc" directory.
EXCLUDE_DOCS="no"

# Directory used to save build information
readonly BUILD_INFO="/.build-info"
114 changes: 114 additions & 0 deletions oracle-linux-image-tools/distr/ol9-slim/image-scripts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env bash
#
# image scripts for OL9
#
# Copyright (c) 2022 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at
# https://oss.oracle.com/licenses/upl
#
# Description: this module provides the following function:
# distr::validate: basic parameter validation
# distr::kickstart: hook for kickstart file updates
# distr::packer_conf: hook for packer configuration file updates
# distr::image_cleanup: distribution specific actions to cleanup the image
# All functions are optional
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
#

#######################################
# Validate distribution parameters
# Globals:
# RESCUE_LERNEL ROOT_FS
# Arguments:
# None
# Returns:
# None
#######################################
distr::validate() {
[[ "${ROOT_FS,,}" =~ ^(xfs)|(btrfs)|(lvm)$ ]] || error "ROOT_FS must be xfs, btrfs or lvm"
[[ "${ROOT_FS,,}" = "btrfs" ]] && echo_message "Note that for btrfs root filesystem you need to use an UEK boot ISO"
[[ "${RESCUE_KERNEL,,}" =~ ^(yes)|(no)$ ]] || error "RESCUE_KERNEL must be yes or no"
[[ "${LINUX_FIRMWARE,,}" =~ ^(yes)|(no)$ ]] || error "LINUX_FIRMWARE must be yes or no"
[[ "${EXCLUDE_DOCS,,}" =~ ^(yes)|(no)|(minimal)$ ]] || error "EXCLUDE_DOCS must be yes, no or minimal"
readonly ROOT_FS RESCUE_KERNEL LINUX_FIRMWARE EXCLUDE_DOCS
}

#######################################
# Kickcstart fixup
# Globals:
# RESCUE_KERNEL ROOT_FS
# Arguments:
# kickstart file name
# Returns:
# None
#######################################
distr::kickstart() {
local ks_file="$1"

local btrfs="\
part btrfs.01 --fstype=\"btrfs\" --ondisk=sda --size=4096 --grow\n\
btrfs none --label=btrfs_vol --data=single btrfs.01\n\
btrfs / --subvol --name=root LABEL=btrfs_vol\n\
btrfs /home --subvol --name=home LABEL=btrfs_vol\
"
local lvm="\
part pv.01 --ondisk=sda --size=4096 --grow\n\
volgroup vg_main pv.01\n\
logvol swap --fstype=\"swap\" --vgname=vg_main --size=4096 --name=lv_swap\n\
logvol / --fstype=\"xfs\" --vgname=vg_main --size=4096 --name=lv_root --grow\
"

# Kickstart file is populated for xfs
if [[ "${ROOT_FS,,}" = "btrfs" ]]; then
sed -i -e 's!^part / .*$!'"${btrfs}"'!' "${ks_file}"
elif [[ "${ROOT_FS,,}" = "lvm" ]]; then
sed -i -e '/^part swap/d' -e 's!^part / .*$!'"${lvm}"'!' "${ks_file}"
fi

# Pass kernel and rescue kernel selections
sed -i -e 's!^KERNEL=.*$!KERNEL='"${KERNEL}"'!' "${ks_file}"
sed -i -e 's!^RESCUE_KERNEL=.*$!RESCUE_KERNEL='"${RESCUE_KERNEL}"'!' "${ks_file}"

# Override authselect if needed
if [[ -n ${AUTHSELECT} ]]; then
sed -i -e 's!^authselect .*$!authselect '"${AUTHSELECT}"'!' "${ks_file}"
fi

# Docs
sed -i -e 's!^EXCLUDE_DOCS=.*$!EXCLUDE_DOCS='"${EXCLUDE_DOCS}"'!' "${ks_file}"
if [[ "${EXCLUDE_DOCS,,}" = "yes" ]]; then
sed -i -e 's!^%packages!%packages --excludedocs!' "${ks_file}"
fi
}

#######################################
# Packer configuration
# Globals:
# BUILD_INFO
# Arguments:
# Packer configuration file
# Returns:
# None
#######################################
distr::packer_conf() {
if [[ -n "${BUILD_INFO}" ]]; then
cat >>"$1" <<-EOF
build_info = "${BUILD_INFO}"
EOF
fi
}

#######################################
# Cleanup actions run directly on the image
# Globals:
# WORKSPACE VM_NAME BUILD_INFO
# Arguments:
# root filesystem directory
# boot filesystem directory
# Returns:
# None
#######################################
# distr::image_cleanup() {
# :
# }
Loading