forked from theforeman/forklift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
44 lines (32 loc) · 1.12 KB
/
Vagrantfile
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
# rubocop:disable Naming/FileName
# -*- mode: ruby -*-
# vi: set ft=ruby :
ENV['LANG'] = 'en_US.UTF-8'
ENV['LC_ALL'] = 'en_US.UTF-8'
VAGRANTFILE_DIR = File.dirname(__FILE__)
require "#{VAGRANTFILE_DIR}/vagrant/lib/forklift"
def migrate_boxes!
old = "#{VAGRANTFILE_DIR}/boxes.d/99-local.yaml"
new = "#{VAGRANTFILE_DIR}/vagrant/boxes.d/99-local.yaml"
return if File.symlink?(old) || !File.exist?(old)
if File.exist?(new)
raise "File #{new} already exists, refusing to overwrite. Remove boxes.d/99-local.yaml in favor of vagrant/boxes.d/99-local.yaml"
end
File.rename(old, new)
end
def migrate_settings!
old = "#{VAGRANTFILE_DIR}/settings.yaml"
new = "#{VAGRANTFILE_DIR}/vagrant/settings.yaml"
return if !File.exist?(old)
if File.exist?(new)
raise "File #{new} already exists, refusing to overwrite. Remove settings.yaml in favor of vagrant/settings.yaml"
end
File.rename(old, new)
end
migrate_boxes!
migrate_settings!
loader = Forklift::BoxLoader.new("#{VAGRANTFILE_DIR}/vagrant")
loader.load!
distributor = Forklift::BoxDistributor.new(loader.boxes)
distributor.distribute!
# rubocop:enable Naming/FileName