Created
August 17, 2019 22:17
-
-
Save Jaskaranbir/ad5dc6201a1ed9e484864da8ff4f16db to your computer and use it in GitHub Desktop.
Vagrantfile I use for Hyper-V
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
plugin_dependencies = [ | |
"vagrant-docker-compose", | |
# "vagrant-windows-hyperv" | |
# "vagrant-vbguest" | |
] | |
needsRestart = false | |
# Install plugins if required | |
plugin_dependencies.each do |plugin_name| | |
unless Vagrant.has_plugin? plugin_name | |
system("vagrant plugin install #{plugin_name}") | |
needsRestart = true | |
puts "#{plugin_name} installed" | |
end | |
end | |
# Restart vagrant if new plugins were installed | |
if needsRestart === true | |
exec "vagrant #{ARGV.join(' ')}" | |
end | |
Vagrant.configure(2) do |config| | |
config.vm.define :codevm do |codevm| | |
codevm.vm.hostname = "code" | |
codevm.vm.box = "bento/ubuntu-18.04" | |
codevm.vm.provider :hyperv do |h| | |
h.vmname = "code-vm" | |
h.memory = "5120" | |
# h.memory = "11776" | |
h.maxmemory = "14336" | |
h.cpus = 12 | |
h.enable_virtualization_extensions = true | |
h.linked_clone = true | |
h.vm_integration_services = { | |
time_synchronization: true | |
} | |
config.vm.synced_folder ".", "/vagrant", type: "smb", | |
mount_options: ["mfsymlinks"] | |
config.vm.network "public_network", | |
auto_config: true, | |
bridge: ["eth0": "ext-1", "eth1": "ext-1"] | |
end | |
codevm.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'" | |
# codevm.vm.provision :shell, inline: <<-SHELL | |
# echo \ | |
# " eth1: | |
# dhcp4: no | |
# addresses: [192.168.0.20/24] | |
# routes: | |
# - to: 0.0.0.0/0 | |
# via: 192.168.0.1 | |
# metric: 50" >> /etc/netplan/$(ls /etc/netplan) && \ | |
# cat /etc/netplan/$(ls /etc/netplan) && \ | |
# netplan --debug apply | |
# SHELL | |
codevm.vm.provision :docker_compose, | |
compose_version: "1.24.0" | |
# Automatically set current-dir to /vagrant on vagrant ssh | |
codevm.vm.provision :shell, | |
inline: "echo 'cd /vagrant' >> /home/vagrant/.bashrc" | |
# Install some required packages | |
codevm.vm.provision :shell, inline: <<-SHELL | |
apt-get update && \ | |
apt-get install -y apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
gnupg-agent \ | |
software-properties-common | |
SHELL | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment