DevOps Yourself:

Fast-Track Your
Windows Develop
Environment Setup

Justin James

@digitaldrummerj

 

Hours

 

Later

 

....

 

 

+

+

+

=

+

+

What is the package manager you speak of?

  • Multiple clicks to get anywhere

  • Deja vu - sense of installing same software

  • Aarg! should have got 64 bit version

  • Darn it, installed it to directory with a space

  • etc

  • etc

Problems Solved

Finding Applications

Finding Applications

Finding Applications

  • Use Boxstarter Chocolatey package

    • choco install boxstarter

Bulk Install Packages

Installing Software

Install Chocolatey

http://chocolatey.org/

iex
(
    (new-object net.webclient).DownloadString
    (
        'https://chocolatey.org/install.ps1'
    )
)

Install Virtualbox

choco install virtualbox.extensionpack

Install Vagrant

choco install vagrant

Getting Start

With Vagrant 

Boxes

 

portable 

skeletons 

for building

Virtual Machines

 

  1. Pre-Built:

    • Everything pre-installed 
       

  2. Base OS Box:

    • Only OS is pre-installed

    • Install software as part of provisioning

2 Options for Boxes

Creating Vagrant Machine

Create VagrantFile

vagrant init [box name]

vagrant init opentable/win-8.1-enterprise-amd64-nocm

Configure VagrantFile

Vagrant.configure(2) do |config|
     config.vm.box = "opentable/win-8.1-enterprise-amd64-nocm"
     config.vm.hostname = "NDCTestMachine"
     config.vm.boot_timeout = 600
     config.vm.communicator = "winrm"

    ....Virtualbox Config

    ....Provisioning
end

Configure Virtual Box

Vagrant.configure(2) do |config|
    .....

    config.vm.provider "virtualbox" do |vb|
          vb.gui = true
          vb.memory = "8192"
          vb.cpus = 2
          vb.name = "Ndc Test Machine"   

          vb.customize ["modifyvm", :id, "--vram", "128"]
          vb.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
     end

    ...Provisioning
end

Configure Provisioning 

Vagrant.configure(2) do |config|
    .....

    config.vm.provision :shell, 
          path: "shell/main.cmd" 
    
    config.vm.provision :shell,
          path: "shell/InstallBoxStarter.bat"  
    
    config.vm.provision "file",
           source: "shell/RunBoxStarterGist.bat",
           destination: "desktop\\RunBoxStarterGist.bat"     

end

Configure Provisioning 

Vagrant.configure(2) do |config|
    .....
    config.vm.provision :shell, 
          path: "shell/main.cmd" 

       config.vm.provision :shell,
          path: "shell/InstallBoxStarter.bat"  

 

    config.vm.provision "file",
           source: "shell/RunBoxStarterGist.bat",
           destination: "desktop\\RunBoxStarterGist.bat"     

end

main.cmd


@powershell -NoProfile -ExecutionPolicy Bypass -File 
    "%systemdrive%\vagrant\shell\RemoveDefaultPrograms.ps1"

@powershell -NoProfile -ExecutionPolicy Bypass -File 
    "%systemdrive%\vagrant\shell\InstallChocolatey.ps1"

Configure Provisioning 

   
    config.vm.provision :shell,
          path: "shell/InstallBoxStarter.bat"  

Vagrant.configure(2) do |config|
    .....

    config.vm.provision :shell, 
          path: "shell/main.cmd" 

    config.vm.provision "file",
           source: "shell/RunBoxStarterGist.bat",
           destination: "desktop\\RunBoxStarterGist.bat"     

end

InstallBoxStarter.bat

chocolatey feature enable -n=allowGlobalConfirmation

choco install BoxStarter

chocolatey feature disable -n=allowGlobalConfirmatio

Configure Provisioning 

    config.vm.provision "file",
           source: "shell/RunBoxStarterGist.bat",
           destination: "desktop\\RunBoxStarterGist.bat"     
end

