Skip to content

Commit 42786e5

Browse files
authored
chore(vagrant): enhancing windows vagrant experience (#1364)
1. Pin vagrant to known working version 2. Automatically pass CI environment variables to the guest 3. Add a bit of vram so that the virtualbox window can be resized GROW-2396
1 parent b4c7726 commit 42786e5

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

cli/vagrant/windows-10/Vagrantfile

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,50 @@
1+
# powershell does not accept empty string arguments with any sort of grace
2+
#
3+
# for instance:
4+
# powershell -ExecutionPolicy Bypass -OutputFormat Text -file "C:\tmp\vagrant-shell.ps1" "dev7.dev7.corp" "" "" "_1234"
5+
#
6+
# results in CI_API_TOKEN being interpreted as CI_API_KEY since the middle empty strings are ignored
7+
# we will use `@@empty@@` as a placeholder which will be respected by provision.ps1 when setting environment variables
8+
lw_account = ENV['CI_ACCOUNT']
9+
if lw_account == nil
10+
lw_account = "@@empty@@"
11+
end
12+
13+
lw_api_key = ENV['CI_API_KEY']
14+
if lw_api_key == nil
15+
lw_api_key = "@@empty@@"
16+
end
17+
18+
lw_api_secret = ENV['CI_API_SECRET']
19+
if lw_api_secret == nil
20+
lw_api_secret = "@@empty@@"
21+
end
22+
23+
lw_api_token = ENV['CI_API_TOKEN']
24+
if lw_api_token == nil
25+
lw_api_token = "@@empty@@"
26+
end
27+
28+
# 2.3.7 was giving all sorts of grief communicating via WinRM; specifically
29+
# Message: Digest initialization failed: initialization error
30+
Vagrant.require_version "<= 2.3.6"
31+
132
Vagrant.configure("2") do |config|
33+
config.vm.communicator = "winrm"
34+
235
config.vm.box = "senglin/win-10-enterprise-vs2015community"
336
config.vm.box_version = "1.0.0"
37+
438
config.vm.synced_folder "../../../bin", "/devcli"
5-
config.vm.provision "shell",
6-
inline: "New-Item -ItemType SymbolicLink -Target \"C:/devcli/lacework-cli-windows-amd64.exe\" -Path \"C:/Users/vagrant/lacework.exe\""
739

840
config.vm.provider "virtualbox" do |v|
941
v.gui = true
42+
v.cpus = 2
43+
v.memory = 1024
44+
# Enables or disables the use of hardware virtualization extensions in the processor of the host system.
45+
v.customize ["modifyvm", :id, "--hwvirtex", "on"]
46+
# Specifies the amount of RAM to allocate to the virtual graphics card.
47+
v.customize ["modifyvm", :id, "--vram", "256"]
1048
end
49+
config.vm.provision "shell", path: "provision.ps1", args: [lw_account, lw_api_key, lw_api_secret, lw_api_token]
1150
end
12-
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
New-Item -ItemType SymbolicLink -Target "C:\devcli\lacework-cli-windows-amd64.exe" -Path "C:\Users\vagrant\lacework.exe"
2+
3+
# add LW_ environment variables
4+
$empty = '@@empty@@'
5+
if ( $args[0] -ne $empty )
6+
{
7+
[System.Environment]::SetEnvironmentVariable('LW_ACCOUNT', $args[0], [System.EnvironmentVariableTarget]::Machine)
8+
}
9+
if ( $args[1] -ne $empty )
10+
{
11+
[System.Environment]::SetEnvironmentVariable('LW_API_KEY', $args[1], [System.EnvironmentVariableTarget]::Machine)
12+
}
13+
if ( $args[2] -ne $empty )
14+
{
15+
[System.Environment]::SetEnvironmentVariable('LW_API_SECRET', $args[2], [System.EnvironmentVariableTarget]::Machine)
16+
}
17+
if ( $args[3] -ne $empty )
18+
{
19+
[System.Environment]::SetEnvironmentVariable('LW_API_TOKEN', $args[3], [System.EnvironmentVariableTarget]::Machine)
20+
}

0 commit comments

Comments
 (0)