Skip to content

Commit d7186ad

Browse files
authored
Merge pull request #710 from ovh/update_dedicated_postInstallScript
Update dedicated post install script
2 parents 93f6445 + beec70f commit d7186ad

10 files changed

+25
-80
lines changed

ovh/data_me_installation_template.go

-10
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,6 @@ func dataSourceMeInstallationTemplate() *schema.Resource {
3939
Computed: true,
4040
Description: "Set up the server using the provided hostname instead of the default hostname",
4141
},
42-
"post_installation_script_link": {
43-
Type: schema.TypeString,
44-
Computed: true,
45-
Description: "Indicate the URL where your postinstall customisation script is located",
46-
},
47-
"post_installation_script_return": {
48-
Type: schema.TypeString,
49-
Computed: true,
50-
Description: "Indicate the string returned by your postinstall customisation script on successful execution. Advice: your script should return a unique validation string in case of succes. A good example is 'loh1Xee7eo OK OK OK UGh8Ang1Gu'",
51-
},
5242
},
5343
},
5444
},

ovh/resource_dedicated_server_install_task.go

-12
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,6 @@ func resourceDedicatedServerInstallTask() *schema.Resource {
7575
ForceNew: true,
7676
Description: "",
7777
},
78-
"post_installation_script_link": {
79-
Type: schema.TypeString,
80-
Optional: true,
81-
ForceNew: true,
82-
Description: "Indicate the URL where your postinstall customisation script is located",
83-
},
84-
"post_installation_script_return": {
85-
Type: schema.TypeString,
86-
Optional: true,
87-
ForceNew: true,
88-
Description: "indicate the string returned by your postinstall customisation script on successful execution. Advice: your script should return a unique validation string in case of succes. A good example is 'loh1Xee7eo OK OK OK UGh8Ang1Gu'",
89-
},
9078
"soft_raid_devices": {
9179
Type: schema.TypeInt,
9280
Optional: true,

ovh/resource_me_installation_template.go

-10
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,6 @@ func resourceMeInstallationTemplate() *schema.Resource {
5050
Optional: true,
5151
Description: "Set up the server using the provided hostname instead of the default hostname",
5252
},
53-
"post_installation_script_link": {
54-
Type: schema.TypeString,
55-
Optional: true,
56-
Description: "Indicate the URL where your postinstall customisation script is located",
57-
},
58-
"post_installation_script_return": {
59-
Type: schema.TypeString,
60-
Optional: true,
61-
Description: "indicate the string returned by your postinstall customisation script on successful execution. Advice: your script should return a unique validation string in case of succes. A good example is 'loh1Xee7eo OK OK OK UGh8Ang1Gu'",
62-
},
6353
},
6454
},
6555
},

ovh/resource_me_installation_template_test.go

