Skip to content

Commit

Permalink
Add cloud-init support for OLVM
Browse files Browse the repository at this point in the history
Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com>
  • Loading branch information
AmedeeBulle committed Feb 6, 2020
1 parent 667b90d commit b40dffc
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 6 deletions.
6 changes: 6 additions & 0 deletions oracle-linux-image-tools/README.md
Expand Up @@ -57,6 +57,12 @@ Files are processed in that order.
As user you should only make changes in your local `env.properties` where you can override any definition from the previous property files.
Relevant parameters are documented in the distributed [`env.properties`](env.properties) file.

# Cloud specific notes
## OLVM
The `olvm` cloud target generates an OVA file. The process to import OVA files in the Oracle Linux Virtualization Manager is described in this [blog post](https://blogs.oracle.com/scoter/import-configure-oracle-linux-7-template-for-oracle-linux-kvm).

For cloud-init support, you will need to specify `CLOUD_INIT="Yes"` in your `env.properties` file.

# Builder architecture
## Directory structure
The `build-image` script relies on the following directory structure:
Expand Down
8 changes: 8 additions & 0 deletions oracle-linux-image-tools/cloud/olvm/env.properties
@@ -0,0 +1,8 @@
# Default parameter for the OLVM cloud.
# Do NOT change anything in this file, customisation must be done in separate
# env file.

# Install cloud-init? (Yes/No)
CLOUD_INIT="No"
# Cloud-init user (Empty variable means keep package default -- cloud-user)
CLOUD_USER=
54 changes: 51 additions & 3 deletions oracle-linux-image-tools/cloud/olvm/provision.sh
Expand Up @@ -15,15 +15,15 @@
#

#######################################
# Provisioning module
# Configure OVLM instance
# Globals:
# YUM_VERBOSE
# None
# Arguments:
# None
# Returns:
# None
#######################################
cloud::provision()
cloud::config()
{
echo_message "Setup network"
# simple eth0 configuration
Expand All @@ -37,11 +37,59 @@ cloud::provision()
IPV6INIT="no"
PERSISTENT_DHCLIENT="1"
EOF
}

#######################################
# Install QEMU guest agent
# Globals:
# YUM_VERBOSE
# Arguments:
# None
# Returns:
# None
#######################################
cloud::install_agent()
{
echo_message "Install guest agent"
yum install -y ${YUM_VERBOSE} qemu-guest-agent
}

#######################################
# Install cloud-init, use CLOUD_USER if specified
# Globals:
# YUM_VERBOSE
# Arguments:
# None
# Returns:
# None
#######################################
cloud::cloud_init()
{
echo_message "Install cloud-init: ${CLOUD_INIT^^}"
if [[ "${CLOUD_INIT,,}" = "yes" ]]; then
yum install -y ${YUM_VERBOSE} cloud-init
if [[ -n "${CLOUD_USER}" ]]; then
sed -i -e "s/\(^\s\+name:\).*/\1 ${CLOUD_USER}/" /etc/cloud/cloud.cfg
fi
fi
}

#######################################
# Provisioning module
# Globals:
# None
# Arguments:
# None
# Returns:
# None
#######################################
cloud::provision()
{
cloud::install_agent
cloud::cloud_init
cloud::config
}

#######################################
# Cleanup module
# Globals:
Expand Down
10 changes: 7 additions & 3 deletions oracle-linux-image-tools/distr/ol7-slim/provision.sh
Expand Up @@ -100,7 +100,7 @@ distr::kernel_config() {
#######################################distr::provision()
distr::common_cfg() {
local service tty

# Run yum update if flag is set to yes in image build page
echo_message "Update image: ${UPDATE_TO_LATEST^^}"
if [[ "${UPDATE_TO_LATEST,,}" = "yes" ]]; then
Expand Down Expand Up @@ -265,8 +265,12 @@ distr::cleanup() {
[ -e /var/log/ovm-template-config.log ] && rm -f /var/log/ovm-template-config.log
/bin/rm -f /var/log/audit/audit.log*
[ -e /var/log/audit/audit.log ] && > /var/log/audit/audit.log
# cleanup ssh cache files
[ -d /root/.ssh ] && /bin/rm -fr /root/.ssh
# cleanup ssh config files
if [ -z "${SSH_KEY_FILE}" ]; then
[ -d /root/.ssh ] && /bin/rm -fr /root/.ssh
else
find /root/.ssh -type f -not -name authorized_keys -delete
fi
# cleanup vnc cache files
if [ -d /root/.vnc ]; then
/bin/rm -f /root/.vnc/*.log
Expand Down
6 changes: 6 additions & 0 deletions oracle-linux-image-tools/env.properties
Expand Up @@ -67,3 +67,9 @@ CLOUD="none"

# OVM Image version (Default: 1.0)
# IMAGE_VERSION=

# OLVM:
# Install cloud-init? (Yes/No)
# CLOUD_INIT="No"
# cloud-init user
# CLOUD_USER=

0 comments on commit b40dffc

Please sign in to comment.