HELP on configuration for a Vagrant server

73 views
Skip to first unread message

Vito Amoroso

unread,
Feb 9, 2016, 11:31:32 AM2/9/16
to Vagrant
Hi guys,

this is the first time for me on a Google group, I'm a system engineer and I write here to ask for some help for a Server configuration. I work for a company in which pre-production server are inexistent, so I'm trying to find an useful solution for different devs groups.

I'm working on Vagrant from some days and I think to be at good point with the following configuration:

- 1 Powerful WinSrv 2012 R2 with last Virtualbox and Vagrant release installed
- Correctly packaged a personal WinSrv2012R2 box ( with correct winrm configuration ) that will be useful for different countries devs ( Spain, France... )
- Vagrant file like this:
__________________________________
Vagrant.configure(2) do |config|


  config.vm.box = "WindowsSrv2012R2-from-DEVVGRITA"
  config.vm.communicator = "winrm"
  config.vm.boot_timeout = 600
  config.vm.guest = :windows
  config.winrm.username = "vagrant"
  config.winrm.password = "vagrant"
  config.windows.set_work_network = true
  
  config.vm.define "devTurkey" do |dev1|
    dev1.vm.network "public_network", bridge: "vmxnet3 Ethernet Adapter", ip: "192.168.79.54"
    dev1.vm.host_name = "devTurkey"
    dev1.vm.network "forwarded_port", guest: 5985, host: 5985, id: "winrm", auto_correct: true
  end
  
  config.vm.define "devPortugal" do |dev2|
    dev2.vm.network "public_network", bridge: "vmxnet3 Ethernet Adapter", ip: "192.168.79.55"
    dev2.vm.host_name = "devPortugal"
    dev2.vm.network "forwarded_port", guest: 5985, host: 5985, id: "winrm", auto_correct: true
  end
  
    config.vm.provider "virtualbox" do |vb|
        vb.gui = true
        vb.customize ["modifyvm", :id, "--memory", 4096]
        vb.customize ["modifyvm", :id, "--cpus", 4]
        vb.customize ["modifyvm", :id, "--vram", 64]
        vb.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
  end
  
  config.vm.provision "shell" do |s|
    s.path = "set-defaultgateway.ps1"
  end
end
__________________________________________

- The machines starts correctly, IP addr configured and powershell script correctly executed.


So, seems al ok...but...what's my problem???

When I enter with my account domain in the host server I can bring up these machines, but If I logout the server ( not disconnect ) or If I leave my work in the evening, the next days the machines are down, and I don't want this.

I thought about 2 workarounds:

1) Use Hyper-V, It's fantastic because It works like a service BUT It's really impossible to configure two network interfaces, and I need them
2) I thought about the possibility to start remotely the vagrant guest with the following script im Powershell:
_______________________________
Set-ExecutionPolicy bypass

$computer = "devvgrita.domain.it"
$securepw = ConvertTo-SecureString ********* -asplaintext -force
$cred = new-object -typename System.Management.Automation.PSCredential -argument user, $securepw

Enable-WSManCredSSP -Role Client -DelegateComputer *.domain.it -force

$allowed = @('WSMAN/*')

$key = 'hklm:\SOFTWARE\Policies\Microsoft\Windows\CredentialsDelegation'
if (!(Test-Path $key))
{
md $key
}
New-ItemProperty -Path $key -Name AllowFreshCredentialsWhenNTLMOnly -Value 1 -PropertyType Dword -Force
New-ItemProperty -Path $key -Name ConcatenateDefaults_AllowFreshNTLMOnly -Value 1 -PropertyType Dword -Force

$key = Join-Path $key 'AllowFreshCredentialsWhenNTLMOnly'
if (!(Test-Path $key))
{
md $key
}
$i = 1
$allowed | % {
# Script does not take into account existing entries in this key
New-ItemProperty -Path $key -Name $i -Value $_ -PropertyType String -Force
$i++
}


$session = New-PSSession -credential $cred -ComputerName $computer -Authentication Credssp
invoke-command -Session $session -ScriptBlock { cd c:\; vagrant up devTurkey }
________________________________

The second works but I totally lose control of the guest machine, when the script finish I cannot manage It with VBoxManage or via Vagrant, I cannot find the machine anymore.

I hope that someone can help me for this point, I'm really at the end of the configuration and any help will be appreciated.

V

Alvaro Miranda Aguilera

unread,
Feb 12, 2016, 4:15:52 AM2/12/16
to vagra...@googlegroups.com
Hello,

Couple of hinters, and sorry if these are too obvious.

a. Each windows machine generate a unique system id, when you have the same box more than once, you will get duplicates id, this is fine when you don't have Active Directory.

When you add a box to Active Directory, as similar to having an user account, your box get a machine account, adding a 2nd box with the same id will break the trust with the old one (overwriting it), so the old one won't talk (wont be trusted any more), so in the past you had to change the id of the machine before adding it to AD.

For VM, it was usually that you could run a sysprep and tell the tool to shutdown the box, so on next run it will generate a random id

Not sure if this is the current way, but it used to be sysprep:


b. have you check the power profile? it may be going to sleep (the VM) or hybernate, etc.

You can configure the console/gui and check later what's the status of the console gui.

Any questions, please let me know.

Alvaro.


Reply all
Reply to author
Forward
0 new messages