-12
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,6 @@ func TestAccMeInstallationTemplateResource_customization(t *testing.T) {
109109
"customization.0.custom_hostname",
110110
"mytest",
111111
),
112-
resource.TestCheckResourceAttr(
113-
"ovh_me_installation_template.template",
114-
"customization.0.post_installation_script_link",
115-
"http://mylink.org",
116-
),
117-
resource.TestCheckResourceAttr(
118-
"ovh_me_installation_template.template",
119-
"customization.0.post_installation_script_return",
120-
"returned_string",
121-
),
122112
resource.TestCheckResourceAttrSet(
123113
"ovh_me_installation_template.template",
124114
"family",
@@ -142,8 +132,6 @@ resource "ovh_me_installation_template" "template" {
142132
143133
customization {
144134
custom_hostname = "mytest"
145-
post_installation_script_link = "http://mylink.org"
146-
post_installation_script_return = "returned_string"
147135
}
148136
}
149137
`

ovh/types_dedicated_server.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,16 @@ func (opts *DedicatedServerInstallTaskCreateOpts) FromResource(d *schema.Resourc
144144
}
145145

146146
type DedicatedServerInstallTaskDetails struct {
147-
CustomHostname *string `json:"customHostname,omitempty"`
148-
DiskGroupId *int64 `json:"diskGroupId,omitempty"`
149-
NoRaid *bool `json:"noRaid,omitempty"`
150-
PostInstallationScriptLink *string `json:"postInstallationScriptLink,omitempty"`
151-
PostInstallationScriptReturn *string `json:"postInstallationScriptReturn,omitempty"`
152-
SoftRaidDevices *int64 `json:"softRaidDevices,omitempty"`
147+
CustomHostname *string `json:"customHostname,omitempty"`
148+
DiskGroupId *int64 `json:"diskGroupId,omitempty"`
149+
NoRaid *bool `json:"noRaid,omitempty"`
150+
SoftRaidDevices *int64 `json:"softRaidDevices,omitempty"`
153151
}
154152

155153
func (opts *DedicatedServerInstallTaskDetails) FromResource(d *schema.ResourceData, parent string) *DedicatedServerInstallTaskDetails {
156154
opts.CustomHostname = helpers.GetNilStringPointerFromData(d, fmt.Sprintf("%s.custom_hostname", parent))
157155
opts.DiskGroupId = helpers.GetNilInt64PointerFromData(d, fmt.Sprintf("%s.disk_group_id", parent))
158156
opts.NoRaid = helpers.GetNilBoolPointerFromData(d, fmt.Sprintf("%s.no_raid", parent))
159-
opts.PostInstallationScriptLink = helpers.GetNilStringPointerFromData(d, fmt.Sprintf("%s.post_installation_script_link", parent))
160-
opts.PostInstallationScriptReturn = helpers.GetNilStringPointerFromData(d, fmt.Sprintf("%s.post_installation_script_return", parent))
161157
opts.SoftRaidDevices = helpers.GetNilInt64PointerFromData(d, fmt.Sprintf("%s.soft_raid_devices", parent))
162158

163159
return opts

ovh/types_installation_template.go

+2-19
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ type InstallationTemplate struct {
1818
EndOfInstall string `json:"endOfInstall,omitempty"`
1919
Family string `json:"family,omitempty"`
2020
Filesystems []string `json:"filesystems"`
21-
HardRaidConfiguration bool `json:"hardRaidConfiguration,omitempty"`
2221
Inputs []InstallationTemplateInputs `json:"inputs,omitempty"`
2322
License *InstallationTemplateLicense `json:"license,omitempty"`
2423
LvmReady *bool `json:"lvmReady,omitempty"`
@@ -48,8 +47,6 @@ func (v InstallationTemplate) ToMap() map[string]interface{} {
4847
obj["family"] = v.Family
4948
obj["filesystems"] = v.Filesystems
5049

51-
obj["hard_raid_configuration"] = v.HardRaidConfiguration
52-
5350
if v.Inputs != nil {
5451
inputs := make([]interface{}, len(v.Inputs))
5552
for i, input := range v.Inputs {
@@ -107,10 +104,8 @@ func (opts *InstallationTemplateUpdateOpts) FromResource(d *schema.ResourceData)
107104
}
108105

109106
type InstallationTemplateCustomization struct {
110-
CustomHostname *string `json:"customHostname,omitempty"`
111-
PostInstallationScriptLink *string `json:"postInstallationScriptLink,omitempty"`
112-
PostInstallationScriptReturn *string `json:"postInstallationScriptReturn,omitempty"`
113-
SshKeyName *string `json:"sshKeyName,omitempty"`
107+
CustomHostname *string `json:"customHostname,omitempty"`
108+
SshKeyName *string `json:"sshKeyName,omitempty"`
114109
}
115110

116111
func (v InstallationTemplateCustomization) ToMap() map[string]interface{} {
@@ -122,16 +117,6 @@ func (v InstallationTemplateCustomization) ToMap() map[string]interface{} {
122117
custom_attr_set = true
123118
}
124119

125-
if v.PostInstallationScriptLink != nil {
126-
obj["post_installation_script_link"] = *v.PostInstallationScriptLink
127-
custom_attr_set = true
128-
}
129-
130-
if v.PostInstallationScriptReturn != nil {
131-
obj["post_installation_script_return"] = *v.PostInstallationScriptReturn
132-
custom_attr_set = true
133-
}
134-
135120
// dont return an object if nothing is set
136121
if custom_attr_set {
137122
return obj
@@ -216,8 +201,6 @@ func (v InstallationTemplateProjectItem) ToMap() map[string]interface{} {
216201

217202
func (opts *InstallationTemplateCustomization) FromResource(d *schema.ResourceData, parent string) *InstallationTemplateCustomization {
218203
opts.CustomHostname = helpers.GetNilStringPointerFromData(d, fmt.Sprintf("%s.custom_hostname", parent))
219-
opts.PostInstallationScriptLink = helpers.GetNilStringPointerFromData(d, fmt.Sprintf("%s.post_installation_script_link", parent))
220-
opts.PostInstallationScriptReturn = helpers.GetNilStringPointerFromData(d, fmt.Sprintf("%s.post_installation_script_return", parent))
221204
return opts
222205
}
223206

website/docs/d/dedicated_server_boots.html.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ data "ovh_dedicated_server_boots" "netboots" {
1919

2020
* `service_name` - (Required) The internal name of your dedicated server.
2121

22-
* `boot_type` - (Optional) Filter the value of bootType property (harddisk, rescue, ipxeCustomerScript, internal, network)
22+
* `boot_type` - (Optional) Filter the value of bootType property (harddisk, rescue, internal, network)
2323

2424
* `kernel` - (Optional) Filter the value of kernel property (iPXE script name)
2525

website/docs/d/me_installation_template.html.markdown

-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ The following attributes are exported:
2626
* `category`: Category of this template (informative only).
2727
* `customization`:
2828
* `custom_hostname`: Set up the server using the provided hostname instead of the default hostname.
29-
* `post_installation_script_link`: Indicate the URL where your postinstall customisation script is located.
30-
* `post_installation_script_return`: Indicate the string returned by your postinstall customisation script on successful execution. Advice: your script should return a unique validation string in case of succes. A good example is 'loh1Xee7eo OK OK OK UGh8Ang1Gu'.
3129
* `description`: Information about this template.
3230
* `distribution`: Distribution this template is based on.
3331
* `end_of_install` - End of install date of the template.

website/docs/r/dedicated_server_install_task.html.markdown

+18-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ resource "ovh_me_installation_template" "debian" {
2424
base_template_name = "debian12_64"
2525
template_name = "mydebian12"
2626
customization {
27-
post_installation_script_link = "http://test"
28-
post_installation_script_return = "ok"
27+
custom_hostname = "mytest"
2928
}
3029
}
3130
@@ -40,6 +39,15 @@ resource "ovh_dedicated_server_install_task" "server_install" {
4039
key = "sshKey"
4140
value = "ssh-ed25519 AAAAC3..."
4241
}
42+
user_metadata {
43+
key = "postInstallationScript"
44+
value = <<-EOF
45+
#!/bin/bash
46+
echo "coucou postInstallationScript" > /opt/coucou
47+
cat /etc/machine-id >> /opt/coucou
48+
date "+%Y-%m-%d %H:%M:%S" --utc >> /opt/coucou
49+
EOF
50+
}
4351
}
4452
```
4553

@@ -116,6 +124,14 @@ resource "ovh_dedicated_server_install_task" "server_install" {
116124
key = "language"
117125
value ="fr-fr"
118126
}
127+
user_metadata {
128+
key = "postInstallationScript"
129+
value = <<-EOF
130+
coucou postInstallationScriptPowerShell" | Out-File -FilePath "c:\ovhupd\script\coucou.txt"
131+
(Get-ItemProperty -LiteralPath "Registry::HKLM\SOFTWARE\Microsoft\Cryptography" -Name "MachineGuid").MachineGuid | Out-File -FilePath "c:\ovhupd\script\coucou.txt" -Append
132+
(Get-Date).ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss") | Out-File -FilePath "c:\ovhupd\script\coucou.txt" -Append
133+
EOF
134+
}
119135
120136
}
121137
```
@@ -138,8 +154,6 @@ The `details` block supports:
138154
* `disk_group_id` - Disk group id.
139155
* `language` - Deprecated, will be removed in next release.
140156
* `no_raid` - Set to true to disable RAID.
141-
* `post_installation_script_link` - Indicate the URL where your postinstall customisation script is located.
142-
* `post_installation_script_return` - Indicate the string returned by your postinstall customisation script on successful execution. Advice: your script should return a unique validation string in case of succes. A good example is 'loh1Xee7eo OK OK OK UGh8Ang1Gu'.
143157
* `soft_raid_devices` - soft raid devices.
144158
* `use_spla` - Deprecated, will be removed in next release.
145159

website/docs/r/me_installation_template.html.markdown

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ resource "ovh_me_installation_template" "mytemplate" {
2323
* `category`: Category of this template (informative only). (basic, customer, hosting, other, readyToUse, virtualisation).
2424
* `customization`:
2525
* `custom_hostname`: Set up the server using the provided hostname instead of the default hostname.
26-
* `post_installation_script_link`: Indicate the URL where your postinstall customisation script is located.
27-
* `post_installation_script_return`: indicate the string returned by your postinstall customisation script on successful execution. Advice: your script should return a unique validation string in case of succes. A good example is 'loh1Xee7eo OK OK OK UGh8Ang1Gu'.
2826
* `description`: information about this template.
2927
* `distribution`: the distribution this template is based on.
3028
* `family`: this template family type.

0 commit comments

Comments
 (0)