In my previous post Getting Started with Chocolatey and Boxstarter I showed you how to prepare your infrastructure for an Enterprise Chocolatey and Boxstarter Environment.
Now an vanilla OS is not of much usage for us, so we need to create Chocolatey Packages for our local repository. Creating Chocolatey Packages for Offline usage is much simpler than real packages that you want to distribute to the Chocolatey Repository since we don´t need to add all those details to the nuspec file.
There´s a couple of short-cuts that we can leverage and I also learned some lessons the hard way (spending way more hours than planned). This blog post will tell you all about it, and the best part, I´ve prepared a NUPKG Starter Pack that you can download to get a flying start. Let´s jump straight into it.
In my previous post we installed the App-V 5 RDS Client, App-V Scheduler and the Citrix Virtual Desktop Agent. I preferrer to deliver all applications through App-V, but there´s still some Core Applications that needs to be installed in the Master Image. Here is my current deployment script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# Server Roles Installation CINST APPServer -source windowsfeatures # Server Features Installation CINST DNS-Server-Tools -source windowsfeatures CINST DesktopExperience -source windowsfeatures CINST RSAT-AD-Tools-Feature -source windowsfeatures CINST RSAT-ADDS-Tools-Feature -source windowsfeatures CINST RSAT-RDS-Tools-Feature -source windowsfeatures CINST DirectoryServices-DomainController-Tools -source windowsfeatures CINST ActiveDirectory-PowerShell -source windowsfeatures CINST Licensing-Diagnosis-UI -source windowsfeatures CINST TelnetClient -source windowsfeatures CINST RemoteAssistance -source windowsfeatures CINST Microsoft-Windows-GroupPolicy-ServerAdminTools-Update -source windowsfeatures CINST Xps-Foundation-Xps-Viewer -source windowsfeatures CINST MSRDC-Infrastructure -source windowsfeatures CINST WindowsMediaPlayer -source windowsfeatures # Disable Zone Checking CINST Disable_Zone_Checking # Install Redist CINST VC2005x64Runtimes CINST VC2005x86Runtimes CINST VC2008x64Runtimes CINST VC2008x86Runtimes CINST VC2010x64Runtimes CINST VC2010x86Runtimes # Install Citrix VDA CINST XenAppWorker # Install Core Applications CINST App-V5.0SP3RDS CINST App-V_Scheduler_2.3_Agent CINST App-V_Scheduler_2.3_Agent_Config CINST Adobe_Flash_Player_Plugin CINST Adobe_Shockwave_Player CINST Adobe_Reader CINST Silverlight CINST Ghostscript CINST CutePDF CINST JRE CINST Classic_Shell # Enable Zone Checking CINST Enable_Zone_Checking |
So how do we create these Chocolatey applications for offline usage? Well I´m using Julien Stanojevic´s install logics based upon the Chocolatey install logics.
Why? Well we don´t need the Download $URL used by Chocolatey since we´re going to host all binaries in our local ChocoRepository.
So let´s say you want to create a Chocolatey package for Classic Shell. That application is probably in the public repository already so just head over to the site and then click the Download link to get the NUPKG.
When we open the file in Nuget Packet Explorer you can easily find the download URL and the silent argument. Download the setup file and place it in your ChocoReository.
Create the install logics with the unattended switches ($FileArgs):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# Declaring Variables $Vendor ='' $Product ='Classic Shell' $Version ='4.1.0' $packageName = 'ClassicShellSetup_4_1_0' $installerType = 'exe' $unattendedArgs = '/passive' $destination="${env:ChocoRepository}" + "\$Vendor\$Product\$Version\$packageName.$installerType" # Running Install try { Install-ChocolateyPackage $packageName $installerType $unattendedArgs $destination Write-ChocolateySuccess "$packageName" } catch { Write-ChocolateyFailure "$packageName" "$($_.Exception.Message)" throw } |
Save the file as e.g. Box.txt and create the package.
1 |
New-PackageFromScript C:\Box.txt Classic_Shell |
Upload the NUPKG to MyGet and then delete all files from C:\Box (Boxstarter Local Repository). Check my previous article for full details.
I was having a REALLY hard time with custom Powershell scripts and the XenAppWorker job. When the installation was launched from my launcher machine (BS-01) the job was just hanging and there where no logs what so ever to help me out.
So after a couple of sleepless nights I figured out it would be a good idea to try doing a cinst packagename locally on the machine in question!
Boom! The Powershell script stopped because of the Unblock-File cmdlet and XenDesktopVdaSetup because of the stupid Open File Security Warning (my GPO didn´t work as expected). So to fix this I simply changed the Powershell ExecutionPolicy from Unrestricted to Bypass:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# Declaring Variables $Vendor ='' $Product ='Scripts' $Version ='' $packageName = 'Disable Zone Checking' $installerType = 'ps1' $destination="${env:ChocoRepository}" + "\$Vendor\$Product\$Version\$packageName.$installerType" # Running Install try { powershell.exe -ExecutionPolicy bypass -file $destination Write-ChocolateySuccess "$packageName" } catch { Write-ChocolateyFailure "$packageName" "$($_.Exception.Message)" throw } |
To fix the Open File Security Warning I created a Powershell script to Disable Zone Checking at the beginning and Enable it again at the end. Read more about it here.
When working with packages that fails, you can edit them directly in Nuget Packet Explorer. Remember to change the version number, save as and upload to MyGet. The installation routine by Chocolatey and Boxstarter will always pick the latest version.
If you do a clist you will see the packages and the version number.
Automation is King, but when it fails it´s a pain in the ass. But don´t worry, download my NUPKG Starter Pack which are packed with examples and binaries to get you a flying start and save 40 hours of work that I´ve spent to make it easier for you!
Extract the NUPKG Start Pack ZIP file to the root of your ChocoRepository and upload the various NUPKG files to your MyGet account.
Let´s push it.
Nice, 20 minutes to install everything completely unattended (on the slowest EC2 instance). Even App-V Scheduler is configured to bring in all our virtualized applications.