Reputation: 801
I am using Chocolatey with an Azure ARM template to build a VM and then install the required software. I know there is a way to configure the sources location of where Chocolatey pulls the install files from after you've installed Chocolatey, but does anyone know if there is a way to pre-configure the sources location before (or during) Chocolatey installation?
I am wanting to do a complete unattended installation from start to finish, so having to edit the Chocolatey config file after it installs, and before the apps are installed, negates the whole unattended idea.
I have looked at the Chocolatey PS1 install script here: https://chocolatey.org/install.ps1
Sadly I cannot find anything in there that I could edit to modify the source location of the Choco packages.
Here is the Custom Script Extension that is part of the ARM template to install the VM via Azure
{
"name": "[concat(parameters('virtualMachineName'),'/chocolatey')]",
"type": "Microsoft.Compute/virtualMachines/extensions",
"location": "[resourceGroup().location]",
"apiVersion": "2015-06-15",
"dependsOn": [
"[concat('Microsoft.DevTestLab/schedules/', 'shutdown-computevm-', parameters('virtualMachineName'))]"
],
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"typeHandlerVersion": "1.9",
"autoUpgradeMinorVersion": true,
"settings": {
"fileUris": [
"[concat(parameters('setupChocolatelyScriptLocation'),parameters('setupChocolateyScriptFileName'))]"
],
"commandToExecute": "[concat('powershell -ExecutionPolicy bypass -File ', parameters('setupChocolateyScriptFileName'), ' -chocoPackages ',parameters('chocoPackages'))]"
}
}
},
Upvotes: 1
Views: 2860
Reputation: 18981
Once the installation of Chocolatey is complete, you can use the choco source
command to alter/add/delete the available sources that are used by Chocolatey.
This command is documented here:
https://chocolatey.org/docs/commands-sources
But to give an example, you would simply run:
choco source add -n=bob -s="https://somewhere/out/there/api/v2/"
You could define a dependency on the section of the ARM template that you define this in, so that is only runs once Chocolatey is installed.
An alternative would be to specify the source that you want to use on the installation command, for example:
choco install packageA -y --source https://somewhere/out/there/api/v2/
Upvotes: 2
Reputation: 1064
Depending on the exact use case, one approach would be to create the VM in the context of a DevTest Lab. There's an off-the-shelf Artifact which allows you to set a custom Chocolatey package feed to pull from during VM creation. You can still use ARM and PowerShell and so on.
Upvotes: 0