Vagrant
Contents
-
Vagrant
- vagrantfile
- vagrant init
- vagrant up
- centos 7
- Slackbuild install vagrant Slack 14.2
- Slackbuild install vagrant Slack64 15.0
- Slackbuild install vagrant 2.4.1-1 Slack64 15.0
- Vagrant file ubuntu maven docker java8
- SandboxVM nodejs jdk8 docker ubuntu
- Install vagrant and VirtualBox on debian bullseye - yoga 300
vagrantfile
sample file for ubuntu xenial
1 Vagrant.configure("2") do |config|
2 config.vm.box = "ubuntu/xenial64"
3 config.vm.network "forwarded_port", guest: 8080, host: 18080, host_ip: "127.0.0.1"
4 config.vm.network "forwarded_port", guest: 9990, host: 19990, host_ip: "127.0.0.1"
5 config.vm.network "forwarded_port", guest: 9000, host: 19000, host_ip: "127.0.0.1"
6 config.vm.network "forwarded_port", guest: 9001, host: 19001, host_ip: "127.0.0.1"
7 config.vm.network "forwarded_port", guest: 9002, host: 19002, host_ip: "127.0.0.1"
8 config.vm.network "forwarded_port", guest: 9003, host: 19003, host_ip: "127.0.0.1"
9 config.vm.network "forwarded_port", guest: 4200, host: 14200, host_ip: "127.0.0.1"
10 config.vm.network "forwarded_port", guest: 5672, host: 15672, host_ip: "127.0.0.1"
11 config.vm.network "forwarded_port", guest: 15672, host: 25672, host_ip: "127.0.0.1"
12 config.vm.network "forwarded_port", guest: 8000, host: 18000, host_ip: "127.0.0.1"
13 config.vm.network "forwarded_port", guest: 5000, host: 15000, host_ip: "127.0.0.1"
14 config.vm.network "forwarded_port", guest: 1433, host: 11433, host_ip: "127.0.0.1"
15 config.vm.network "forwarded_port", guest: 9042, host: 19042, host_ip: "127.0.0.1"
16 config.vm.network "forwarded_port", guest: 27017, host: 37017, host_ip: "127.0.0.1"
17
18 config.vm.provider "virtualbox" do |vb|
19 vb.gui = false
20 vb.memory = "2048"
21 vb.name = "UbuntuVM"
22 file_to_disk = "dockerdata.vmdk"
23 unless File.exist?(file_to_disk)
24 vb.customize [ "createmedium", "disk", "--filename", file_to_disk, "--format", "vmdk", "--size", 1024 * 10 ]
25 end
26 vb.customize [ "storageattach", "UbuntuVM" , "--storagectl", "SCSI", "--port", "2", "--device", "0", "--type", "hdd", "--medium", file_to_disk]
27 end
28
29 config.vm.provision "shell", inline: <<-SHELL
30 apt-get update
31 apt-get install apt-transport-https ca-certificates curl software-properties-common
32 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
33 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
34 apt-get update
35 apt-get install openjdk-8-jdk maven nodejs npm docker-ce -y
36 usermod -a vagrant -G docker
37 dd if=/dev/zero of=/swapfile1 bs=1024 count=2097152
38 chown root:root /swapfile1
39 chmod 0600 /swapfile1
40 mkswap /swapfile1
41 swapon /swapfile1
42 echo "/swapfile1 none swap sw 0 0" >> /etc/fstab
43 # nodejs stuff
44 apt-get purge nodejs npm
45 curl -sL https://deb.nodesource.com/setup_9.x | bash -
46 apt-get install -y nodejs
47 # prepare new disk for docker data ...
48 echo -e "n\np\n1\n\n\nw" | fdisk /dev/sdc
49 mkfs.ext4 /dev/sdc1
50 mkdir -p /mnt/dockerdata
51 mount /dev/sdc1 /mnt/dockerdata/
52 echo "/dev/sdc1 /mnt/dockerdata ext4 defaults 0 0 " >> /etc/fstab
53 echo -e "{\n \"data-root\": \"/mnt/dockerdata\"\n}" > /etc/docker/daemon.json
54 SHELL
55 end
vagrant init
vagrant init [name [url]] This initializes the current directory to be a Vagrant environment by creating an initial Vagrantfile if one does not already exist. If a first argument is given, it will prepopulate the config.vm.box setting in the created Vagrantfile. If a second argument is given, it will prepopulate the config.vm.box_url setting in the created Vagrantfile. Create a base Vagrantfile: $ vagrant init hashicorp/precise64 Create a minimal Vagrantfile (no comments or helpers): $ vagrant init -m hashicorp/precise64 Create a Vagrantfile with the specific box, from the specific box URL: $ vagrant init my-company-box https://boxes.company.com/my-company.box
vagrant up
vagrant up [name|id] This command creates and configures guest machines according to your Vagrantfile.
centos 7
# https://app.vagrantup.com/centos/boxes/7 vagrant init centos/7 # customize the Vagrantfile vagrant up
Slackbuild install vagrant Slack 14.2
Slackbuild install vagrant Slack64 15.0
Slackbuild install vagrant 2.4.1-1 Slack64 15.0
1 # update to vagrant 2.4.1-1
2 cd /tmp/
3 wget https://slackbuilds.org/slackbuilds/15.0/system/vagrant.tar.gz
4 tar xvzf vagrant.tar.gz
5 cd vagrant
6 wget https://releases.hashicorp.com/vagrant/2.4.1/vagrant-2.4.1-1.x86_64.rpm
7 nano vagrant.SlackBuild
8 # VERSION=${VERSION:-2.4.1-1}
9 # rpm2cpio < $CWD/${PRGNAM}-${VERSION}.$SRCARCH.rpm | cpio -ivmd
10 ./vagrant.SlackBuild
11 sudo /sbin/removepkg vagrant-2.2.15-x86_64-1_SBo
12 sudo /sbin/installpkg /tmp/vagrant-2.4.1-1-x86_64-1_SBo.tgz
13 vagrant -v
14 # go to folder with Vagrantfile
15 vagrant up
Vagrant file ubuntu maven docker java8
- cat Vagrantfile | grep -v "^.*#"
1 Vagrant.configure("2") do |config|
2 config.vm.box = "ubuntu/xenial64"
3 config.vm.network "forwarded_port", guest: 8080, host: 18080, host_ip: "127.0.0.1"
4 config.vm.network "forwarded_port", guest: 9990, host: 19990, host_ip: "127.0.0.1"
5 config.vm.network "forwarded_port", guest: 9000, host: 19000, host_ip: "127.0.0.1"
6 config.vm.network "forwarded_port", guest: 9001, host: 19001, host_ip: "127.0.0.1"
7 config.vm.network "forwarded_port", guest: 9002, host: 19002, host_ip: "127.0.0.1"
8 config.vm.network "forwarded_port", guest: 9003, host: 19003, host_ip: "127.0.0.1"
9
10 config.vm.provider "virtualbox" do |vb|
11 vb.gui = false
12 vb.memory = "2048"
13 end
14
15 config.vm.provision "shell", inline: <<-SHELL
16 apt-get update
17 apt-get install docker-ce
18 apt-get install openjdk-8-jdk
19 apt-get install maven
20 dd if=/dev/zero of=/swapfile1 bs=1024 count=2097152
21 chown root:root /swapfile1
22 chmod 0600 /swapfile1
23 mkswap /swapfile1
24 swapon /swapfile1
25 echo "/swapfile1 none swap sw 0 0" >> /etc/fstab
26 SHELL
27 end
SandboxVM nodejs jdk8 docker ubuntu
1 Vagrant.configure("2") do |config|
2 config.vm.box = "ubuntu/xenial64"
3 config.vm.network "forwarded_port", guest: 8080, host: 18080, host_ip: "127.0.0.1"
4 config.vm.network "forwarded_port", guest: 9990, host: 19990, host_ip: "127.0.0.1"
5 config.vm.network "forwarded_port", guest: 9000, host: 19000, host_ip: "127.0.0.1"
6 config.vm.network "forwarded_port", guest: 9001, host: 19001, host_ip: "127.0.0.1"
7 config.vm.network "forwarded_port", guest: 9002, host: 19002, host_ip: "127.0.0.1"
8 config.vm.network "forwarded_port", guest: 9003, host: 19003, host_ip: "127.0.0.1"
9 config.vm.network "forwarded_port", guest: 4200, host: 14200, host_ip: "127.0.0.1"
10 config.vm.network "forwarded_port", guest: 5672, host: 15672, host_ip: "127.0.0.1"
11 config.vm.network "forwarded_port", guest: 15672, host: 25672, host_ip: "127.0.0.1"
12 config.vm.network "forwarded_port", guest: 8000, host: 18000, host_ip: "127.0.0.1"
13 config.vm.network "forwarded_port", guest: 5000, host: 15000, host_ip: "127.0.0.1"
14 config.vm.network "forwarded_port", guest: 1433, host: 11433, host_ip: "127.0.0.1"
15 config.vm.network "forwarded_port", guest: 9042, host: 19042, host_ip: "127.0.0.1"
16 config.vm.network "forwarded_port", guest: 27017, host: 37017, host_ip: "127.0.0.1"
17
18 config.vm.provider "virtualbox" do |vb|
19 vb.gui = false
20 vb.memory = "2048"
21 vb.name = "SandboxVM"
22 file_to_disk = "dockerdata.vmdk"
23 unless File.exist?(file_to_disk)
24 vb.customize [ "createmedium", "disk", "--filename", file_to_disk, "--format", "vmdk", "--size", 1024 * 10 ]
25 end
26 vb.customize [ "storageattach", "SandboxVM" , "--storagectl", "SCSI", "--port", "2",, "--device", "0", "--type", "hdd", "--medium", file_to_disk]
27 end
28
29 config.vm.provision "shell", inline: <<-SHELL
30 apt-get update
31 apt-get install apt-transport-https ca-certificates curl software-properties-common
32 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
33 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
34 apt-get update
35 apt-get install openjdk-8-jdk maven -y
36 apt-get install nodejs npm -y
37 apt-get install docker-ce -y
38 usermod -a vagrant -G docker
39 dd if=/dev/zero of=/swapfile1 bs=1024 count=2097152
40 chown root:root /swapfile1
41 chmod 0600 /swapfile1
42 mkswap /swapfile1
43 swapon /swapfile1
44 echo "/swapfile1 none swap sw 0 0" >> /etc/fstab
45 apt-get purge nodejs npm
46 curl -sL https://deb.nodesource.com/setup_9.x | bash -
47 apt-get install -y nodejs
48 echo -e "n\np\n1\n\n\nw" | fdisk /dev/sdc
49 mkfs.ext4 /dev/sdc1
50 mkdir -p /mnt/dockerdata
51 mount /dev/sdc1 /mnt/dockerdata/
52 echo "/dev/sdc1 /mnt/dockerdata ext4 defaults 0 0 " >> /etc/fstab
53 echo -e "{\n \"data-root\": \"/mnt/dockerdata\"\n}" > /etc/docker/daemon.json
54 SHELL
55 end
Install vagrant and VirtualBox on debian bullseye - yoga 300
1 sudo apt update
2 sudo apt upgrade
3 cd Downloads/
4 wget https://download.virtualbox.org/virtualbox/6.1.34/virtualbox-6.1_6.1.34-150636.1~Debian~bullseye_amd64.deb
5 wget https://releases.hashicorp.com/vagrant/2.2.19/vagrant_2.2.19_x86_64.deb
6 # install dependencies
7 sudo apt install -y libqt5opengl5 linux-headers-amd64 linux-source
8 sudo apt install dkms build-essential linux-image-5.10.0-13-amd64
9 sudo apt autoremove
10 # remove non used linux kernel images
11 sudo apt remove linux-image-4.19.0-6-amd64
12 sudo apt remove linux-image-5.17.0-1-amd64
13 # install packages
14 sudo dpkg -i virtualbox-6.1_6.1.34-150636.1~Debian~bullseye_amd64.deb
15 sudo dpkg -i vagrant_2.2.19_x86_64.deb
16 virtualbox &
17 vagrant --version
Vagrantfile
- vagrant up
- vagrant ssh
1 # -*- mode: ruby -*-
2 # vi: set ft=ruby :
3
4 Vagrant.configure("2") do |config|
5 config.vm.box = "debian/bullseye64"
6 config.vm.provider "virtualbox" do |vb|
7 vb.customize ["setextradata", :id, "CustomVideoMode1", "1366x768x32"]
8 end
9
10 config.vm.provision "shell", inline: <<-SHELL
11 apt update
12 apt upgrade
13 apt install -y docker.io openjdk-17-jdk maven gradle
14 apt install -y xorg lxterminal wmaker lightdm ibus
15 usermod -a vagrant -G docker
16 service lightdm start
17 SHELL
18 end