From 9fc15872a15aa3e480ce783791551ed225b2b387 Mon Sep 17 00:00:00 2001 From: Andreas Bader Date: Tue, 15 Mar 2016 21:06:52 +0100 Subject: [PATCH] Add Virtualbox support --- MakeDebianVB.py | 239 +++++++++++++++++++++++++++++++ TSDBBench.py | 2 +- Vm.py | 6 +- preseed-virtualbox.cfg | 136 ++++++++++++++++++ vagrant_files/vagrantconf.rb | 5 + vagrant_files/vagrantconf_db.rb | 5 +- vagrant_files/vagrantconf_gen.rb | 3 + 7 files changed, 393 insertions(+), 3 deletions(-) create mode 100755 MakeDebianVB.py create mode 100644 preseed-virtualbox.cfg diff --git a/MakeDebianVB.py b/MakeDebianVB.py new file mode 100755 index 0000000..647d9cb --- /dev/null +++ b/MakeDebianVB.py @@ -0,0 +1,239 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +import time + +__author__ = 'Andreas Bader' +__version__ = "0.01" + +import argparse +import logging +import Util +import os +import shutil +from fabric.api import * +import re + +neededTools = ["which", "VBoxManage", "vagrant"] + +creation_commands = [ + "VBoxManage createvm --name \"{name}\" --register", + "VBoxManage modifyvm \"{name}\" --ostype Debian_64", + "VBoxManage modifyvm \"{name}\" --memory 1024", + "VBoxManage modifyvm \"{name}\" --vram 8", + "VBoxManage modifyvm \"{name}\" --acpi on", + "VBoxManage modifyvm \"{name}\" --ioapic on", + "VBoxManage modifyvm \"{name}\" --boot1 dvd", + "VBoxManage modifyvm \"{name}\" --pae on", + "VBoxManage modifyvm \"{name}\" --longmode on", + "VBoxManage modifyvm \"{name}\" --synthcpu off", + "VBoxManage modifyvm \"{name}\" --hwvirtex on", + "VBoxManage modifyvm \"{name}\" --nestedpaging on", + "VBoxManage modifyvm \"{name}\" --largepages off", + "VBoxManage modifyvm \"{name}\" --vtxvpid on", + "VBoxManage modifyvm \"{name}\" --vtxux on", + "VBoxManage modifyvm \"{name}\" --accelerate3d off", + "VBoxManage modifyvm \"{name}\" --accelerate2dvideo off", + "VBoxManage modifyvm \"{name}\" --chipset piix3", + "VBoxManage modifyvm \"{name}\" --biossystemtimeoffset 0", + "VBoxManage modifyvm \"{name}\" --firmware bios", + "VBoxManage modifyvm \"{name}\" --monitorcount 1", + "VBoxManage modifyvm \"{name}\" --cpus 2", + "VBoxManage modifyvm \"{name}\" --rtcuseutc on", + "VBoxManage modifyvm \"{name}\" --nic1 nat", + "VBoxManage createhd --filename \"{path}/{name}.vdi\" --size \"{size}\" --format VDI --variant Standard", + "VBoxManage storagectl \"{name}\" --name \"IDE Controller\" --add ide", + "VBoxManage storagectl \"{name}\" --name \"SATA Controller\" --add sata", + "VBoxManage storageattach \"{name}\" --storagectl \"SATA Controller\" --port 0 --device 0 --type hdd --medium \"{path}/{name}.vdi\"", + "VBoxManage storageattach \"{name}\" --storagectl \"IDE Controller\" --port 0 --device 0 --type dvddrive --medium \"{iso}\"" +] + +timeout = 3600 # 1 hour should be enough + +def delete_vm(name, logger): + with settings(warn_only=True), hide('output','running','warnings'): + ret = local("VBoxManage list vms", capture=True) + if base_box_name in ret.stdout: + uuid = re.search("^\"%s\"\s+\{[a-z0-9\-]+\}" % name,ret,re.MULTILINE) + if uuid is None: + logger.error("uuid of VM %s can't be found." %(name)) + return False + uuid = re.search("\{[a-z0-9\-]+\}", uuid.group()) + if uuid is None: + logger.error("uuid of VM %s can't be extracted from '%s'." %(name, uuid.group())) + return False + uuid = uuid.group().replace("{","").replace("}","") + # deleting all drives without iso files + # not necessary, --delete for unrgeistervm does it already + # drives = local("VBoxManage showvminfo %s" % uuid, capture=True) + # for res in re.findall("^IDE-Controller.+$|^SATA-Controller.+$", drives, re.MULTILINE): + # if ".iso" in res.lower(): + # continue + # hdd_uuid = re.search("\(UUID:\s+[a-z0-9\-]+\)$",res) + # if hdd_uuid == None: + # logger.warning("Can't find UUID for hdd in '%s'. Please delete it by hand." %(hdd_uuid)) + # continue + # hdd_uuid = hdd_uuid.group().replace("(UUID: ","").replace(")","") + if status_vm(uuid, logger): + logger.info("VM %s is running, stopping it..." %(name)) + stop_vm(uuid, logger) + deleted = local("VBoxManage unregistervm %s --delete" % uuid) + if deleted.return_code != 0: + logger.error("Error while deleting VM %s with UUID %s. Please delete by hand!" %(name, uuid)) + else: + logger.error("VM %s can't be found." %(name)) + return False + return True + +def create_vm(name, size, path, iso, logger): + with settings(warn_only=True), hide('output','running','warnings'): + for command in creation_commands: + ret = local(command.format(name=name, size=size, path=path, iso=iso), capture=True) + logger.info("Executing '%s'." % (command.format(name=name, size=size, path=path, iso=iso))) + if ret.return_code != 0: + logger.error("Command '%s' failed and returned with error code %s and stdout '%s' and stderr '%s'." % + (command.format(name=name, size=size, path=path, iso=iso), ret.return_code, ret.stdout, ret.stderr)) + return False + logger.info("Command '%s' returned 0." % (command.format(name=name, size=size, path=path, iso=iso))) + return True + +def start_vm(name, graphic, logger): + with settings(warn_only=True), hide('output','running','warnings'): + headless_arg="" + if not graphic: + headless_arg = " --type headless" + ret = local("VBoxManage startvm \"%s\"%s" %(name, headless_arg), capture=True) + logger.info("Executing 'VBoxHeadless --startvm \"%s\"%s'." % (name, headless_arg)) + if ret.return_code != 0: + logger.error("Command 'VBoxHeadless --startvm \"%s\"%s' failed and returned with error " + "code %s and stdout '%s' and stderr '%s'." % + (name, headless_arg, ret.return_code, ret.stdout, ret.stderr)) + return False + logger.info("Command 'VBoxHeadless --startvm \"%s\"%s' returned 0." % (name, headless_arg)) + return True + +def stop_vm(name, logger): + with settings(warn_only=True), hide('output','running','warnings'): + if status_vm(name, logger): + logger.info("Trying soft poweroff...") + ret = local("vboxmanage controlvm \"%s\" poweroff soft" % (name)) + logger.info("Command 'vboxmanage controlvm \"%s\" poweroff soft' returned %s." % (name, ret.return_code)) + if ret.return_code != 0: + logger.info("Soft poweroff failed, trying (hard) poweroff...") + ret = local("vboxmanage controlvm \"%s\" poweroff" % (name)) + logger.info("Command 'vboxmanage controlvm \"%s\" poweroff' returned %s." % (name, ret.return_code)) + if ret.return_code != 0: + return False + return True + + +def status_vm(name, logger): + with settings(warn_only=True), hide('output','running','warnings'): + ret = local("VBoxManage showvminfo \"%s\"" % name, capture=True) + if ret.return_code == 0: + state = re.search("State:\s+running", ret.stdout) + if state == None: + return False + else: + return True + else: + logger.error("Error while checking of VM %s, can't determine state." %(name)) + return False + +def exist_vm(name, logger): + with settings(warn_only=True), hide('output','running','warnings'): + ret = local("VBoxManage list vms", capture=True) + if ret.return_code == 0: + if name in ret.stdout: + return True + else: + return False + else: + logger.error("Error while checking of VM %s, can't determine existence." %(name)) + return True + +def package_vm(name, output_file, logger): + with settings(warn_only=True), hide('output','running','warnings'): + logger.info("Packaging vm with 'vagrant package --base \"%s\"'." %(name)) + ret = local("vagrant package --base \"%s\" --output \"%s\"" %(name, output_file), capture=True) + if ret.return_code == 0: + logger.info("Packaging of VM %s returned 0." %(name)) + return True + else: + logger.error("Packaging of VM %s returned %s with stdout '%s' and stderr '%s'." + % (name, ret.return_code, ret.stdout, ret.stderr)) + return False + +# Configure ArgumentParser +parser = argparse.ArgumentParser(prog="MakeDebianVB.py",version=__version__,description="Creates an Vagrant Box with/for VirtualBox for use with TSDBBench.", formatter_class=argparse.RawDescriptionHelpFormatter, epilog="") +parser.add_argument("-i", "--isofile", metavar="ISOFILE", required=True, help="path to Debian Autoinstall Iso") +parser.add_argument("-f", "--outputfolder", metavar="OUTPUTFOLDER", required=True, help="path to outputfolder (will be created if not existent) (> 5 gb)") +parser.add_argument("-g", "--graphic", action="store_true", help="show graphic output, normally -nographic is used. Useful if you don't use a preseeded iso.") +parser.add_argument("-o", "--overwrite", action="store_true", help="overwrite if VM is existing") +parser.add_argument("-l", "--log", action='store_true', help="Be more verbose, log vagrant output.") +parser.add_argument("-s", "--size", metavar="SIZE", type=int, default=50, help="Size in Gigabyte (50 is default), e.g. 50 for 50G (will be compressed, Qcow2 file size will be much lesser!)") +args = parser.parse_args() + +# Configure Logging +logLevel = logging.WARN +if args.log: + logLevel = logging.DEBUG +logging.basicConfig(level=logLevel) +logger = logging.getLogger(__name__) + +# Check ob alle Tools da sind +for tool in neededTools: + with settings(warn_only=True), hide('output','running','warnings'): + ret=local("which '%s'" %(tool)) + if ret.return_code != 0: + logger.error("'%s' not found, please install." %(tool)) + exit(-1) + +if not (Util.check_file_exists(args.isofile) and Util.check_file_readable(args.isofile)): + logger.error("Isofile %s does not exist or is not readable." %(args.isofile)) + exit(-1) + +if not Util.check_folder(args.outputfolder,logger,False,True): + if not Util.create_folder(args.outputfolder) or not Util.check_folder(args.outputfolder,logger): + logger.error("Can't create %s." %(args.outputfolder)) + exit(-1) + +isoFileName=os.path.basename(args.isofile) +base_box_name="default" +if len(os.path.splitext(args.isofile)) > 0: + base_box_name=os.path.splitext(isoFileName)[0] +outputFileName="%s.box" %(base_box_name) + +## Checking if Virtualbox exists +if exist_vm(base_box_name, logger): + if not args.overwrite: + logger.error("Error: VM %s already exists." % base_box_name) + else: + if not delete_vm(base_box_name, logger): + logger.error("Error: VM %s already exists and can't be deleted." % base_box_name) + exit(-1) + +if create_vm(base_box_name, int(round(args.size*953.674)), args.outputfolder, args.isofile, logger): + if start_vm(base_box_name, args.graphic, logger): + logger.info("Waiting for Installation to finish...") + start_time = time.time() + while status_vm(base_box_name, logger) and time.time()-start_time <= timeout: + time.sleep(1) + if time.time()-start_time > timeout: + logger.error("VM took more than %s seconds. Timeout activated." % timeout) + else: + logger.info("VM is now powered off.") + logger.info("Packaging VM with Vagrant.") + if package_vm(base_box_name, os.path.join(args.outputfolder, outputFileName), logger): + print "Packaging was successful. You can now import your new base box with" \ + " 'vagrant box add tsdbbench-debian %s'" %(os.path.join(args.outputfolder, outputFileName)) + logger.info("Deleting VM.") + if not delete_vm(base_box_name, logger): + logger.warning("Error: VM %s can't be deleted, please delete by hand." % base_box_name) + else: + logger.error("Error: VM %s can't be started." % base_box_name) + exit(-1) +else: + logger.error("Error: VM %s can't be created." % base_box_name) + exit(-1) + +exit(0) \ No newline at end of file diff --git a/TSDBBench.py b/TSDBBench.py index ac2d3b5..f02f12f 100755 --- a/TSDBBench.py +++ b/TSDBBench.py @@ -20,7 +20,7 @@ vagrantCredFiles=["vagrantconf.rb", "vagrantconf_gen.rb", "vagrantconf_db.rb"] vagrantBasicFilesFolder="basic" -availProviders=['vsphere', 'openstack'] # First one is default +availProviders=['virtualbox', 'vsphere', 'openstack'] # First one is default def run_workload(genDict, dbDict, dbName, workloadName, timeseries, granularity, bucket, test, onlyPrerun, debug, logger): if test: diff --git a/Vm.py b/Vm.py index a202e5c..ce1d9d9 100644 --- a/Vm.py +++ b/Vm.py @@ -149,7 +149,11 @@ def run_without_output (self,disableKnownHosts,command,warn_only=False,quiet=Fal return False def get_ip(self): - result = self.run_with_output (True,'sudo ifconfig | grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" | head -n1',True, True) + head_str = " | head -n1" + if self.provider == "virtualbox": + # virtualbox uses second network interface for vm-interconnections + head_str = " | head -n4 | tail -n1" + result = self.run_with_output (True,'sudo ifconfig | grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"%s' % (head_str),True, True) if result.return_code == 0: return result.stdout else: diff --git a/preseed-virtualbox.cfg b/preseed-virtualbox.cfg new file mode 100644 index 0000000..c345603 --- /dev/null +++ b/preseed-virtualbox.cfg @@ -0,0 +1,136 @@ +#### Contents of the preconfiguration file (for jessie) +### Localization +d-i debian-installer/language string en +d-i debian-installer/country string US +d-i debian-installer/locale string en_US.UTF-8 +d-i localechooser/supported-locales multiselect en_US.UTF-8 +d-i keyboard-configuration/xkb-keymap select de +d-i netcfg/choose_interface select auto +d-i netcfg/link_wait_timeout string 10 +d-i netcfg/dhcp_timeout string 60 +d-i netcfg/dhcpv6_timeout string 60 +d-i netcfg/get_hostname string Vagrant-VM +d-i netcfg/get_domain string localdomain +d-i hw-detect/load_firmware boolean true +d-i mirror/country string manual +d-i mirror/http/hostname string ftp.de.debian.org +d-i mirror/http/directory string /debian +d-i mirror/http/proxy string +d-i passwd/root-login boolean false +# Generierung von PW Hashes mit mkpasswd -m sha-512 +#d-i passwd/root-password-crypted password +d-i passwd/root-password password vagrant +d-i passwd/root-password-again password vagrant +d-i passwd/user-fullname string Vagrant +d-i passwd/username string vagrant +d-i passwd/user-password password vagrant +d-i passwd/user-password-again password vagrant +#d-i passwd/user-password-crypted password [MD5 hash] +d-i passwd/user-default-groups string vagrant cdrom floppy audio dip video plugdev netdev sudo +d-i clock-setup/utc boolean true +d-i time/zone string Etc/UTC +d-i clock-setup/ntp boolean true +d-i partman-auto/disk string /dev/sda +d-i partman-auto/method string regular +d-i partman-lvm/device_remove_lvm boolean true +d-i partman-md/device_remove_md boolean true +d-i partman-lvm/confirm boolean true +d-i partman-lvm/confirm_nooverwrite boolean true +#d-i partman-auto/choose_recipe select home +d-i partman-auto/expert_recipe string \ +boot-root :: \ +1000 10000 1000000000000 ext4 \ +$primary{ } $bootable{ } \ +method{ format } format{ } \ +use_filesystem{ } filesystem{ ext4 } \ +mountpoint{ / } \ +. \ +512 512 512 linux-swap \ +method{ swap } format{ } \ +. +d-i partman-partitioning/confirm_write_new_label boolean true +d-i partman/choose_partition select finish +d-i partman/confirm boolean true +d-i partman/confirm_nooverwrite boolean true +d-i partman/mount_style select uuid +d-i base-installer/kernel/image string linux-image-amd64 +d-i apt-setup/non-free boolean true +d-i apt-setup/contrib boolean true +d-i apt-setup/services-select multiselect security, updates +d-i apt-setup/security_host string security.debian.org +#d-i apt-setup/multiarch string i386 +tasksel tasksel/first multiselect standard, ssh-server +d-i pkgsel/include string build-essential, ruby-highline, ruby-termios, sudo, ntp, linux-headers-amd64, dpkg, screen, htop, wget, curl, openjdk-7-jre, open-vm-tools, rsync, libpam-systemd, python2.7, fabric, resolvconf, linux-image-amd64, openssh-server, virtualbox-guest-dkms +d-i pkgsel/upgrade select full-upgrade +popularity-contest popularity-contest/participate boolean false +d-i grub-installer/only_debian boolean true +d-i grub-installer/with_other_os boolean true +d-i grub-installer/bootdev string /dev/sda +#d-i grub-installer/bootdev string default +#d-i debian-installer/add-kernel-opts string nousb +d-i finish-install/reboot_in_progress note +d-i cdrom-detect/eject boolean true +d-i debian-installer/exit/poweroff boolean true +d-i preseed/late_command string \ +in-target sed -i 's/^%sudo.*$/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/g' /etc/sudoers; \ +in-target /bin/sh -c "echo 'Defaults env_keep += \"SSH_AUTH_SOCK DEBIAN_FRONTEND\"' >> /etc/sudoers"; \ +in-target /bin/sh -c "echo 'export DEBIAN_FRONTEND=noninteractive' >> /home/vagrant/.bashrc"; \ +in-target /bin/sh -c "echo 'export DEBIAN_FRONTEND=noninteractive' >> /root/.bashrc"; \ +in-target /bin/sh -c "echo 'blacklist ipv6' >> /etc/modprobe.d/blacklist.conf"; \ +in-target /bin/sh -c "echo 'net.ipv6.conf.all.disable_ipv6 = 1' >> /etc/sysctl.d/01-disable-ipv6.conf"; \ +in-target mkdir -p /home/vagrant/.ssh; \ +in-target /bin/sh -c "echo 'fs.file-max = 404358' >> /etc/sysctl.conf"; \ +in-target /bin/sh -c "echo 'fs.file-max = 404358' >> /etc/sysctl.d/99-sysctl.conf"; \ +in-target /bin/sh -c "echo '* - nofile 404358' >> /etc/security/limits.conf"; \ +in-target /bin/sh -c "echo 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key' >> /home/vagrant/.ssh/authorized_keys"; \ +in-target /bin/sh -c "echo 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key' >> /home/vagrant/.ssh/id_rsa.pub"; \ +in-target /bin/sh -c "echo 'Host *' >> /home/vagrant/.ssh/config"; \ +in-target /bin/sh -c "echo ' StrictHostKeyChecking no' >> /home/vagrant/.ssh/config"; \ +in-target /bin/sh -c "echo ' UserKnownHostsFile=/dev/null' >> /home/vagrant/.ssh/config"; \ +in-target /bin/sh -c "echo '-----BEGIN RSA PRIVATE KEY-----' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZUvnJUTvzf' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'TK2Lg6EdbUE9TarUlBf/xPfuEhMSlIE5keb/Zz3/LUlRg8yDqz5w+QWVJ4utnKnK' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'iqwZN0mwpwU7YSyJhlT4YV1F3n4YjLswM5wJs2oqm0jssQu/BT0tyEXNDYBLEF4A' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'sClaWuSJ2kjq7KhrrYXzagqhnSei9ODYFShJu8UWVec3Ihb5ZXlzO6vdNQ1J9Xsf' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo '4m+2ywKBgQD6qFxx/Rv9CNN96l/4rb14HKirC2o/orApiHmHDsURs5rUKDx0f9iP' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'cXN7S1uePXuJRK/5hsubaOCx3Owd2u9gD6Oq0CsMkE4CUSiJcYrMANtx54cGH7Rk' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'EjFZxK8xAv1ldELEyxrFqkbE4BKd8QOt414qjvTGyAK+OLD3M2QdCQKBgQDtx8pN' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'CAxR7yhHbIWT1AH66+XWN8bXq7l3RO/ukeaci98JfkbkxURZhtxV/HHuvUhnPLdX' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo '3TwygPBYZFNo4pzVEhzWoTtnEtrFueKxyc3+LjZpuo+mBlQ6ORtfgkr9gBVphXZG' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'YEzkCD3lVdl8L4cw9BVpKrJCs1c5taGjDgdInQKBgHm/fVvv96bJxc9x1tffXAcj' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo '3OVdUN0UgXNCSaf/3A/phbeBQe9xS+3mpc4r6qvx+iy69mNBeNZ0xOitIjpjBo2+' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'dBEjSBwLk5q5tJqHmy/jKMJL4n9ROlx93XS+njxgibTvU6Fp9w+NOFD/HvxB3Tcz' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo '6+jJF85D5BNAG3DBMKBjAoGBAOAxZvgsKN+JuENXsST7F89Tck2iTcQIT8g5rwWC' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'P9Vt74yboe2kDT531w8+egz7nAmRBKNM751U/95P9t88EDacDI/Z2OwnuFQHCPDF' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'llYOUI+SpLJ6/vURRbHSnnn8a/XG+nzedGH5JGqEJNQsz+xT2axM0/W/CRknmGaJ' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'kda/AoGANWrLCz708y7VYgAtW2Uf1DPOIYMdvo6fxIB5i9ZfISgcJ/bbCUkFrhoH' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo '+vq/5CIWxCPp0f85R4qxxQ5ihxJ0YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQ' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo 'NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s=' >> /home/vagrant/.ssh/id_rsa"; \ +in-target /bin/sh -c "echo '-----END RSA PRIVATE KEY-----' >> /home/vagrant/.ssh/id_rsa"; \ +in-target chmod 640 /home/vagrant/.ssh/id_rsa.pub; \ +in-target chmod 600 /home/vagrant/.ssh/id_rsa; \ +in-target chown -R vagrant:vagrant /home/vagrant/; \ +in-target chmod -R go-rwx /home/vagrant/.ssh/authorized_keys; \ +in-target cp -r /home/vagrant/.ssh /root/; \ +in-target chown -R root:root /root/.ssh/; \ +in-target sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config; \ +in-target rm /etc/udev/rules.d/70-persistent-net.rules; \ +in-target /bin/sh -c "echo '#!/bin/bash' >> /home/vagrant/change_hostname.sh"; \ +in-target /bin/sh -c "echo 'get_ip=\$(sudo ifconfig | grep -E -o \"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\" | head -n1)' >> /home/vagrant/change_hostname.sh"; \ +in-target /bin/sh -c "echo 'sudo -s bash -c \"echo \\\"\$get_ip \$1\\\" >> /etc/hosts\"' >> /home/vagrant/change_hostname.sh"; \ +in-target /bin/sh -c "echo 'sudo -s bash -c \"sudo hostname \$1;' >> /home/vagrant/change_hostname.sh"; \ +in-target /bin/sh -c "echo 'sudo -s bash -c \"echo \\\"\$1\\\" > /etc/hostname\"' >> /home/vagrant/change_hostname.sh"; \ +in-target /bin/sh -c "echo 'sudo -s bash -c \"sudo sed -i \"s/127.0.1.1.*$//g\" /etc/hosts' >> /home/vagrant/change_hostname.sh"; \ +in-target /bin/sh -c "echo 'sudo hostnamectl set-hostname \$1' >> /home/vagrant/change_hostname.sh"; \ +in-target cp /home/vagrant/change_hostname.sh /root/change_hostname.sh; \ +in-target chmod 775 /home/vagrant/change_hostname.sh /root/change_hostname.sh; \ +in-target chown vagrant:vagrant /home/vagrant/change_hostname.sh; \ +in-target chown root:root /root/change_hostname.sh; \ +in-target apt-get clean; \ No newline at end of file diff --git a/vagrant_files/vagrantconf.rb b/vagrant_files/vagrantconf.rb index e92b9fd..bc2b513 100644 --- a/vagrant_files/vagrantconf.rb +++ b/vagrant_files/vagrantconf.rb @@ -22,6 +22,11 @@ openstack.floating_ip_pool = '' openstack.openstack_image_url = '' end + config.vm.provider :virtualbox do |virtualbox| + config.vm.box = "tsdbbench-debian" + virtualbox.gui = false + config.vm.network "private_network", type: "dhcp" + end end # links to prepackaged/precompiled stuff diff --git a/vagrant_files/vagrantconf_db.rb b/vagrant_files/vagrantconf_db.rb index 311610e..8176b86 100644 --- a/vagrant_files/vagrantconf_db.rb +++ b/vagrant_files/vagrantconf_db.rb @@ -1,8 +1,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.provider :vsphere do |vsphere| - vsphere.template_name = '' + vsphere.template_name = '' end config.vm.provider :openstack do |openstack| openstack.flavor = '' end + config.vm.provider :virtualbox do |virtualbox| + virtualbox.customize ["modifyvm", :id, "--memory", "1024"] + end end \ No newline at end of file diff --git a/vagrant_files/vagrantconf_gen.rb b/vagrant_files/vagrantconf_gen.rb index bf01a7b..4c8645a 100644 --- a/vagrant_files/vagrantconf_gen.rb +++ b/vagrant_files/vagrantconf_gen.rb @@ -5,4 +5,7 @@ config.vm.provider :openstack do |openstack| openstack.flavor = '' end + config.vm.provider :virtualbox do |virtualbox| + virtualbox.customize ["modifyvm", :id, "--memory", "1024"] + end end \ No newline at end of file