PowerShell DSC Package Management with Chocolatey
Paul Broadwith
|
Paul Broadwith
Technical Engineering Manager at Chocolatey Software, Inc.
- Glasgow, Scotland
- 30 years in IT in many different sectors
|
|
|
|
|
Agenda
- Options to manage Chocolatey with DSC. What is available?
- Comparisons.
- Questions?
Options To Manage Chocolatey With DSC
What is available?
- PowerShell PackageManagement providers.
- Chocolatey Community ‘Chocolatey’ PowerShell module and DSC resource.
- Chocolatey official DSC resource, cChoco.
PowerShell PackageManagement Providers
Chocolatey OneGet
|
- First commit November 2014 by Garrett Serack (
fearthecowboy ).
- Transferred to the Chocolatey Community in February 2015.
- Deprecated in June 2022 in favour of ChocolateyGet.
|
Chocolatier
|
- First commit on January 2020 by Ethan Bergstrom (
ethanbergstrom ).
- The provider is heavily influenced by the work of the ChocolateyGet project.
- Deprecated in October 2020 in favour of ChocolateyGet.
|
ChocolateyGet
- First commit on September 2016 by Jianyun (
jianyunt
).
- Currently active project.
- Mature.
There may be other PackageManagement providers for Chocolatey but ChocolateyGet
seems to be the most used and recommended by the community.
Chocolatey Community Chocolatey
Module and DSC Resource
Chocolatey
PowerShell Module and DSC Resource
|
- First commit in October 2017 by Gael Colas (
gaelcolas ).
- Part of the Chocolatey Community GitHub Organization.
- PowerShell module AND DSC Resources in the one project.
- PowerShell module can be used separately.
- Actively maintained.
|
History of the official Chocolatey DSC Resource
- The first commit made by Steve Murawski in October 2014.
- Early code was primarily from Lawrence Gripper and Eugene Bekker, with some community help.
- Rob Reynolds started to heavily commit to it in April 2017.
- Paul Broadwith started to maintain it in October 2018.
Managing Chocolatey - what do we need to cover?
The five fundamental areas for Chocolatey:
- Installing Chocolatey CLI.
- Packages.
- Sources.
- Features.
- Config.
Installing Chocolatey CLI
cChocoInstaller InstallChoco
{
# required!
InstallDir = 'c:\choco'
}
All it does is install Chocolatey!
But you need to install Chocolatey before you do anything else because it’s not installed automatically.
Installing Chocolatey CLI In Your Org
Environment chocolateyDownloadUrl
{
Name = 'chocolateyDownloadUrl'
Path = $false
Value = 'https://your-internal-repo.com/chocolatey.1.1.0.nupkg'
Ensure = 'present'
}
cChocoInstaller InstallChoco
{
InstallDir = 'c:\choco'
DependsOn = '[Environment]chocolateyDownloadUrl'
}
PR Submitted by timothy-mcroy-cengage.
Installing A Single Package
cChocoPackageInstaller InstallGoogleChromeWithVersion
{
Name = 'googlechrome'
Ensure = 'present'
Version = 101.0.4951.41
Source = 'https://internal-repo.com/api/v2/'
# Also supports Params and MinimumVersion
DependsOn = '[cChocoInstaller]InstallChoco'
}
Installing Multiple Packages At Once
cChocoPackageInstallerSet InstallBaselinePackages
{
Name = 'googlechrome', 'git', 'putty'
Ensure = 'present'
# Also supports Source
DependsOn = '[cChocoInstaller]InstallChoco'
}
Manage Sources
cChocoSource AddInternalRepoSource
{
Name = 'my-org'
Ensure = 'present'
Source = 'https://internal-repo.com/api/v2/'
# Also supports Priority and Credential
DependsOn = '[cChocoInstaller]InstallChoco'
}
Cannot enable
or disable
a source.
Admin only, self-service or proxy bypass is not supported.
Enable or Disable Features
cChocoFeature allowGlobalConfirmation
{
FeatureName = 'allowGlobalConfirmation'
Ensure = 'present'
DependsOn = '[cChocoInstaller]InstallChoco'
}
Changing Config
cChocoConfig UseVirusTotal
{
ConfigName = 'virusScannerType'
Ensure = 'present'
Value = 'virustotal'
DependsOn = '[cChocoInstaller]InstallChoco'
}
- Installing Chocolatey CLI.
- Packages.
- Sources.
- Features
- Config.
Chocolatey CLI
|
ChocolateyGet |
‘Chocolatey’ |
cChoco |
Auto Install |
✔ |
✔ |
❌ |
Install Choco Separately |
❌ * |
✔ |
✔ |
Org install |
❌ * |
✔ |
✔ |
Chocolatey Packages
|
ChocolateyGet |
‘Chocolatey’ |
cChoco |
Install |
✔ |
✔ |
✔ |
Upgrade |
✔ * |
✔ |
✔ |
Pin |
❌ |
✔ |
❌ |
Uninstall |
✔ |
✔ |
✔ |
List (Local) |
✔ |
✔ |
✔ |
List (Source) |
✔ |
✔ |
✔ |
Chocolatey Sources
|
ChocolateyGet |
‘Chocolatey’ |
cChoco |
Install |
✔ |
✔ |
✔ |
List |
✔ |
✔ |
✔ |
Manage |
✔ * |
✔ |
✔ * |
Chocolatey Features and Config
|
ChocolateyGet |
‘Chocolatey’ |
cChoco |
Manage Feature |
❌ |
✔ |
✔ |
Manage Config |
❌ |
✔ |
✔ |
- The ChocolateyGet PackageManagement provider:
- Native PowerShell integration.
- Simple. Easy to use.
- Mature - been around since 2016.
- The PowerShell PackageManagement provider has limitations.
- The ‘Chocolatey’ Chocolatey Community module:
- Current version is a 0.2.0-preview002 release.
- Feel more mature than its age suggests.
- Written by Gael Colas.
- Can be used as a PowerShell module or as a DSC resource.
- The Chocolatey Official cChoco DSC Resource
- The official DSC resource.
- Been around for a long time and is mature.
- Hasn’t had a lot of love for some time.
- Is missing the pin feature.
- We know what options to manage Chocolatey with DSC.
- We know what the cChoco code looks like.
- We know what features are offered with the providers, modules and DSC resources.
- And we hopefully now have a better informed decision about what we should use.
|
blog.pauby.com
|
Paul Broadwith
|
|
@pauby
|
|
github.com/pauby
|
|
pau.by/linkedin
|
pau.by/talks