azure-linux-extensions: [CustomScript] extension blocks deployment when using bare command line
I’ve been trying to get this extension to do the simplest thing that could possibly work, which is to run a single command line upon provisioning:
"settings": {
"commandToExecute": "sudo apt-get -y update && sudo apt-get -y dist-upgrade"
}
But whenever I try to do this, my deployments never finish - the extension is created, its provisioning state is set to “running”, but I don’t get any debug output when looking at the properties blade for the extension on the machine it’s provisioned for.
Looking at the code, I believe it is blowing up at:
a) Line 192, where blob_uris is tested for lack of content, even though the documentation states that the fileUrisarray is optional. This because Line 179 would seem to return None in case the setting is missing.
b) Line 278 and following, given that the command line might be mangled by parse_args - which goes against expectations for a Linux sysadmin.
In short, the extension should cover the case of running a bare command line (I would also vastly prefer to be able to inline a full script rather than having to manage access to a storage account, but I’ll file issue #216 for that).
For completion, here’s the relevant resource in the ARM template I’m using:
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"copy": {
"name": "rancher-master-provisioning-loop",
"count": "[parameters('masterCount')]"
},
"name": "[concat(parameters('virtualMachineNameMaster'), copyIndex(), '/updatePackages')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"properties": {
"publisher": "Microsoft.OSTCExtensions",
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.5",
"autoUpgradeMinorVersion": true,
"settings": {
"commandToExecute": "sh sudo apt-get -y update && sudo apt-get -y dist-upgrade"
}
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineNameMaster'), copyIndex())]"
]
},
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (15 by maintainers)
Just to provide input here, @rcarmo is right, the current version of CustomScriptExtension uses
shlex.splitwhich splitswhoami && whoamiintoexec(['whoami', '&&', 'whoami'])which is clearly invalid.In this case this is bug(and also by-design) and fileUris should be used for that.
Easiest workaround is to say
"commandToExecute": "sh -c 'whoami && whoami;'"(I realized @rcarmo missed the-cearlier, the failure listed a few comments above happened due to that).The new version of the Custom Script Extension (which we have not yet published) at https://github.com/Azure/custom-script-extension-linux always uses
sh -cto run the specified comment (likeshell=Truein Python subprocess), so this issue will be fixed in theshortmedium term.