32
31
linuxCustomScriptVersion = "1.4"
35
// createVMExtension creates a CustomScript VM extension for the given VM
34
// vmExtension creates a CustomScript VM extension for the given VM
36
35
// which will execute the CustomData on the machine as a script.
37
func createVMExtension(
39
vmExtensionClient compute.VirtualMachineExtensionsClient,
40
os jujuos.OSType, resourceGroup, vmName, location string, vmTags map[string]string,
36
func vmExtensionProperties(os jujuos.OSType) (*compute.VirtualMachineExtensionProperties, error) {
42
37
var commandToExecute, extensionPublisher, extensionType, extensionVersion string
56
51
// Ubuntu renders CustomData as cloud-config, and interprets
57
52
// it with cloud-init. Windows and CentOS do not use cloud-init
59
return errors.NotSupportedf("CustomScript extension for OS %q", os)
54
return nil, errors.NotSupportedf("CustomScript extension for OS %q", os)
62
57
extensionSettings := map[string]interface{}{
63
58
"commandToExecute": commandToExecute,
65
extension := compute.VirtualMachineExtension{
66
Location: to.StringPtr(location),
67
Tags: to.StringMapPtr(vmTags),
68
Properties: &compute.VirtualMachineExtensionProperties{
69
Publisher: to.StringPtr(extensionPublisher),
70
Type: to.StringPtr(extensionType),
71
TypeHandlerVersion: to.StringPtr(extensionVersion),
72
AutoUpgradeMinorVersion: to.BoolPtr(true),
73
Settings: &extensionSettings,
76
err := callAPI(func() (autorest.Response, error) {
77
return vmExtensionClient.CreateOrUpdate(
78
resourceGroup, vmName, extensionName, extension,
60
return &compute.VirtualMachineExtensionProperties{
61
Publisher: to.StringPtr(extensionPublisher),
62
Type: to.StringPtr(extensionType),
63
TypeHandlerVersion: to.StringPtr(extensionVersion),
64
AutoUpgradeMinorVersion: to.BoolPtr(true),
65
Settings: &extensionSettings,