Automating the Software Deployment Lifecycle in Azure with Chocolatey

Automating the Software Deployment Lifecycle in Azure with Chocolatey

Automating the Software Deployment Lifecycle with Chocolatey, Jenkins and PowerShell Paul Broadwith @pauby https://blog.pauby.com Who Am I? • Paul Broadwith, Glasgow, Scotland • 25+ years in defence, government, financial sectors • Lead Engineer on Boxstarter and Chocolatey cChoco DSC Resource @pauby 2 @pauby 3 Agenda • What is Chocolatey? • Chocolatey Sources; • Internalizing packages; • Recommended Organizational Architecture; • Common scenarios where Chocolatey automation will help you; • Based on this blog post: https://blog.pauby.com/post/getting-started-with-chocolatey- and-jenkins/ @pauby 4 Before We Start! C4B @pauby 5 What Is Chocolatey? @pauby 6 A Definition Of Chocolatey Chocolatey is a package manager for Windows, like apt-get or yum but for Windows. It was designed to be a decentralized framework for quickly installing applications and tools that you need. It is built on the NuGet infrastructure currently using PowerShell as its focus for delivering packages from the distros to your door, err computer. @pauby 7 @pauby 8 Chocolatey manages Packages Packages manage Installers @pauby 9 Chocolatey Package Sources Where do packages come from? @pauby 10 Chocolatey Sources • Where packages come from; • C4B comes with two Chocolatey sources by default: • chocolatey – Chocolatey Community Repository • chocolatey.licensed - Chocolatey Community Repository cached binaries; • Add your own sources: • Repository manager: Artifactory, Nexus, ProGet, Azure DevOps Feeds • Local folder @pauby 11 Azure DevOps Artifacts Feeds • Requires a license to use – only 5 provided; • Create tokens for multiple ‘users’; • See https://blog.pauby.com/post/chocolatey-repository- using-azure-devops-artifacts-feed/ • Chocolatey considerations: • Cannot use choco push as it requires to push to a URL and supports only an --api-key (Azure DevOps pipeline?); • Use nuget push instead as it allows you to push to a named source (where the username and password is defined); • Turn off repository optimizations: choco feature disable - n=usePackageRepositoryOptimizations @pauby 12 Demo 1 Chocolatey Sources. @pauby 13 Internalizing Packages Keeping it in the family. @pauby 14 Why Internalize Packages? • What is ‘package internalization’? • Organizations recommended to disable the default sources: • Reliability • Trust • Bandwidth • Copyright Restrictions • Using the default chocolatey source is subject to: • rate limiting; • excessive download limiting; @pauby 15 C4B Package Internalizer • Automatically internalizes the vast majority of packages; • Very fast; • Don’t reinvent the wheel; • Automation! @pauby 16 Demo 2 Package Internalization. @pauby 17 Organizational Architecture Every organisation is a snowflake. (shield your eyes!) @pauby 18 @pauby 19 Production Testing Internalization @pauby 20 Tools We Need Package Repositories – Azure DevOps Artifacts Feeds Code - PowerShell Automation - Jenkins @pauby 21 Demo 3 Lets look at the Jenkins jobs. @pauby 22 # Jenkins - Internalize Package and Push to Test Repo $temp = Join-Path -Path $env:TEMP -ChildPath ([GUID]::NewGuid()).Guid New-Item -Path $temp -ItemType Directory | Out-Null Write-Verbose “Created temporary directory ‘$temp’.” Set-Location (Join-Path -Path $env:SystemDrive -ChildPath ‘scripts’) .\Internalize-ChocoPackage.ps1 ` -Name $env:P_PKG_LIST ` -OutputDirectory $temp ` -Verbose if ($LASTEXITCODE -eq 0) { Set-Location $temp Get-ChildItem -Path *.nupkg | ForEach-Object { nuget push $_.Name -source $env:G_TEST_REPO -apikey $env:G_API_KEY ` -configfile c:\nuget\nuget.config } } @pauby 23 # Jenkins - Test Package and Push to Prod Repo Set-Location (Join-Path -Path $env:SystemDrive -ChildPath 'scripts') .\Update-ProdRepoFromTest.ps1 ` -ProdRepo $env:G_PROD_REPO ` -ProdRepoApiKey $env:G_API_KEY ` -TestRepo $env:G_TEST_REPO ` -Verbose @pauby 24 # Jenkins - Upgrade Outdated Packages in Test Repository Set-Location (Join-Path -Path $env:SystemDrive -ChildPath 'scripts') .\Get-UpdatedPackage.ps1 -LocalRepo $env:P_LOCAL_REPO_URL ` -LocalRepoApiKey $env:P_LOCAL_REPO_API_KEY ` -RemoteRepo $env:P_REMOTE_REPO_URL ` -Verbose @pauby 25 Jenkins Configuration Test Production Repository Repository Test Internalize Binary / Package Package Installer and and Push Downloads Push to to Test Prod Chocolatey Repo Community Repo Repository Test Production Environment Environment (*maybe) @pauby @pauby 26 Common Scenarios You helping Chocolatey help you. @pauby 28 Demo 4 Jenkins PowerShell Scripts and Common Scenarios @pauby 29 Suggested Improvements. Ideas to extend and customise. @pauby 32 Suggested Improvements • Schedule Updating Packages from Chocolatey Community Repository; • Write your own Pester Tests that your organization needs; • When packages are published to production send a message via email / Slack / Teams or whatever you use; @pauby 33 Summary • What Chocolatey is and how sources work; • Understand package internalization and why it’s important for organizations; • How to apply automation to Chocolatey package testing and deployment; @pauby 34 Questions? @pauby 35 pauby.com @pauby github.com/pauby linkedin.pauby.com Paul Broadwith pau.by/talks @pauby 36.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    33 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us