Azure / Azure/custom-script-extension-linux
Script for debian7 VM works on the old CustomScript Extension 1.5 and doesn't work on 2.0
- Lingua principale
- Go
- Stelle
- 113
- Fork
- 46
- Merge medio
- 6g 3h
- PR unite (30g)
- 3
Descrizione
I am working on a template for deploying VM with software which need to be configured after default vm provisioning.
This looks like call
1. Call script some config
2. Upload licence file in some dir
3. Restart some services.
It depends on the vm instance so can't be done on vhd image.
I can't put it here but it's really looks like
`sh -c 'echo ZWNobyAtZSAncGFyYW0xOiB2YWx1ZVxucGFyYW0yOnZhbHVlJyA+IGNvbmZpZyAmJiBwcm9nIGNv
bmZpZyAmJiBlY2hvICdsaWNlbmNlIGZpbGUgY29udGVudCBoZXJlJyA+IC9vcHQvc29mdHdhcmUv
bGljZW5jZSAmJiBzZXJpY2UgbGljZW5jZWQgcmVzdGFydCcK | base64- d bash'`
Which is base64 encoded version of
`echo -e 'param1: value\nparam2:value' > config && prog config && echo 'licence file content here' > /opt/software/licence && service licenced restart'`
My template json has this section for extension
```
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('virtualMachineName'),'/config')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "CustomScript",
"typeHandlerVersion": "2.0",
"autoUpgradeMinorVersion": true,
"settings": {
"commandToExecute": "[parameters('extensionCommand')]"
}
}
}
```
where `extensionCommand` is a command above.
Of course at first the were no base64, and I don't shure that I need it. I just saw xml escaped & and > in /var/lib/waagent/ExtensionsConfig.2.xml and try base64 to avoid possible problem.
And I also try sh -c after reading https://github.com/Azure/azure-linux-extensions/issues/215#issuecomment-237693314. In my case for 2.0 extension it doesn't look necessary.
Also I tried to use fileUris whithout any base64 encoding and it fails as usual.
So this command above works well on 1.5 and doesn't work on 2.0 which looks like a bug.
What I got in this new 2.0 extension running this is.
```
error: The resource operation completed with terminal provisioning state 'Failed'.
error: VM has reported a failure when processing extension 'config'. Error message: "Enable failed: failed to execute command: command terminated with exit status=127".
error:
```
All is ok if I run my command manually on VM.
And also is ok if I use this template with 1.5
```
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('virtualMachineName'),'/config')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
],
"properties": {
"publisher": "Microsoft.OSTCExtensions",
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.5",
"autoUpgradeMinorVersion": true,
"settings": {
"commandToExecute": "[parameters('extensionCommand')]"
}
}
}
```
I will add the log files if they really necessary (Unfortunatly I've deleted VM with them). But I found there nothing except the line about 127 error in my script.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia riproducendo la distribuzione con il modello e il comando forniti nelle versioni 1.5 e 2.0 dell'estensione CustomScript. Confronta i log dell'estensione e la gestione di commandToExecute e fileUris, concentrandoti sullo stato di uscita 127 segnalato. Il lavoro è completato quando il comando funziona nella versione 2.0 oppure l'incompatibilità è documentata con una configurazione richiesta chiara.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- azure, debian, shell
- Ambito
- cloud, devops, infrastructure
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 30/100