lambodar
lambodar

Reputation: 3753

Custom extension in VMSS

Once the VMSS is up, I wanted to execute a shell script as part of the VMSS extension. This is what I tried but the script didn't execute.

My initial analysis is the script is not available to VMSS; in this case how to copy the script along with the tf build, I don't want to upload to blob storage and supply the path here. In case of VM I can achieve the same using file provisioner and remote-exec.

..................................
extension {
    name = "StartupScript"
    publisher = "Microsoft.OSTCExtensions"
    type = "CustomScriptForLinux"
    type_handler_version = "1.5"
    settings = <<-SETTINGS
    {
        "commandToExecute": "${var.startup_command}",
        #Script path from where my TF is running
        "script": "${base64encode("/bin/sh ./path_to_custom_scripts/my_script.sh script_param")}",
        "enableInternalDNSCheck": "false"
    }
    SETTINGS
  }
  ..................................

Didn't find much info in extension.log, any help is highly appreciable.

Upvotes: 1

Views: 764

Answers (1)

4c74356b41
4c74356b41

Reputation: 72171

No, you cannot use file provisioner, at least I dont see a clear path forward with this approach, as this is not a single vm, but rather an amalgamation of vms.

As for your original question, no real way of doing that, if you want script extension, you have to upload it somewhere for nodes to pull it down.

You can try and use customData property. This allows you to store something on the vm\vmss node so its added to it at provision time.

Upvotes: 1

Related Questions