Last active
September 10, 2019 16:16
-
-
Save pimentelra/6eb55ff1fd773fa85ca3d969443f6570 to your computer and use it in GitHub Desktop.
Set UseDNS to no on RedHat machine to prevent hanging on "vagrant up" and auto extend Windows trial
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
config.trigger.before :up do |trigger| | |
trigger.ruby do |env, machine| | |
if machine.name.to_s == app1 | |
trigger.info = "Disabling DNS reverse lookup in SSHD." | |
if Vagrant::Util::Platform.windows? | |
pid = spawn("ping -n 61 127.0.0.1 > nul && for /F \"tokens=1,2 delims= \" %i in ('\"VBoxManage list runningvms | findstr /R /C:\"#{machine.name}\"\"') do VBoxManage --nologo guestcontrol %j --username root --password vagrant start --exe \"/usr/bin/sh\" -- sh/arg0 -c \"/usr/bin/sed -ie 's/\\(#\\)\\{0,1\\}UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config && /usr/bin/systemctl restart sshd\" --wait-stdout\" ") | |
else | |
pid = spawn("sleep 30 && VBoxManage --nologo guestcontrol $(VBoxManage list runningvms | grep \"#{machine.name}\" | cut -d \" \" -f 2) --username root --password vagrant start --exe \"/usr/bin/sh\" -- sh/arg0 -c \"/usr/bin/sed -ie 's/\\(#\\)\\{0,1\\}UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config && /usr/bin/systemctl restart sshd\" --wait-stdout ") | |
end | |
puts "UseDNS=no and SSHD daemon restarted with pid #{pid.to_s}." | |
end | |
end | |
end | |
config.trigger.after :up do |trigger| | |
trigger.ruby do |env, machine| | |
if machine.name.to_s == db1 | |
trigger.info = "Rearming Windows machine." | |
pid = spawn("VBoxManage --nologo guestcontrol #{machine.id} --username Administrator --password vagrant start --exe \"cscript.exe\" -- cscript.exe/arg0 \"\"slmgr.vbs /rearm\"\" ") | |
puts "Machine rearmed with pid #{pid.to_s}." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment