using Chocolatey for application deployments
-
Upload
owain-perry -
Category
Technology
-
view
4.704 -
download
0
description
Transcript of using Chocolatey for application deployments
![Page 1: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/1.jpg)
CHOCOLATEYSoftware deployments using
![Page 2: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/2.jpg)
Who am i
Owain Perry
Software architect at thetrainline.com
Twitter: owainperryBlog: owainperry.com
![Page 3: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/3.jpg)
What is Chocolatey?
Chocolatey NuGet is a Machine Package Manager, somewhat like apt-get, but built with Windows in mind. - See more at: http://chocolatey.org/#sthash.WI0IhYUd.dpuf
![Page 4: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/4.jpg)
What is a package?
A collection of stuff, glued into one file Msi Self extracting zip exe Zip file Nuget Rpm Etc…
![Page 5: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/5.jpg)
What version is it?
Packages should be versioned? Question: Which is more helpful?
Setup.exe Setup_Notepadpp_1.2.3.4.exe Version.txt inside a zip file.
![Page 6: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/6.jpg)
This is not new
Unix has been doing this for the last 20 years
Windows tried to do this with Msi #fail.
![Page 7: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/7.jpg)
How do we get it there?
What is wrong with this? //installers/files/notepadpp/setup.exe
Share permissions Domain TCP / UDP Ports 135->139 Only works “easily” on windows.
![Page 8: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/8.jpg)
What is installed?
How do we find out what is installed on a machine?
Check the registry (add / remove programs)?
Scan in c:\program files\* C:\program files x86\*
What about stuff installed elsewhere?
![Page 9: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/9.jpg)
How do we replicate?
We have multiple sites – how to replicate?
Use windows file based replication Domain hell if not on one domain
Polled replication every x minutes a pain and slow hard to see current state when is it broken?
![Page 10: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/10.jpg)
Some technology we have been using
Nuget. Zip file containing stuff API for downloading a specific version
via HTTP Wide adoption amongst the .NET
community Written by *Microsoft* Lightweight (single .exe) Large active open source development
community
![Page 11: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/11.jpg)
Artifactory
Multiple repositories Virtual repositories Near real-time replication Simple to browse and search
Thought? - Could use SEMVER and promote packages between repositories (environments)
![Page 12: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/12.jpg)
This can help ops people?
Use the same pattern for installing everything Same command line Single repository of packages easy to
browse Obvious version selection Easy to script Abstract the implementation away – who
cares?
![Page 13: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/13.jpg)
What I want?
Simple and easy to use command line interface
Download via HTTP Download a specific version(s) List packages that have been
installed. Install / upgrade / uninstall options. Simple to create packages using
known language syntax.
![Page 14: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/14.jpg)
Chocolatey
Chocolatey NuGet is a Machine Package Manager, somewhat like apt-get, but built with Windows in mind. - See more at: http://chocolatey.org/#sthash.WI0IhYUd.dpuf
![Page 15: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/15.jpg)
Chocolatey
Nuget packages with extra stuff
Tools/chocolatey-install.ps1
![Page 16: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/16.jpg)
Commands
chocolatey [install [packageName [-source source] [-version version] | pathToPac kagesConfig] | installmissing packageName [-source source] | update
packageName [-source source] [-version version] | list [packageName] [-source source] | hel p | version [packageName] | webpi packageName | windowsfeatures
packageName | ge m packageName [-version version] |uninstall packageName]
example: chocolatey install nunit example: chocolatey install nunit -version 2.5.7.10213 example: chocolatey install packages.config example: chocolatey installmissing nunit example: chocolatey update nunit -source http://somelocalfeed.com/nuget/ example: chocolatey help example: chocolatey list (might take awhile) example: chocolatey list nunit example: chocolatey version example: chocolatey version nunit example: chocolatey uninstall
![Page 17: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/17.jpg)
Commands - shortcuts
Cpack – create a chocolatey package (nuget style)Cpush – push a package Cinst – install Cup – update Clist – list Cuninst – uninstall Cver – display versionCwindowsfeature – add a windows feature
![Page 18: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/18.jpg)
How most chocolatey.org packages work
![Page 19: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/19.jpg)
This is not ideal
Hundreds of machines installing stuff Putting the implementation files into the
package keeps it all in house Provides more control over switches and
install options.
![Page 20: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/20.jpg)
Dependants
Chocolatey like nuget supports pulling down and installing dependants
E.g. getting version 2.1.1.0 of package A to install a package B with version 4.8.0.34
![Page 21: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/21.jpg)
We can build them
![Page 22: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/22.jpg)
What does an install script look like?
It’s just PowerShell. Everything you can do in PowerShell
you have at your finger tips
![Page 23: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/23.jpg)
What does an install script look like?
$packageName = 'notepad++'
$silentArgs = '/S'
$validExitCodes = @(0)
$url = $(Split-Path –parent) $MyInvocation.MyCommand.Definition) + "\..\data\npp.6.3.Installer.exe"
$url64 = $url
Install-ChocolateyPackage $packageName "exe" "$silentArgs" "$url" "$url64" -validExitCodes $validExitCodes
![Page 24: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/24.jpg)
What is a chocolatey package then?
Nuget package with: /tools/chocolateyinstall.ps1 /tools/chocolateyuninstall.ps1
A bunch of helpers https://github.com/chocolatey/chocolate
y/wiki/HelpersReference
![Page 25: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/25.jpg)
Helpers
Install-ChocolateyPackageInstall-ChocolateyZipPackageInstall-ChocolateyPowershellCommandInstall-ChocolateyVsixPackage - v0.9.8.20+
![Page 26: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/26.jpg)
helpers
Install-ChocolateyPackage
Start-ChocolateyProcessAsAdmin
Install-ChocolateyInstallPackage
Install-ChocolateyPath - when specifying machine path
Install-ChocolateyEnvironmentVariable - when specifying machine path v0.9.8.20+
Install-ChocolateyExplorerMenuItem - v0.9.8.20+ Install-ChocolateyFileAssociation - v0.9.8.20+ Update-SessionEnvironment - v0.9.8.20+
![Page 27: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/27.jpg)
helpers
Install-ChocolateyZipPackage
Install-ChocolateyPowershellCommand
Write-ChocolateySuccess
Write-ChocolateyFailure
Get-ChocolateyWebFile
Get-ChocolateyUnzip
Install-ChocolateyPath - when specifying user path Install-ChocolateyEnvironmentVariable - when specifying user path
v0.9.8.20+ Install-ChocolateyDesktopLink
Install-ChocolateyPinnedTaskBarItem - v0.9.8.20+
![Page 28: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/28.jpg)
Build a package
We have a build script in nuget and a repository layout to make this quick and easy for 3rd party tools.
![Page 29: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/29.jpg)
Quick demo
![Page 30: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/30.jpg)
Install chocolatey
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
![Page 31: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/31.jpg)
cinst
Install a package Cinst <package name> (get from chocolatey.org) Cinst ttl-msysgit –source
http://get.pkgs.ttldev Cinst ttl-msysgit –version 1.2.3.4 –source
http://get.pkgs.ttldev
![Page 32: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/32.jpg)
clist
Get a list of packages via the command line.
Clist (get from chocolatey.org) Clist –source http://get.pkgs.ttldev chocolatey.bat version ttl-msysgit -localonly
![Page 33: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/33.jpg)
Using chef.
Installation using chef is just this.
![Page 34: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/34.jpg)
Or really this…
![Page 35: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/35.jpg)
What’s installed? The chef way
Chocolatey ohai plugin
![Page 36: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/36.jpg)
So…
We should consider using chocolatey to wrap all existing installers
Work is minimal to do this. Near real-time robust replication to
multiple sites Simple consistent interface to install
applications internal or 3rd party Easy to what versions are installed.
![Page 37: using Chocolatey for application deployments](https://reader035.fdocuments.net/reader035/viewer/2022062513/554f8cbdb4c9052a518b51b8/html5/thumbnails/37.jpg)
Questions?