-
Notifications
You must be signed in to change notification settings - Fork 3
/
vagrantfile.template
53 lines (47 loc) · 1.9 KB
/
vagrantfile.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require "json"
version_file = File.open(File.dirname(__FILE__) + "/vagrant_routeros_plugin_version.json")
begin
plugin_version = Gem::Version.new(JSON.load(version_file)["vagrant_routeros_plugin_version"])
ensure
version_file.close
end
plugin_version_is_ok = Vagrant::Plugin::Manager.instance.installed_specs.any? do |spec|
match = spec.name == "vagrant-routeros"
next match if spec.version >= plugin_version
end
if not plugin_version_is_ok
if system("vagrant plugin install " + File.dirname(__FILE__) + "/vagrant-routeros-#{plugin_version}.gem")
exec "vagrant #{ARGV.join(' ')}"
else
abort "Installation of 'vagrant-routeros' plugin has failed. Aborting."
end
end
Vagrant.configure(2) do |config|
config.vm.guest = "routeros"
config.ssh.username = "vagrant"
config.ssh.shell = "\#"
config.ssh.keys_only = true
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.network "private_network", type: "dhcp", auto_config: false
config.vm.provider "virtualbox" do |vb|
vb.check_guest_additions = false
end
# Temporary fix for "sign_and_send_pubkey: no mutual signature supported" error
# Recent versions of ssh clients deprecate SHA-1 logins due to security risks
# https://forum.mikrotik.com/viewtopic.php?p=882513
# We check OpenSSH client version before using PubkeyAcceptedAlgorithms option though
# because earlier versions don't support it and throw an error
begin
# We expect output like this
# OpenSSH_8.8p1, OpenSSL 1.1.1l 24 Aug 2021
ssh_version = Gem::Version.new(`ssh -V 2>&1`.sub(/^OpenSSH_([\d.p]+)[, ].*/m, '\1').split('p')[0])
rescue
ssh_version = Gem::Version.new("0.0")
end
if ssh_version >= Gem::Version.new("8.8")
config.ssh.extra_args = ["-oPubkeyAcceptedAlgorithms=+ssh-rsa"]
end
config.vm.provision "routeros_command", name: "Initial provision",
command: "/import vagrant_provision.rsc"
end