- Notifications
You must be signed in to change notification settings - Fork 50
Add Vagrant (VirtualBox provider) #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits Select commit Hold shift + click to select a range
c077764
Handle root on LVM partitioning
AmedeeBulle 817605d
The tyranny of the defaults.
AmedeeBulle 99c9852
Save kernel version
AmedeeBulle 82a2118
Remove non essential package and pin the release rpm
AmedeeBulle 0090045
Clear OCI region
AmedeeBulle 7c2f442
Add Vagrant (VirtulBox provider)
AmedeeBulle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions 12 oracle-linux-image-tools/cloud/vagrant-virtualbox/env.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Default parameters for the vagrant-virtualbox cloud. | ||
# Do NOT change anything in this file, customisation must be done in separate | ||
# env file. | ||
| ||
# Memory and CPU to allocate to the box by default at runtime (default: use | ||
# build VM parameters) | ||
# VAGRANT_VIRTUALBOX_MEM_SIZE= | ||
# VAGRANT_VIRTUALBOX_CPU_NUM= | ||
| ||
# Additional disk to attach to the VM. | ||
# Empty means no disk, otherwhise it is the size in GB of the extra disk | ||
# VAGRANT_VIRTUALBOX_EXTRA_DISK_GB= |
84 changes: 84 additions & 0 deletions 84 oracle-linux-image-tools/cloud/vagrant-virtualbox/image-scripts.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Cleanup and package image for the "vagrant-virtualbox" image | ||
# | ||
# Copyright (c) 1982-2020 Oracle and/or its affiliates. All rights reserved. | ||
AmedeeBulle marked this conversation as resolved. Show resolved Hide resolved | ||
# Licensed under the Universal Permissive License v 1.0 as shown at | ||
# https://oss.oracle.com/licenses/upl. | ||
# | ||
# Description: this module provides 2 functions: | ||
# cloud::image_cleanup: cloud specific actions to cleanup the image | ||
# This function is optional | ||
# cloud::image_package: Package the raw image for the target cloud. | ||
# This function must be defined either at cloud or cloud/distribution level | ||
# | ||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
# | ||
| ||
####################################### | ||
# Parameter validation | ||
# Globals: | ||
# VAGRANT_VIRTUALBOX_CPU, VAGRANT_VIRTUALBOX_MEMORY, | ||
# VAGRANT_VIRTUALBOX_EXTRA_DISK_GB | ||
# Arguments: | ||
# None | ||
# Returns: | ||
# None | ||
####################################### | ||
cloud::image_cleanup() { | ||
[[ ${VAGRANT_VIRTUALBOX_CPU_NUM} =~ ^[0-9]*$ ]] || error "vagrant cpu count is not numeric" | ||
[[ ${VAGRANT_VIRTUALBOX_MEM_SIZE} =~ ^[0-9]*$ ]] || error "vagrant memory is not numeric" | ||
[[ ${VAGRANT_VIRTUALBOX_EXTRA_DISK_GB} =~ ^[0-9]*$ ]] || error "vagrant disk size is not numeric" | ||
} | ||
| ||
####################################### | ||
# Cleanup actions run directly on the image | ||
# Globals: | ||
# None | ||
# Arguments: | ||
# root filesystem directory | ||
# boot filesystem directory | ||
# Returns: | ||
# None | ||
####################################### | ||
cloud::image_cleanup() { | ||
: | ||
} | ||
| ||
####################################### | ||
# Image packaging: generate box using vagrant tool | ||
# Globals: | ||
# VM_NAME, VAGRANT_VIRTUALBOX_CPU, VAGRANT_VIRTUALBOX_MEMORY, | ||
# VAGRANT_VIRTUALBOX_EXTRA_DISK_GB | ||
# Arguments: | ||
# None | ||
# Returns: | ||
# None | ||
####################################### | ||
cloud::image_package() { | ||
local cpu="${VAGRANT_VIRTUALBOX_CPU_NUM:-$CPU_NUM}" | ||
local memory="${VAGRANT_VIRTUALBOX_MEM_SIZE:-$MEM_SIZE}" | ||
# convert back to VMDK | ||
local vmdk=$(grep "ovf:href" "${VM_NAME}.ovf" | sed -r -e 's/.*ovf:href="([^"]+)".*/\1/') | ||
vboxmanage convertfromraw System.img --format VMDK "${vmdk}" --variant Stream | ||
rm System.img | ||
# re-create the OVA file | ||
tar cvf "${VM_NAME}.ova" "${VM_NAME}.ovf" "${vmdk}" | ||
rm "${vmdk}" | ||
# Import in VirtualBox and adjust cpu/memory for the box | ||
vboxmanage import "${VM_NAME}.ova" \ | ||
--vsys 0 --vmname "${VM_NAME}" \ | ||
--vsys 0 --ostype "Oracle_64" \ | ||
--vsys 0 --cpus $cpu \ | ||
--vsys 0 --memory $memory | ||
rm "${VM_NAME}.ova" | ||
# Add additional disk | ||
if [[ -n $VAGRANT_VIRTUALBOX_EXTRA_DISK_GB ]]; then | ||
local disk_size_mb=$(( ${VAGRANT_VIRTUALBOX_EXTRA_DISK_GB} * 1024 )) | ||
vboxmanage createhd --filename ./extra_disk.vdi --size $disk_size_mb --format VDI --variant fixed | ||
vboxmanage storageattach "${VM_NAME}" --storagectl "SATA Controller" --port 1 --device 0 --type hdd --medium ./extra_disk.vdi | ||
Djelibeybi marked this conversation as resolved. Show resolved Hide resolved | ||
fi | ||
# Create the box | ||
vagrant package --base "${VM_NAME}" --output "${VM_NAME}.box" | ||
vboxmanage unregistervm "${VM_NAME}" --delete | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.