-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add templates and scripts for libvirt provider, tidy
- Loading branch information
1 parent
c086874
commit a3d378a
Showing
16 changed files
with
391 additions
and
68 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
.DS_Store | ||
.*.swp | ||
_site/* | ||
/config | ||
/out/ | ||
node_modules | ||
/build/ | ||
build/ | ||
TOKEN | ||
.release* | ||
.upload* | ||
/ova/ | ||
ova/ | ||
developer.rb | ||
info.json | ||
.box* | ||
.provider* | ||
.version* | ||
*XXX* | ||
*xxx* |
This file contains 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,7 @@ | ||
# Changelog for cits3007 vagrant environment | ||
|
||
## Unreleased changes | ||
|
||
## 0.1.0 - 2021-07-24 | ||
|
||
Initial version |
This file contains 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,22 @@ | ||
|
||
# useful tips | ||
|
||
## VMDK info | ||
|
||
A handy command for displaying info about a .vmdk file is: | ||
|
||
``` | ||
vboxmanage showmediuminfo /path/to/img.vmdk | ||
``` | ||
|
||
It shows the file format version, and what disk variant is being used (streaming, fixed, etc.) | ||
|
||
## Building an .ova file | ||
|
||
It would be nice if we could just download an OVA file from the Vagrant cloud, | ||
but it appears that the generic/ubuntu2004 box consists of a version 1 OVA file, | ||
but packer only works with version 2 OVA files. So we have to instead re-package | ||
the OVA file using `make_ova.pl` (which used as a template the output of doing an | ||
"export" from a recent version of VirtualBox). | ||
|
||
|
This file contains 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 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 @@ | ||
.qcow_checksum.md5 |
This file contains 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,42 @@ | ||
|
||
include ../vars.mk | ||
|
||
PROVIDER=libvirt | ||
|
||
include ../rules.mk | ||
|
||
|
||
|
||
QCOW_PATH=$(HOME)/.vagrant.d/boxes/generic-VAGRANTSLASH-$(BASE_BOX_NAME)/$(BASE_BOX_VERSION)/$(PROVIDER)/box.img | ||
|
||
$(QCOW_PATH): | ||
vagrant box add \ | ||
--provider $(PROVIDER) \ | ||
--box-version $(BASE_BOX_VERSION) \ | ||
$(BASE_BOX) | ||
|
||
.qcow_checksum.md5: $(QCOW_PATH) | ||
cat $(QCOW_PATH) | pv | md5sum | awk '{ print $$1; }' > $@ | ||
|
||
build/$(BOX_NAME)_$(BOX_VERSION).box \ | ||
build/$(BOX_NAME)_$(BOX_VERSION).box.md5 \ | ||
build/$(BOX_NAME)_$(BOX_VERSION).qcow2 \ | ||
: $(QCOW_PATH) \ | ||
developer.rb \ | ||
info.json \ | ||
.qcow_checksum.md5 | ||
set -x && \ | ||
export PKR_VAR_SOURCE_PATH=$< && \ | ||
export PKR_VAR_SOURCE_MD5=`cat .qcow_checksum.md5` && \ | ||
export PKR_VAR_OUTPUT_DIR=$(output_dir) && \ | ||
export PKR_VAR_DISK_SIZE=`qemu-img info --output=json $(QCOW_PATH) | jq '.["virtual-size"]'` && \ | ||
export PKR_VAR_BOX_NAME=$(BOX_NAME) && \ | ||
export PKR_VAR_BOX_VERSION=$(BOX_VERSION) && \ | ||
packer validate $(packer_template) && \ | ||
PACKER_LOG=1 packer build $(packer_template) | ||
|
||
packer-build: build/$(BOX_NAME)_$(BOX_VERSION).box | ||
|
||
|
||
|
||
|
This file contains 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,109 @@ | ||
|
||
# various variables, typically | ||
# got from environment | ||
|
||
variable "SOURCE_PATH" { | ||
type = string | ||
description = "path to input .img QCOW2 file" | ||
} | ||
|
||
variable "SOURCE_MD5" { | ||
type = string | ||
description = "md5 hash of QCOW2 file" | ||
} | ||
|
||
variable "DISK_SIZE" { | ||
type = number | ||
description = "size of disk in bytes" | ||
} | ||
|
||
variable "OUTPUT_DIR" { | ||
type = string | ||
description = "output dir" | ||
} | ||
|
||
variable "BOX_NAME" { | ||
type = string | ||
description = "name of box being created" | ||
} | ||
|
||
variable "BOX_VERSION" { | ||
type = string | ||
description = "version of box being created" | ||
} | ||
|
||
source "qemu" "cits3007" { | ||
|
||
iso_url = "file:///${var.SOURCE_PATH}" | ||
disk_image = true | ||
format = "qcow2" | ||
iso_checksum = "md5:${var.SOURCE_MD5}" | ||
|
||
shutdown_command = "sudo shutdown -P now" | ||
|
||
communicator = "ssh" | ||
ssh_username = "vagrant" | ||
ssh_password = "vagrant" | ||
ssh_timeout = "60m" | ||
|
||
headless = true | ||
|
||
# Needn't specify an accelerator - packer docco | ||
# says kvm will be used by default if available, | ||
# else tcg: https://www.packer.io/docs/builders/qemu. | ||
|
||
#accelerator = "kvm" | ||
|
||
output_directory = "${var.OUTPUT_DIR}" | ||
|
||
disk_size = "${var.DISK_SIZE}b" | ||
vm_name = "${var.BOX_NAME}_${var.BOX_VERSION}.qcow2" | ||
|
||
net_device = "virtio-net" | ||
disk_interface = "virtio-scsi" | ||
boot_wait = "20s" | ||
|
||
display = "none" | ||
|
||
# needed, see https://github.com/hashicorp/packer/issues/8693 | ||
# (??still) | ||
qemuargs = [ | ||
["-display", "none"] | ||
] | ||
} | ||
|
||
|
||
build { | ||
sources = ["source.qemu.cits3007"] | ||
|
||
provisioner "shell" { | ||
scripts = [ | ||
"../provision-01.sh", | ||
"../provision-02.sh" | ||
] | ||
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" | ||
timeout = "60m" | ||
max_retries = 2 | ||
} | ||
|
||
post-processors { | ||
|
||
post-processor "vagrant" { | ||
|
||
compression_level = 9 | ||
keep_input_artifact = true | ||
vagrantfile_template = "developer.rb" | ||
output = "${var.OUTPUT_DIR}/${var.BOX_NAME}_${var.BOX_VERSION}.box" | ||
include = [ | ||
"info.json" | ||
] | ||
} | ||
|
||
post-processor "checksum" { | ||
checksum_types = ["md5"] | ||
output = "${var.OUTPUT_DIR}/${var.BOX_NAME}_${var.BOX_VERSION}.box.md5" | ||
} | ||
|
||
} | ||
|
||
} |
File renamed without changes.
This file contains 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,50 @@ | ||
#!/usr/bin/env bash | ||
|
||
# should be run as root | ||
|
||
set -x | ||
|
||
apt-get update | ||
|
||
# should already have: wget, curl | ||
|
||
# basic apps | ||
|
||
DEBIAN_FRONTEND=noninteractive \ | ||
apt-get install --no-install-recommends -y \ | ||
apt-transport-https \ | ||
aptitude \ | ||
bash \ | ||
bash-completion \ | ||
bzip2 \ | ||
ca-certificates \ | ||
command-not-found \ | ||
expect \ | ||
file \ | ||
fakeroot \ | ||
gpg \ | ||
jq \ | ||
less \ | ||
lsof \ | ||
lynx \ | ||
netcat-openbsd \ | ||
procps \ | ||
pv \ | ||
openssh-client \ | ||
screen \ | ||
sudo \ | ||
time | ||
|
||
# extra utils | ||
|
||
DEBIAN_FRONTEND=noninteractive \ | ||
apt-get install --no-install-recommends -y \ | ||
binutils \ | ||
bsdmainutils \ | ||
coreutils \ | ||
diffutils \ | ||
findutils \ | ||
moreutils \ | ||
patchutils \ | ||
sharutils | ||
|
This file contains 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,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
# should be run as root | ||
|
||
set -x | ||
|
||
apt-get update | ||
|
||
# should already have: wget, curl | ||
|
||
|
||
# dev tools | ||
|
||
DEBIAN_FRONTEND=noninteractive \ | ||
apt-get install --no-install-recommends -y \ | ||
afl++-clang \ | ||
build-essential \ | ||
clang \ | ||
clang-format \ | ||
clang-tidy \ | ||
clang-tools \ | ||
g++-multilib \ | ||
gdb \ | ||
git \ | ||
gpg \ | ||
indent \ | ||
libtool \ | ||
llvm-10-dev \ | ||
pkg-config \ | ||
splint \ | ||
universal-ctags \ | ||
valgrind \ | ||
xxd \ | ||
zzuf | ||
|
||
# docco | ||
|
||
DEBIAN_FRONTEND=noninteractive \ | ||
apt-get install --no-install-recommends -y \ | ||
man-db \ | ||
manpages \ | ||
manpages-dev \ | ||
manpages-posix \ | ||
manpages-posix-dev | ||
|
This file contains 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
Oops, something went wrong.