beaker-vagrant 0.6.4 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/release.yml +24 -0
- data/.github/workflows/test.yml +32 -0
- data/.rspec +1 -0
- data/CHANGELOG.md +27 -0
- data/Rakefile +2 -2
- data/beaker-vagrant.gemspec +2 -6
- data/docs/vagrant.md +39 -1
- data/lib/beaker-vagrant/version.rb +1 -1
- data/lib/beaker/hypervisor/vagrant.rb +45 -67
- data/lib/beaker/hypervisor/vagrant_custom.rb +1 -0
- data/lib/beaker/hypervisor/vagrant_libvirt.rb +12 -22
- data/lib/beaker/hypervisor/vagrant_virtualbox.rb +4 -4
- data/spec/beaker/hypervisor/vagrant_custom_spec.rb +3 -2
- data/spec/beaker/hypervisor/vagrant_desktop_spec.rb +33 -47
- data/spec/beaker/hypervisor/vagrant_fusion_spec.rb +14 -14
- data/spec/beaker/hypervisor/vagrant_libvirt_spec.rb +23 -26
- data/spec/beaker/hypervisor/vagrant_parallels_spec.rb +20 -23
- data/spec/beaker/hypervisor/vagrant_spec.rb +43 -118
- data/spec/beaker/hypervisor/vagrant_virtualbox_spec.rb +47 -56
- data/spec/beaker/hypervisor/vagrant_workstation_spec.rb +33 -47
- metadata +17 -21
@@ -63,15 +63,15 @@ class Beaker::VagrantVirtualbox < Beaker::Vagrant
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
provider_section << " vb.customize [
|
66
|
+
provider_section << " vb.customize ['modifyvm', :id, '--ioapic', 'on']\n" unless host['ioapic'].nil?
|
67
67
|
|
68
|
-
provider_section << " vb.customize [
|
68
|
+
provider_section << " vb.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']\n" unless host['natdns'].nil?
|
69
69
|
|
70
|
-
provider_section << " vb.customize [
|
70
|
+
provider_section << " vb.customize ['modifyvm', :id, '--natdnsproxy1', 'on']\n" unless host['natdns'].nil?
|
71
71
|
|
72
72
|
provider_section << " vb.gui = true\n" unless host['vb_gui'].nil?
|
73
73
|
|
74
|
-
provider_section << " [
|
74
|
+
provider_section << " vb.customize ['modifyvm', :id, '--cpuidset', '1','000206a7','02100800','1fbae3bf','bfebfbff']\n" if /osx/i.match(host['platform'])
|
75
75
|
|
76
76
|
if host['disk_path']
|
77
77
|
unless File.exist?(host['disk_path'])
|
@@ -19,9 +19,10 @@ describe Beaker::VagrantCustom do
|
|
19
19
|
expect( vagrant ).to receive( :set_ssh_config ).with( host, host_prev_name ).once
|
20
20
|
end
|
21
21
|
expect( vagrant ).to receive( :hack_etc_hosts ).with( @hosts, options ).once
|
22
|
-
FakeFS.activate!
|
23
22
|
expect( vagrant ).to receive( :vagrant_cmd ).with( "up" ).once
|
24
|
-
|
23
|
+
FakeFS do
|
24
|
+
vagrant.provision
|
25
|
+
end
|
25
26
|
end
|
26
27
|
|
27
28
|
context 'takes vagrant configuration from existing file' do
|
@@ -2,71 +2,57 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Beaker::VagrantDesktop do
|
4
4
|
let( :options ) { make_opts.merge({ :hosts_file => 'sample.cfg', 'logger' => double().as_null_object }) }
|
5
|
-
let( :vagrant ) {
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
@hosts = make_hosts()
|
9
|
-
end
|
5
|
+
let( :vagrant ) { described_class.new( hosts, options ) }
|
6
|
+
let( :hosts ) { make_hosts }
|
10
7
|
|
11
8
|
it "uses the vmware_desktop provider for provisioning" do
|
12
|
-
|
9
|
+
hosts.each do |host|
|
13
10
|
host_prev_name = host['user']
|
14
11
|
expect( vagrant ).to receive( :set_ssh_config ).with( host, 'vagrant' ).once
|
15
12
|
expect( vagrant ).to receive( :copy_ssh_to_root ).with( host, options ).once
|
16
13
|
expect( vagrant ).to receive( :set_ssh_config ).with( host, host_prev_name ).once
|
17
14
|
end
|
18
|
-
expect( vagrant ).to receive( :hack_etc_hosts ).with(
|
15
|
+
expect( vagrant ).to receive( :hack_etc_hosts ).with( hosts, options ).once
|
19
16
|
expect( vagrant ).to receive( :vagrant_cmd ).with( "up --provider vmware_desktop" ).once
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
it "can make a Vagranfile for a set of hosts" do
|
24
|
-
path = vagrant.instance_variable_get( :@vagrant_path )
|
25
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
26
|
-
|
27
|
-
vagrant.make_vfile( @hosts )
|
28
|
-
|
29
|
-
vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
|
30
|
-
expect( vagrantfile ).to include( %Q{ v.vm.provider :vmware_desktop do |v|\n v.vmx['memsize'] = '1024'\n end})
|
17
|
+
FakeFS do
|
18
|
+
vagrant.provision
|
19
|
+
end
|
31
20
|
end
|
32
21
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
expect( vagrantfile ).to include( %Q{ v.vmx['whitelist_verified'] = 'true'})
|
41
|
-
end
|
22
|
+
context 'can make a Vagrantfile' do
|
23
|
+
subject do
|
24
|
+
FakeFS do
|
25
|
+
vagrant.make_vfile(hosts)
|
26
|
+
File.read(vagrant.instance_variable_get(:@vagrant_file))
|
27
|
+
end
|
28
|
+
end
|
42
29
|
|
43
|
-
|
44
|
-
|
45
|
-
|
30
|
+
it "for a set of hosts" do
|
31
|
+
is_expected.to include( %Q{ v.vm.provider :vmware_desktop do |v|\n v.vmx['memsize'] = '1024'\n end})
|
32
|
+
end
|
46
33
|
|
47
|
-
|
34
|
+
context 'with whitelist_verified' do
|
35
|
+
let(:hosts) { make_hosts({:whitelist_verified => true}, 1) }
|
48
36
|
|
49
|
-
|
50
|
-
|
51
|
-
end
|
37
|
+
it { is_expected.to include( %Q{ v.vmx['whitelist_verified'] = 'true'}) }
|
38
|
+
end
|
52
39
|
|
53
|
-
|
54
|
-
|
55
|
-
hosts = make_hosts({:unmount_default_hgfs => true},1)
|
40
|
+
context 'with functional_hgfs' do
|
41
|
+
let(:hosts) { make_hosts({:functional_hgfs => true}, 1) }
|
56
42
|
|
57
|
-
|
43
|
+
it { is_expected.to include( %Q{ v.vmx['functional_hgfs'] = 'true'}) }
|
44
|
+
end
|
58
45
|
|
59
|
-
|
60
|
-
|
61
|
-
end
|
46
|
+
context 'with unmount_default_hgfs' do
|
47
|
+
let(:hosts) { make_hosts({:unmount_default_hgfs => true}, 1) }
|
62
48
|
|
63
|
-
|
64
|
-
|
65
|
-
hosts = make_hosts({:gui => true},1)
|
49
|
+
it { is_expected.to include( %Q{ v.vmx['unmount_default_hgfs'] = 'true'}) }
|
50
|
+
end
|
66
51
|
|
67
|
-
|
52
|
+
context "with gui" do
|
53
|
+
let(:hosts) { make_hosts({:gui => true},1) }
|
68
54
|
|
69
|
-
|
70
|
-
|
55
|
+
it { is_expected.to include( %Q{ v.vmx['gui'] = true}) }
|
56
|
+
end
|
71
57
|
end
|
72
58
|
end
|
@@ -2,31 +2,31 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Beaker::VagrantFusion do
|
4
4
|
let( :options ) { make_opts.merge({ :hosts_file => 'sample.cfg', 'logger' => double().as_null_object }) }
|
5
|
-
let( :vagrant ) {
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
@hosts = make_hosts()
|
9
|
-
end
|
5
|
+
let( :vagrant ) { described_class.new( hosts, options ) }
|
6
|
+
let( :hosts ) { make_hosts() }
|
10
7
|
|
11
8
|
it "uses the vmware_fusion provider for provisioning" do
|
12
|
-
|
9
|
+
hosts.each do |host|
|
13
10
|
host_prev_name = host['user']
|
14
11
|
expect( vagrant ).to receive( :set_ssh_config ).with( host, 'vagrant' ).once
|
15
12
|
expect( vagrant ).to receive( :copy_ssh_to_root ).with( host, options ).once
|
16
13
|
expect( vagrant ).to receive( :set_ssh_config ).with( host, host_prev_name ).once
|
17
14
|
end
|
18
|
-
expect( vagrant ).to receive( :hack_etc_hosts ).with(
|
15
|
+
expect( vagrant ).to receive( :hack_etc_hosts ).with( hosts, options ).once
|
19
16
|
expect( vagrant ).to receive( :vagrant_cmd ).with( "up --provider vmware_fusion" ).once
|
20
17
|
vagrant.provision
|
21
18
|
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
context 'Correct vagrant configuration' do
|
21
|
+
subject do
|
22
|
+
FakeFS do
|
23
|
+
vagrant.make_vfile( hosts, options )
|
24
|
+
File.read(vagrant.instance_variable_get(:@vagrant_file))
|
25
|
+
end
|
26
|
+
end
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
it 'has a provider section' do
|
29
|
+
is_expected.to include( %Q{ v.vm.provider :vmware_fusion do |v|\n v.vmx['memsize'] = '1024'\n end})
|
30
|
+
end
|
31
31
|
end
|
32
32
|
end
|
@@ -6,56 +6,53 @@ describe Beaker::VagrantLibvirt do
|
|
6
6
|
'libvirt' => { 'uri' => 'qemu+ssh://root@host/system'},
|
7
7
|
'vagrant_cpus' => 2,
|
8
8
|
}) }
|
9
|
-
let( :vagrant ) {
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
let( :vagrant ) { described_class.new( hosts, options ) }
|
10
|
+
let( :hosts ) do
|
11
|
+
make_hosts().each do |host|
|
12
|
+
host.delete('ip')
|
13
|
+
end
|
13
14
|
end
|
14
15
|
|
15
16
|
it "uses the vagrant_libvirt provider for provisioning" do
|
16
|
-
|
17
|
+
hosts.each do |host|
|
17
18
|
host_prev_name = host['user']
|
18
19
|
expect( vagrant ).to receive( :set_ssh_config ).with( host, 'vagrant' ).once
|
19
20
|
expect( vagrant ).to receive( :copy_ssh_to_root ).with( host, options ).once
|
20
21
|
expect( vagrant ).to receive( :set_ssh_config ).with( host, host_prev_name ).once
|
21
22
|
end
|
22
|
-
expect( vagrant ).to receive( :hack_etc_hosts ).with(
|
23
|
-
FakeFS.activate!
|
23
|
+
expect( vagrant ).to receive( :hack_etc_hosts ).with( hosts, options ).once
|
24
24
|
expect( vagrant ).to receive( :vagrant_cmd ).with( "up --provider libvirt" ).once
|
25
|
-
|
25
|
+
FakeFS do
|
26
|
+
vagrant.provision
|
27
|
+
end
|
26
28
|
end
|
27
29
|
|
28
30
|
context 'Correct vagrant configuration' do
|
29
|
-
|
30
|
-
FakeFS
|
31
|
-
|
31
|
+
subject do
|
32
|
+
FakeFS do
|
33
|
+
vagrant.make_vfile( hosts, options )
|
34
|
+
File.read(vagrant.instance_variable_get(:@vagrant_file))
|
35
|
+
end
|
36
|
+
end
|
32
37
|
|
33
|
-
|
34
|
-
|
38
|
+
it 'has a provider section' do
|
39
|
+
is_expected.to include( %Q{ v.vm.provider :libvirt do |node|})
|
35
40
|
end
|
36
41
|
|
37
|
-
it "
|
38
|
-
|
42
|
+
it "has no private network" do
|
43
|
+
is_expected.to include('v.vm.network :private_network')
|
39
44
|
end
|
40
45
|
|
41
46
|
it "can specify the memory as an integer" do
|
42
|
-
|
43
|
-
.to include('node.memory = 1024')
|
47
|
+
is_expected.to include('node.memory = 1024')
|
44
48
|
end
|
45
49
|
|
46
50
|
it "can specify the number of cpus" do
|
47
|
-
|
48
|
-
.to include("node.cpus = 2")
|
51
|
+
is_expected.to include("node.cpus = 2")
|
49
52
|
end
|
50
53
|
|
51
54
|
it "can specify any libvirt option" do
|
52
|
-
|
53
|
-
.to include("node.uri = 'qemu+ssh://root@host/system'")
|
54
|
-
end
|
55
|
-
|
56
|
-
it "has a mac address in the proper format" do
|
57
|
-
expect( @vagrantfile.split("\n").map(&:strip) )
|
58
|
-
.to include(/:mac => "08:00:27:\h{2}:\h{2}:\h{2}"/)
|
55
|
+
is_expected.to include("node.uri = 'qemu+ssh://root@host/system'")
|
59
56
|
end
|
60
57
|
end
|
61
58
|
end
|
@@ -2,43 +2,40 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Beaker::VagrantParallels do
|
4
4
|
let( :options ) { make_opts.merge({ :hosts_file => 'sample.cfg', 'logger' => double().as_null_object }) }
|
5
|
-
let( :vagrant ) { Beaker::VagrantParallels.new(
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
@hosts = make_hosts()
|
9
|
-
end
|
5
|
+
let( :vagrant ) { Beaker::VagrantParallels.new( hosts, options ) }
|
6
|
+
let( :hosts ) { make_hosts }
|
10
7
|
|
11
8
|
it "uses the parallels provider for provisioning" do
|
12
|
-
|
9
|
+
hosts.each do |host|
|
13
10
|
host_prev_name = host['user']
|
14
11
|
expect( vagrant ).to receive( :set_ssh_config ).with( host, 'vagrant' ).once
|
15
12
|
expect( vagrant ).to receive( :copy_ssh_to_root ).with( host, options ).once
|
16
13
|
expect( vagrant ).to receive( :set_ssh_config ).with( host, host_prev_name ).once
|
17
14
|
end
|
18
|
-
expect( vagrant ).to receive( :hack_etc_hosts ).with(
|
15
|
+
expect( vagrant ).to receive( :hack_etc_hosts ).with( hosts, options ).once
|
19
16
|
expect( vagrant ).to receive( :vagrant_cmd ).with( "up --provider parallels" ).once
|
20
17
|
vagrant.provision
|
21
18
|
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
context 'Correct vagrant configuration' do
|
21
|
+
subject do
|
22
|
+
FakeFS do
|
23
|
+
vagrant.make_vfile( hosts, options )
|
24
|
+
File.read(vagrant.instance_variable_get(:@vagrant_file))
|
25
|
+
end
|
26
|
+
end
|
28
27
|
|
29
|
-
|
30
|
-
|
28
|
+
it "can make a Vagrantfile for a set of hosts" do
|
29
|
+
is_expected.to include( %Q{ v.vm.provider :parallels do |prl|\n prl.optimize_power_consumption = false\n prl.memory = '1024'\n end})
|
30
|
+
end
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
options.merge
|
35
|
-
|
36
|
-
vfile_section = vagrant.class.provider_vfile_section( @hosts.first, options )
|
37
|
-
|
38
|
-
match = vfile_section.match(/prl.update_guest_tools = false/)
|
39
|
-
|
40
|
-
expect( match ).to_not be nil
|
33
|
+
context 'disabled guest tools' do
|
34
|
+
let(:options) { super().merge({ :prl_update_guest_tools => 'disable' }) }
|
35
|
+
subject { vagrant.class.provider_vfile_section( hosts.first, options ) }
|
41
36
|
|
37
|
+
it "can disable the auto-update functionality of the Parallels Guest Tools" do
|
38
|
+
is_expected.to match(/prl.update_guest_tools = false/)
|
39
|
+
end
|
42
40
|
end
|
43
|
-
|
44
41
|
end
|
@@ -29,17 +29,15 @@ module Beaker
|
|
29
29
|
})
|
30
30
|
end
|
31
31
|
|
32
|
-
it "stores the vagrant file in $WORKINGDIR/.vagrant/beaker_vagrant_files/
|
33
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
32
|
+
it "stores the vagrant file in $WORKINGDIR/.vagrant/beaker_vagrant_files/beaker_sample.cfg" do
|
34
33
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
35
34
|
|
36
|
-
expect( path ).to be === File.join(Dir.pwd, '.vagrant', 'beaker_vagrant_files', '
|
35
|
+
expect( path ).to be === File.join(Dir.pwd, '.vagrant', 'beaker_vagrant_files', 'beaker_sample.cfg')
|
37
36
|
|
38
37
|
end
|
39
38
|
|
40
39
|
it "can make a Vagrantfile for a set of hosts" do
|
41
40
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
42
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
43
41
|
|
44
42
|
vagrant.make_vfile( @hosts )
|
45
43
|
|
@@ -53,7 +51,7 @@ Vagrant.configure("2") do |c|
|
|
53
51
|
v.vm.box = 'vm2vm1_of_my_box'
|
54
52
|
v.vm.box_url = 'http://address.for.my.box.vm1'
|
55
53
|
v.vm.box_check_update = 'true'
|
56
|
-
v.vm.network :private_network, ip: "ip.address.for.vm1", :netmask => "255.255.0.0"
|
54
|
+
v.vm.network :private_network, ip: "ip.address.for.vm1", :netmask => "255.255.0.0"
|
57
55
|
v.vm.synced_folder './', '/temp', create: true
|
58
56
|
v.vm.synced_folder '../', '/tmp', create: true
|
59
57
|
v.vm.network :forwarded_port, guest: 80, host: 10080
|
@@ -68,7 +66,7 @@ Vagrant.configure("2") do |c|
|
|
68
66
|
v.vm.box = 'vm2vm2_of_my_box'
|
69
67
|
v.vm.box_url = 'http://address.for.my.box.vm2'
|
70
68
|
v.vm.box_check_update = 'true'
|
71
|
-
v.vm.network :private_network, ip: "ip.address.for.vm2", :netmask => "255.255.0.0"
|
69
|
+
v.vm.network :private_network, ip: "ip.address.for.vm2", :netmask => "255.255.0.0"
|
72
70
|
v.vm.synced_folder './', '/temp', create: true
|
73
71
|
v.vm.synced_folder '../', '/tmp', create: true
|
74
72
|
v.vm.network :forwarded_port, guest: 80, host: 10080
|
@@ -83,7 +81,7 @@ Vagrant.configure("2") do |c|
|
|
83
81
|
v.vm.box = 'vm2vm3_of_my_box'
|
84
82
|
v.vm.box_url = 'http://address.for.my.box.vm3'
|
85
83
|
v.vm.box_check_update = 'true'
|
86
|
-
v.vm.network :private_network, ip: "ip.address.for.vm3", :netmask => "255.255.0.0"
|
84
|
+
v.vm.network :private_network, ip: "ip.address.for.vm3", :netmask => "255.255.0.0"
|
87
85
|
v.vm.synced_folder './', '/temp', create: true
|
88
86
|
v.vm.synced_folder '../', '/tmp', create: true
|
89
87
|
v.vm.network :forwarded_port, guest: 80, host: 10080
|
@@ -99,7 +97,6 @@ EOF
|
|
99
97
|
|
100
98
|
it "can make a Vagrantfile with ssh agent forwarding enabled" do
|
101
99
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
102
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
103
100
|
|
104
101
|
hosts = make_hosts({},1)
|
105
102
|
vagrant.make_vfile( hosts, options )
|
@@ -110,7 +107,6 @@ EOF
|
|
110
107
|
|
111
108
|
it "can replace underscores in host.name with hypens" do
|
112
109
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
113
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
114
110
|
|
115
111
|
host = make_host( 'name-with_underscore', {} )
|
116
112
|
vagrant.make_vfile( [host,], options )
|
@@ -122,7 +118,6 @@ EOF
|
|
122
118
|
|
123
119
|
it "can make a Vagrantfile with synced_folder disabled" do
|
124
120
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
125
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
126
121
|
|
127
122
|
hosts = make_hosts({:synced_folder => 'disabled'},1)
|
128
123
|
vagrant.make_vfile( hosts, options )
|
@@ -131,16 +126,6 @@ EOF
|
|
131
126
|
expect( vagrantfile ).to match(/v.vm.synced_folder .* disabled: true/)
|
132
127
|
end
|
133
128
|
|
134
|
-
it "can make a Vagrantfile with network mac autogenerated" do
|
135
|
-
path = vagrant.instance_variable_get( :@vagrant_path )
|
136
|
-
|
137
|
-
hosts = make_hosts({},1)
|
138
|
-
vagrant.make_vfile( hosts, options )
|
139
|
-
|
140
|
-
vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
|
141
|
-
expect( vagrantfile ).to match(/v.vm.network :private_network, ip: "ip.address.for.vm1", :netmask => "255.255.0.0", :mac => ".+/)
|
142
|
-
end
|
143
|
-
|
144
129
|
it "can make a Vagrantfile with network mac specified" do
|
145
130
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
146
131
|
|
@@ -151,16 +136,6 @@ EOF
|
|
151
136
|
expect( vagrantfile ).to match(/v.vm.network :private_network, ip: "ip.address.for.vm1", :netmask => "255.255.0.0", :mac => "b6:33:ae:19:48:f9/)
|
152
137
|
end
|
153
138
|
|
154
|
-
it "can make a Vagrantfile with network mac disabled" do
|
155
|
-
path = vagrant.instance_variable_get( :@vagrant_path )
|
156
|
-
|
157
|
-
hosts = make_hosts({:network_mac => 'false'},1)
|
158
|
-
vagrant.make_vfile( hosts, options )
|
159
|
-
|
160
|
-
vagrantfile = File.read( File.expand_path( File.join( path, "Vagrantfile")))
|
161
|
-
expect( vagrantfile ).to match(/v.vm.network :private_network, ip: "ip.address.for.vm1", :netmask => "255.255.0.0"/)
|
162
|
-
end
|
163
|
-
|
164
139
|
it "can make a Vagrantfile with improper keys for synced folders" do
|
165
140
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
166
141
|
|
@@ -182,7 +157,6 @@ EOF
|
|
182
157
|
|
183
158
|
it "can make a Vagrantfile with optional shell provisioner" do
|
184
159
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
185
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
186
160
|
|
187
161
|
shell_path = '/path/to/shell/script'
|
188
162
|
hosts = make_hosts({
|
@@ -198,7 +172,6 @@ EOF
|
|
198
172
|
|
199
173
|
it "can make a Vagrantfile with optional shell provisioner with args" do
|
200
174
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
201
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
202
175
|
|
203
176
|
shell_path = '/path/to/shell/script.sh'
|
204
177
|
shell_args = 'arg1 arg2'
|
@@ -216,7 +189,6 @@ EOF
|
|
216
189
|
|
217
190
|
it "raises an error if path is not set on shell_provisioner" do
|
218
191
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
219
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
220
192
|
|
221
193
|
hosts = make_hosts({:shell_provisioner => {}}, 1)
|
222
194
|
expect{ vagrant.make_vfile( hosts, options ) }.to raise_error RuntimeError, /No path defined for shell_provisioner or path empty/
|
@@ -224,7 +196,6 @@ EOF
|
|
224
196
|
|
225
197
|
it "raises an error if path is EMPTY on shell_provisioner" do
|
226
198
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
227
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
228
199
|
|
229
200
|
empty_shell_path = ''
|
230
201
|
hosts = make_hosts({
|
@@ -238,7 +209,6 @@ EOF
|
|
238
209
|
context "when generating a windows config" do
|
239
210
|
before do
|
240
211
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
241
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
242
212
|
@hosts[0][:platform] = 'windows'
|
243
213
|
|
244
214
|
vagrant.make_vfile( @hosts )
|
@@ -270,7 +240,6 @@ EOF
|
|
270
240
|
context 'when generating a freebsd config' do
|
271
241
|
before do
|
272
242
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
273
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
274
243
|
@hosts[0][:platform] = 'freebsd'
|
275
244
|
|
276
245
|
vagrant.make_vfile( @hosts )
|
@@ -285,15 +254,10 @@ EOF
|
|
285
254
|
it 'has the proper guest setting' do
|
286
255
|
expect( @generated_file ).to match /v.vm.guest = :freebsd\n/
|
287
256
|
end
|
288
|
-
|
289
|
-
it 'sets the vm.base_mac setting' do
|
290
|
-
expect( @generated_file ).to match /v.vm.base_mac = '0123456789'\n/
|
291
|
-
end
|
292
257
|
end
|
293
258
|
|
294
259
|
it "uses the memsize defined per vagrant host" do
|
295
260
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
296
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
297
261
|
|
298
262
|
vagrant.make_vfile( @hosts, {'vagrant_memsize' => 'hello!'} )
|
299
263
|
|
@@ -307,7 +271,6 @@ EOF
|
|
307
271
|
|
308
272
|
it "uses the cpus defined per vagrant host" do
|
309
273
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
310
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
311
274
|
|
312
275
|
vagrant.make_vfile( @hosts, {'vagrant_cpus' => 'goodbye!'} )
|
313
276
|
|
@@ -322,7 +285,6 @@ EOF
|
|
322
285
|
context "port forwarding rules" do
|
323
286
|
it "supports all Vagrant parameters" do
|
324
287
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
325
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
326
288
|
|
327
289
|
hosts = make_hosts(
|
328
290
|
{
|
@@ -344,7 +306,6 @@ EOF
|
|
344
306
|
|
345
307
|
it "supports supports from_ip" do
|
346
308
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
347
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
348
309
|
|
349
310
|
hosts = make_hosts(
|
350
311
|
{
|
@@ -364,7 +325,6 @@ EOF
|
|
364
325
|
|
365
326
|
it "supports all to_ip" do
|
366
327
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
367
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
368
328
|
|
369
329
|
hosts = make_hosts(
|
370
330
|
{
|
@@ -384,7 +344,6 @@ EOF
|
|
384
344
|
|
385
345
|
it "supports all protocol" do
|
386
346
|
path = vagrant.instance_variable_get( :@vagrant_path )
|
387
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
388
347
|
|
389
348
|
hosts = make_hosts(
|
390
349
|
{
|
@@ -451,55 +410,57 @@ EOF
|
|
451
410
|
end
|
452
411
|
|
453
412
|
describe "set_ssh_config" do
|
454
|
-
let( :out )
|
413
|
+
let( :out ) do
|
414
|
+
<<-CONFIG
|
415
|
+
Host #{name}
|
416
|
+
HostName 127.0.0.1
|
417
|
+
User vagrant
|
418
|
+
Port 2222
|
419
|
+
UserKnownHostsFile /dev/null
|
420
|
+
StrictHostKeyChecking no
|
421
|
+
PasswordAuthentication no
|
422
|
+
IdentityFile /home/root/.vagrant.d/insecure_private_key
|
423
|
+
IdentitiesOnly yes
|
424
|
+
CONFIG
|
425
|
+
end
|
455
426
|
let( :host ) { @hosts[0] }
|
456
427
|
let( :name ) { host.name }
|
457
|
-
let( :
|
428
|
+
let( :override_options ) { {} }
|
458
429
|
|
459
430
|
before :each do
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
431
|
+
# FakeFS is just broken with Tempfile
|
432
|
+
FakeFS.deactivate!
|
433
|
+
Dir.mktmpdir do |dir|
|
434
|
+
vagrant.instance_variable_get(:@options).merge!(override_options)
|
435
|
+
vagrant.instance_variable_set(:@vagrant_path, dir)
|
436
|
+
state = double( 'state' )
|
437
|
+
allow( state ).to receive( :success? ).and_return( true )
|
438
|
+
allow( Open3 ).to receive( :capture3 ).with( {"RUBYLIB"=>"", "RUBYOPT"=>""}, 'vagrant', 'ssh-config', name ).and_return( [ out, "", state ])
|
467
439
|
|
468
|
-
|
469
|
-
|
440
|
+
vagrant.set_ssh_config( host, 'root' )
|
441
|
+
end
|
442
|
+
end
|
470
443
|
|
471
|
-
|
472
|
-
|
473
|
-
User vagrant
|
474
|
-
Port 2222
|
475
|
-
UserKnownHostsFile /dev/null
|
476
|
-
StrictHostKeyChecking no
|
477
|
-
PasswordAuthentication no
|
478
|
-
IdentityFile /home/root/.vagrant.d/insecure_private_key
|
479
|
-
IdentitiesOnly yes")
|
444
|
+
it 'sets the user to root' do
|
445
|
+
expect(host['user']).to be === 'root'
|
480
446
|
end
|
481
447
|
|
482
|
-
it
|
483
|
-
|
484
|
-
|
448
|
+
it 'sets the ssh user to root' do
|
449
|
+
expect(host['ssh']['user']).to be === 'root'
|
450
|
+
end
|
485
451
|
|
486
|
-
|
487
|
-
|
488
|
-
expect(
|
452
|
+
# This is because forward_ssh_agent is true by default
|
453
|
+
it 'sets IdentitiesOnly to no' do
|
454
|
+
expect(host['ssh'][:keys_only]).to be === false
|
489
455
|
end
|
490
456
|
|
491
457
|
context "when :forward_ssh_agent is false" do
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
options = vagrant.instance_variable_set( :@options, options )
|
496
|
-
|
497
|
-
expect( Tempfile ).to receive( :new ).with( "#{host.name}").and_return( file )
|
498
|
-
expect( file ).to receive( :write ).with("Host ip.address.for.#{name}\n HostName 127.0.0.1\n User root\n Port 2222\n UserKnownHostsFile /dev/null\n StrictHostKeyChecking no\n PasswordAuthentication no\n IdentityFile /home/root/.vagrant.d/insecure_private_key\n IdentitiesOnly yes")
|
458
|
+
let(:override_options) do
|
459
|
+
{forward_ssh_agent: false}
|
460
|
+
end
|
499
461
|
|
500
|
-
|
501
|
-
expect( host['ssh']
|
502
|
-
expect( host['user']).to be === 'root'
|
462
|
+
it "should keep IdentitiesOnly to yes" do
|
463
|
+
expect( host['ssh'][:keys_only]).to be === true
|
503
464
|
end
|
504
465
|
end
|
505
466
|
end
|
@@ -513,17 +474,6 @@ EOF
|
|
513
474
|
end
|
514
475
|
end
|
515
476
|
|
516
|
-
it 'calls #get_ip_from_vagrant_file' do
|
517
|
-
vagrant.make_vfile(@hosts)
|
518
|
-
|
519
|
-
@hosts.each do |host|
|
520
|
-
allow(vagrant).to receive(:set_ssh_config).with(host, anything)
|
521
|
-
expect(vagrant).to receive(:get_ip_from_vagrant_file).with(host.name)
|
522
|
-
end
|
523
|
-
|
524
|
-
vagrant.configure
|
525
|
-
end
|
526
|
-
|
527
477
|
it 'calls #set_all_ssh_config' do
|
528
478
|
vagrant.make_vfile(@hosts)
|
529
479
|
expect(vagrant).to receive(:set_all_ssh_config)
|
@@ -567,31 +517,6 @@ EOF
|
|
567
517
|
end
|
568
518
|
end
|
569
519
|
|
570
|
-
describe "get_ip_from_vagrant_file" do
|
571
|
-
before :each do
|
572
|
-
allow( vagrant ).to receive( :randmac ).and_return( "0123456789" )
|
573
|
-
vagrant.make_vfile( @hosts )
|
574
|
-
end
|
575
|
-
|
576
|
-
it "can find the correct ip for the provided hostname" do
|
577
|
-
@hosts.each do |host|
|
578
|
-
expect( vagrant.get_ip_from_vagrant_file(host.name) ).to be === host[:ip]
|
579
|
-
end
|
580
|
-
|
581
|
-
end
|
582
|
-
|
583
|
-
it "returns nil if it is unable to find an ip" do
|
584
|
-
expect( vagrant.get_ip_from_vagrant_file("unknown") ).to be_nil
|
585
|
-
end
|
586
|
-
|
587
|
-
it "raises an error if no Vagrantfile is present" do
|
588
|
-
File.delete( vagrant.instance_variable_get( :@vagrant_file ) )
|
589
|
-
@hosts.each do |host|
|
590
|
-
expect{ vagrant.get_ip_from_vagrant_file(host.name) }.to raise_error RuntimeError, /No vagrant file found/
|
591
|
-
end
|
592
|
-
end
|
593
|
-
end
|
594
|
-
|
595
520
|
describe "provisioning and cleanup" do
|
596
521
|
|
597
522
|
before :each do
|