Skip to content

Instantly share code, notes, and snippets.

@aidygus
Created October 25, 2016 09:01
Show Gist options
  • Save aidygus/a2f68d8cb484886a11402c6767af97a1 to your computer and use it in GitHub Desktop.
Save aidygus/a2f68d8cb484886a11402c6767af97a1 to your computer and use it in GitHub Desktop.
vagrant file for windows server build with ansible
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.boot_timeout = 500
config.vm.define "sqlserver" do |wb|
wb.vm.communicator = "winrm"
wb.winrm.username = "vagrant"
wb.winrm.password = "vagrant"
wb.vm.box = "2012R2"
wb.vm.hostname = "SQLBOX"
wb.vm.network "private_network", ip: "192.168.34.21", virtualbox__intnet: "intnet"
wb.vm.network "forwarded_port", guest: 65001, host: 65502
wb.vm.provider "vmware_workstation" do |vm|
vm.vmx["memsize"] = 6 * 1024
vm.vmx["numvcpus"] = "2"
vmdir = "#{ENV['HOME']}\\vmware-vagrant-disks"
unless File.directory?( vmdir )
Dir.mkdir vmdir
end
vdiskmanager = "'C:\\Program Files (x86)\\VMware\\VMware Workstation\\vmware-vdiskmanager.exe'"
file_to_disk = "#{vmdir}\\sql_d_drive.vmdk"
unless File.exist?(file_to_disk)
`#{vdiskmanager} -c -t 1 -s 40GB -a lsilogic #{file_to_disk}`
end
vm.vmx['scsi1.filename'] = file_to_disk
vm.vmx['scsi1.present'] = 'TRUE'
vm.vmx['scsi1.redo'] = ''
end
wb.vm.provider "virtualbox" do |vb|
vb.memory = 4 * 1024
vb.cpus = "1"
file_to_disk = 'data/d_drive.vdi'
unless File.exist?(file_to_disk)
vb.customize [
'createhd',
'--filename', file_to_disk,
'--size', 60 * 1024
]
end
vb.customize [
'storageattach', :id,
'--storagectl', 'SAS',
'--port', 1,
'--device', 0,
'--type', 'hdd',
'--medium', file_to_disk
]
end
wb.vm.provision "shell", path: "scripts/setipaddress.ps1", privileged: false
wb.vm.provision "shell", path: "scripts/setupwinrmforansible.ps1", privileged: false
wb.vm.provision "shell", path: "scripts/installchocolatey.ps1", privileged: false
wb.vm.provision "shell", path: "scripts/setupwindowsdisk.ps1", privileged: false
end
config.vm.define "provisioner" do |provisioner|
provisioner.ssh.username = "vagrant"
provisioner.ssh.password = "vagrant"
provisioner.ssh.insert_key = false
provisioner.vm.box = "WCS-Centos7"
provisioner.vm.hostname = "ansible"
provisioner.vm.network "private_network", ip: "192.168.34.20", virtualbox__intnet: "intnet"
provisioner.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
vb.cpus = "1"
end
provisioner.vm.provider "vmware_workstation" do |vm|
vm.vmx["memsize"] = "2048"
vm.vmx["numvcpus"] = "2"
end
provisioner.vm.synced_folder ".", "/vagrant"
provisioner.vm.provision "shell", path: "scripts/setuplinux.sh", privileged: true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment