diff --git a/oracle-linux-image-tools/README.md b/oracle-linux-image-tools/README.md index 535f471..d33238b 100755 --- a/oracle-linux-image-tools/README.md +++ b/oracle-linux-image-tools/README.md @@ -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: diff --git a/oracle-linux-image-tools/cloud/olvm/env.properties b/oracle-linux-image-tools/cloud/olvm/env.properties new file mode 100644 index 0000000..60c9c69 --- /dev/null +++ b/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= diff --git a/oracle-linux-image-tools/cloud/olvm/provision.sh b/oracle-linux-image-tools/cloud/olvm/provision.sh index 93293f4..44ae3d9 100755 --- a/oracle-linux-image-tools/cloud/olvm/provision.sh +++ b/oracle-linux-image-tools/cloud/olvm/provision.sh @@ -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 @@ -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: diff --git a/oracle-linux-image-tools/distr/ol7-slim/provision.sh b/oracle-linux-image-tools/distr/ol7-slim/provision.sh index bb60cff..2eb3c7c 100644 --- a/oracle-linux-image-tools/distr/ol7-slim/provision.sh +++ b/oracle-linux-image-tools/distr/ol7-slim/provision.sh @@ -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 @@ -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 diff --git a/oracle-linux-image-tools/env.properties b/oracle-linux-image-tools/env.properties index f67b1e4..5257a1f 100644 --- a/oracle-linux-image-tools/env.properties +++ b/oracle-linux-image-tools/env.properties @@ -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=