vagrant init Win2012R2x64The parameter specifies the name of the box that we want to expand here. In principle, it can always be corrected later. As a result of the command execution, a file is created in the directory with the straightforward name Vagrantfile, in which the minimum parameters of the lifted machine are specified in the Ruby language: provider (hypervisor), OS type, and box name. Basically, I prefer to just copy the finished file, rather than edit the template. A description of all the parameters can be found in the documentation, I will only give my example with working provisioning (the listing is available on Gist ):
# - , . . # -*- mode: ruby -*- # vi: set ft=ruby : # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # config.vm, . # config.vm.box = "Win2012R2x64" # , windows config.vm.guest = :windows # , Vagrant . , , Hyper-V. - “default”. config.vm.define :godnota # . SSH, - WinRM config.vm.communicator = "winrm" # . Chef, . , , Vagrantfile. , -, - (, \\\\server\\DevOps\\Vagrant\\provision.ps1), . config.vm.provision "shell", path: "provision.ps1" # , , Vagrant . , 5, sysprep, config.vm.boot_timeout = 300 # , , config.vm.graceful_halt_timeout = 180 # Vagrant ( SMB) . , Windows ( Ubuntu hashicorp/precise64 ), config.vm.synced_folder ".", "/vagrant", disabled: true # Hyper-V. , , , . config.vm.provider "hyperv" do |hv| hv.ip_address_timeout = 300 end # - , . , ( ). config.winrm.username = "Administrator" config.winrm.password = "P@$$word" end
# Chocolatey . , , . , , iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1')) # Boxstarter cinst boxstarter $env:Path+=";"+$env:AppData+"\Boxstarter" $env:PSModulePath+=";"+$env:APPDATA+"\Boxstarter" Import-Module Boxstarter.Chocolatey $Boxstarter.AutoLogin=$true # Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions # RDP Enable-RemoteDesktop # Far 7-zip choco install far,7zip -y # Classic Shell, Start choco install classic-shell -installArgs ADDLOCAL=ClassicStartMenu -y # del C:\Users\Administrator\Desktop\*.lnk # Install-WindowsUpdate -AcceptEula -SuppressReboots Restart-Computer
# Determine boot device Switch ((Select-Xml -xml $vmconfig -XPath "//boot").node.device0."#text") { "Floppy" { $bootdevice = "floppy" } "HardDrive" { $bootdevice = "VHD" } "Optical" { $bootdevice = "CD" } "Network" { $bootdevice = "LegacyNetworkAdapter" } "Default" { $bootdevice = "VHD" } } #switch
if ($generation -eq 2) { $hddd = Get-VMHardDiskDrive $vm_name Set-VMFirmware $vm_name -BootOrder $hddd }
Cannot add 'disk.vhdx'. The disk is already connected to the virtual machine 'Windows2012R2x64' '. (Virtual machine ID 35449990-E3D2-4BE1-99E5-2CAACC537097).This is a known issue . So far I have not been able to defeat her in a hurry, so I will be glad if someone tells you how to overcome it. Otherwise, it remains to wait until the developers correct it.
vagrant up mwrock / Windows2012R2 --provider hyperv
Source: https://habr.com/ru/post/252645/
All Articles