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

Open
#80 3 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Go
Stars
113
Forks
46
Avg merge
6d 3h
Merged PRs (30d)
3

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.