Vagrant.configure(2) do |config|
    .....

    config.vm.provision :shell, 
          path: "shell/main.cmd" 

   config.vm.provision :shell,
          path: "shell/InstallBoxStarter.bat"  

RunBoxStarterGist.bat

copy 
    "%systemdrive%\vagrant\shell\BoxStarterGist.txt" 
    "%temp%\BoxStarterGist.txt"

@powershell 
    -NoProfile -ExecutionPolicy Bypass 
    -Command "Install-BoxStarterPackage 
        -PackageName %temp%\\BoxstarterGist.txt"

Gist File - Windows Config

Enable-RemoteDesktop

Set-CornerNavigationOptions -EnableUsePowerShellOnWinX

Set-ExplorerOptions 
    -EnableShowHiddenFilesFoldersDrives 
    -EnableShowProtectedOSFiles 
    -EnableShowFileExtensions 
    -EnableShowFullPathInTitlebar

Set-TaskbarOptions -Size Small -Lock

Gist File - Chocolatey

chocolatey feature enable -n=allowGlobalConfirmation

choco install git 
choco install nodejs 
choco install visualstudiocode 
choco install GoogleChrome 
.....

chocolatey feature disable -n=allowGlobalConfirmation

Gist File - Npm/Taskbar 

Install-ChocolateyPinnedTaskBarItem 
    "${env:UserProfile}\Desktop\code.lnk"

Install-ChocolateyPinnedTaskBarItem 
    "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe"

Gist File - Npm/Taskbar 

npm config set loglevel http
npm config set spin false

npm install -g ionic
npm install -g cordova

Gist File - Code Config

$vsCodeDir = "${env:appdata}\Code"

If ((Test-Path $vsCodeDir)) {
	cp "${env:temp}\VisualStudioCode_keybinding.json" 
            "$vsCodeDir\keybinding.json"
	
	cp "${env:temp}\VisualStudioCode_UserSettings.json" 
            "$vsCodeDir\usersettings.json"
}
else {  
   Write-Host "Error: Visual Studio Code Directory, $vsCodeDir is missing"
}

Gist File - Git Clone


$projectDir = "${env:systemdrive}\projects"

If (!(Test-Path $projectDir)) {
	New-Item -Path $projectDir -ItemType Directory
}

cd $projectDir

git clone ....

Control Virtual Machine

Useful Vagrant Commands

Start Up Box

vagrant up

Login into Box

vagrant rdp

vagrant reload

Need to Reboot?

vagrant halt

Need to Shutdown?

vagrant suspend

Need to Hibernate?

vagrant destroy

Done with Project?

vagrant up

Need to Box Again?

Build & Share

Your Own Box

Easiest way

 

build out machine

 

then

 

package it

Packaging VirtualBox Machine

 

Setup Windows Remote Management (WinRM)

http://tinyurl.com/winrmconfig

 

vagrant package --base NAME --output NAME

 

Adding Box

 

vagrant box add [NAME]

 

Wrap up

  1. Install Chocolatey

  2. Install Virtualbox

  3. Install Vagrant

  4. Install Git 

  5. Clone github repo with Vagrant File

  6. Vagrant Up

New Initial Instructions

  1. Clone github repo with Vagrant File

  2. Vagrant Up

New Create Instructions

  • Azure 

  • Modern.IE 

  • Replicate production environments

  • Any Windows or Linux OS

Other uses for Vagrant

Resources

VirtualBox - http://www.virtualbox.org

 

Vagrant Website - http://www.vagrantup.com

 

Vagrant Boxes - https://atlas.hashicorp.com/boxes/search

 

Chocolatey - https://chocolatey.org/

 

BoxStarter -  https://boxstarter.org/

thank you

i'm Justin.

 

@digitaldrummerj - digitaldrummerj@gmail.com

http://digitaldrummerj.me

1 480 360 4335

DevOps Yourself: Fast Track Your Windows Dev Box Setup

By Justin James

DevOps Yourself: Fast Track Your Windows Dev Box Setup

Learn how to get rid of the it works on my machine. Toss the setup manual out the window and learn how to create reproducible setups.

  • 5,464