diff --git a/ovh/data_me_installation_template.go b/ovh/data_me_installation_template.go index 337f78ebb..5566f336e 100644 --- a/ovh/data_me_installation_template.go +++ b/ovh/data_me_installation_template.go @@ -20,9 +20,9 @@ func dataSourceMeInstallationTemplate() *schema.Resource { // computed "default_language": { - Type: schema.TypeString, - Computed: true, - Description: "The default language of this template", + Type: schema.TypeString, + Computed: true, + Deprecated: "This field will be removed from the API, please use `userMetadata` instead.", }, "customization": { Type: schema.TypeList, @@ -44,15 +44,10 @@ func dataSourceMeInstallationTemplate() *schema.Resource { Computed: true, 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'", }, - "rating": { - Type: schema.TypeInt, - Deprecated: "field is not used anymore", - Computed: true, - }, "ssh_key_name": { - Type: schema.TypeString, - Computed: true, - Description: "Name of the ssh key that should be installed. Password login will be disabled", + Type: schema.TypeString, + Computed: true, + Deprecated: "This field will be removed from the API, please use `userMetadata` instead.", }, }, }, @@ -160,11 +155,6 @@ func dataSourceMeInstallationTemplate() *schema.Resource { Type: schema.TypeString, }, }, - "beta": { - Type: schema.TypeBool, - Computed: true, - Description: "This distribution is new and, although tested and functional, may still display odd behaviour", - }, "bit_format": { Type: schema.TypeInt, Computed: true, @@ -175,11 +165,6 @@ func dataSourceMeInstallationTemplate() *schema.Resource { Computed: true, Description: "Category of this template (informative only). (basic, customer, hosting, other, readyToUse, virtualisation)", }, - "deprecated": { - Type: schema.TypeBool, - Computed: true, - Description: "is this distribution deprecated", - }, "description": { Type: schema.TypeString, Computed: true, @@ -208,21 +193,11 @@ func dataSourceMeInstallationTemplate() *schema.Resource { Type: schema.TypeString, }, }, - "last_modification": { - Type: schema.TypeString, - Computed: true, - Description: "Date of last modification of the base image", - }, "lvm_ready": { Type: schema.TypeBool, Computed: true, Description: "This distribution supports Logical Volumes (Linux LVM)", }, - "supports_sql_server": { - Type: schema.TypeBool, - Computed: true, - Description: "This distribution supports the microsoft SQL server", - }, }, } } diff --git a/ovh/data_me_installation_template_test.go b/ovh/data_me_installation_template_test.go index b74f9f04c..4ff1bb02c 100644 --- a/ovh/data_me_installation_template_test.go +++ b/ovh/data_me_installation_template_test.go @@ -61,9 +61,8 @@ data "ovh_me_installation_template" "template" { ` const testAccMeInstallationTemplateDatasourceConfig_Basic = ` resource "ovh_me_installation_template" "template" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "%s" - default_language = "en" } data "ovh_me_installation_template" "template" { diff --git a/ovh/data_me_installation_templates_test.go b/ovh/data_me_installation_templates_test.go index bef875c3d..b8f27fa6d 100644 --- a/ovh/data_me_installation_templates_test.go +++ b/ovh/data_me_installation_templates_test.go @@ -51,17 +51,15 @@ func TestAccMeInstallationTemplatesDataSource_basic(t *testing.T) { const testAccMeInstallationTemplatesDatasourceConfig_presetup = ` resource "ovh_me_installation_template" "template" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "%s" - default_language = "en" } ` const testAccMeInstallationTemplatesDatasourceConfig_Basic = ` resource "ovh_me_installation_template" "template" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "%s" - default_language = "en" } data "ovh_me_installation_templates" "templates" {} diff --git a/ovh/data_me_ssh_key.go b/ovh/data_me_ssh_key.go index 915cc4960..6a31dae4e 100644 --- a/ovh/data_me_ssh_key.go +++ b/ovh/data_me_ssh_key.go @@ -8,7 +8,8 @@ import ( func dataSourceMeSshKey() *schema.Resource { return &schema.Resource{ - Read: dataSourceMeSshKeyRead, + Read: dataSourceMeSshKeyRead, + DeprecationMessage: "[DEPRECATED] SSH key names '/me/sshKey' will be deprecated soon", Schema: map[string]*schema.Schema{ "key_name": { Type: schema.TypeString, @@ -33,7 +34,6 @@ func dataSourceMeSshKeyRead(d *schema.ResourceData, meta interface{}) error { config := meta.(*Config) sshKey := &MeSshKeyResponse{} - keyName := d.Get("key_name").(string) err := config.OVHClient.Get( fmt.Sprintf("/me/sshKey/%s", keyName), diff --git a/ovh/data_me_ssh_keys.go b/ovh/data_me_ssh_keys.go index e4875cf5e..638d1865d 100644 --- a/ovh/data_me_ssh_keys.go +++ b/ovh/data_me_ssh_keys.go @@ -11,7 +11,8 @@ import ( func dataSourceMeSshKeys() *schema.Resource { return &schema.Resource{ - Read: dataSourceMeSshKeysRead, + Read: dataSourceMeSshKeysRead, + DeprecationMessage: "[DEPRECATED] SSH key names '/me/sshKey' will be deprecated soon", Schema: map[string]*schema.Schema{ "names": { Type: schema.TypeSet, diff --git a/ovh/import_me_installation_template_test.go b/ovh/import_me_installation_template_test.go index 187d17c22..2eff9b3fb 100644 --- a/ovh/import_me_installation_template_test.go +++ b/ovh/import_me_installation_template_test.go @@ -21,11 +21,10 @@ func TestAccMeInstallationTemplate_importBasic(t *testing.T) { { ResourceName: "ovh_me_installation_template.template", ImportState: true, - ImportStateId: fmt.Sprintf("centos7_64/%s", installationTemplate), + ImportStateId: fmt.Sprintf("debian12_64/%s", installationTemplate), ImportStateVerify: true, ImportStateVerifyIgnore: []string{ "remove_default_partition_schemes", - "customization.0.rating", }, }, }, diff --git a/ovh/import_me_ssh_key_test.go b/ovh/import_me_ssh_key_test.go deleted file mode 100644 index 73f42b891..000000000 --- a/ovh/import_me_ssh_key_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package ovh - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform-plugin-testing/helper/acctest" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" -) - -func TestAccMeSshKey_importBasic(t *testing.T) { - resourceName := "ovh_me_ssh_key.key_1" - sshKey := acctest.RandomWithPrefix(test_prefix) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheckCredentials(t) }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: fmt.Sprintf(testAccMeSshKeyConfig_import, sshKey), - }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -const testAccMeSshKeyConfig_import = ` -resource "ovh_me_ssh_key" "key_1" { - key_name = "%s" - key = "ssh-ed25519 AAAAC3NzaC1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -} -` diff --git a/ovh/resource_dedicated_server_install_task.go b/ovh/resource_dedicated_server_install_task.go index cc176958d..b3877657d 100644 --- a/ovh/resource_dedicated_server_install_task.go +++ b/ovh/resource_dedicated_server_install_task.go @@ -69,17 +69,17 @@ func resourceDedicatedServerInstallTask() *schema.Resource { ForceNew: true, Description: "", }, - "install_sql_server": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: "", - }, "language": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "language", + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Deprecated: "This field is deprecated and will be removed in a future release", + }, + "use_spla": { + Type: schema.TypeBool, + Optional: true, + ForceNew: true, + Deprecated: "This field is deprecated and will be removed in a future release", }, "no_raid": { Type: schema.TypeBool, @@ -105,18 +105,6 @@ func resourceDedicatedServerInstallTask() *schema.Resource { ForceNew: true, Description: "", }, - "ssh_key_name": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Description: "Name of the ssh key that should be installed. Password login will be disabled", - }, - "use_spla": { - Type: schema.TypeBool, - Optional: true, - ForceNew: true, - Description: "", - }, }, }, }, diff --git a/ovh/resource_dedicated_server_install_task_test.go b/ovh/resource_dedicated_server_install_task_test.go index 8d3bbd9fc..f3a170b5e 100644 --- a/ovh/resource_dedicated_server_install_task_test.go +++ b/ovh/resource_dedicated_server_install_task_test.go @@ -120,9 +120,7 @@ func testAccDedicatedServerInstallConfig(config string) string { return fmt.Sprintf( testAccDedicatedServerInstallConfig_RebootOnDestroy, dedicated_server, - testName, sshKey, - testName, ) } @@ -130,9 +128,7 @@ func testAccDedicatedServerInstallConfig(config string) string { return fmt.Sprintf( testAccDedicatedServerInstallConfig_Usermetadata, dedicated_server, - testName, sshKey, - testName, sshKey, sshKey, ) @@ -143,7 +139,6 @@ func testAccDedicatedServerInstallConfig(config string) string { dedicated_server, testName, sshKey, - testName, ) } @@ -154,11 +149,6 @@ data ovh_dedicated_server_boots "harddisk" { boot_type = "harddisk" } -resource "ovh_me_ssh_key" "key" { - key_name = "%s" - key = "%s" -} - resource ovh_dedicated_server_update "server" { service_name = data.ovh_dedicated_server_boots.harddisk.service_name boot_id = data.ovh_dedicated_server_boots.harddisk.result[0] @@ -167,13 +157,10 @@ resource ovh_dedicated_server_update "server" { } resource "ovh_me_installation_template" "debian" { - base_template_name = "debian10_64" + base_template_name = "debian12_64" template_name = "%s" - default_language = "en" - customization { - custom_hostname = "mytest" - ssh_key_name = ovh_me_ssh_key.key.key_name + custom_hostname = "mytest" } } @@ -185,7 +172,10 @@ resource "time_sleep" "wait_for_ssh_key_sync" { resource ovh_dedicated_server_install_task "server_install" { service_name = data.ovh_dedicated_server_boots.harddisk.service_name template_name = ovh_me_installation_template.debian.template_name - + user_metadata { + key = "sshKey" + value ="%s" + } depends_on = [time_sleep.wait_for_ssh_key_sync] } ` @@ -201,11 +191,6 @@ data ovh_dedicated_server_boots "rescue" { boot_type = "rescue" } -resource "ovh_me_ssh_key" "key" { - key_name = "%s" - key = "%s" -} - resource ovh_dedicated_server_update "server" { service_name = data.ovh_dedicated_server_boots.harddisk.service_name boot_id = data.ovh_dedicated_server_boots.harddisk.result[0] @@ -213,17 +198,6 @@ resource ovh_dedicated_server_update "server" { state = "ok" } -resource "ovh_me_installation_template" "debian" { - base_template_name = "debian12_64" - template_name = "%s" - default_language = "en" - - customization { - custom_hostname = "mytest" - ssh_key_name = ovh_me_ssh_key.key.key_name - } -} - resource "time_sleep" "wait_for_ssh_key_sync" { create_duration = "120s" depends_on = [ovh_me_installation_template.debian] @@ -231,9 +205,12 @@ resource "time_sleep" "wait_for_ssh_key_sync" { resource ovh_dedicated_server_install_task "server_install" { service_name = data.ovh_dedicated_server_boots.harddisk.service_name - template_name = ovh_me_installation_template.debian.template_name + template_name = "debian12_64" bootid_on_destroy = data.ovh_dedicated_server_boots.rescue.result[0] - + user_metadata { + key = "sshKey" + value ="%s" + } depends_on = [time_sleep.wait_for_ssh_key_sync] } ` @@ -243,27 +220,15 @@ data ovh_dedicated_server_boots "harddisk" { boot_type = "harddisk" } - -resource "ovh_me_ssh_key" "key" { - key_name = "%s" - key = "%s" -} - resource ovh_dedicated_server_update "server" { service_name = data.ovh_dedicated_server_boots.harddisk.service_name monitoring = true state = "ok" } -resource "ovh_me_installation_template" "byolinux" { - base_template_name = "byolinux_64" - template_name = "%s" - default_language = "en" -} - resource ovh_dedicated_server_install_task "server_install" { service_name = data.ovh_dedicated_server_boots.harddisk.service_name - template_name = ovh_me_installation_template.byolinux.template_name + template_name = "byolinux_64" user_metadata { key = "imageURL" value = "https://github.com/ashmonger/akution_test/releases/download/0.6-fixCache/deb11k6.qcow2" @@ -292,5 +257,9 @@ resource ovh_dedicated_server_install_task "server_install" { key = "configDriveUserData" value = "#cloud-config\nssh_authorized_keys:\n - %s\n\nusers:\n - name: aautret\n sudo: ALL=(ALL) NOPASSWD:ALL\n groups: users, sudo\n shell: /bin/bash\n lock_passwd: false\n ssh_authorized_keys:\n - %s\ndisable_root: false\npackages:\n - vim\n - tree\nfinal_message: The system is finally up, after $UPTIME seconds\n" } + user_metadata { + key = "sshKey" + value = "%s" + } } ` diff --git a/ovh/resource_me_installation_template.go b/ovh/resource_me_installation_template.go index 6d1cb2db9..4f931b3e6 100644 --- a/ovh/resource_me_installation_template.go +++ b/ovh/resource_me_installation_template.go @@ -29,10 +29,10 @@ func resourceMeInstallationTemplate() *schema.Resource { Description: "OVH template name yours will be based on, choose one among the list given by compatibleTemplates function", }, "default_language": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The default language of this template", + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Default: "en", ValidateFunc: func(v interface{}, k string) (ws []string, errors []error) { err := helpers.ValidateLanguageCode(v.(string)) if err != nil { @@ -40,20 +40,19 @@ func resourceMeInstallationTemplate() *schema.Resource { } return }, + Deprecated: "This field is deprecated and will be removed in a future release.", }, "template_name": { Type: schema.TypeString, Required: true, Description: "This template name", }, - "remove_default_partition_schemes": { Type: schema.TypeBool, Optional: true, Computed: true, Description: "Remove default partition schemes at creation", }, - "customization": { Type: schema.TypeList, Optional: true, @@ -75,15 +74,10 @@ func resourceMeInstallationTemplate() *schema.Resource { Optional: true, 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'", }, - "rating": { - Type: schema.TypeInt, - Deprecated: "field is not used anymore", - Optional: true, - }, "ssh_key_name": { - Type: schema.TypeString, - Optional: true, - Description: "Name of the ssh key that should be installed. Password login will be disabled", + Type: schema.TypeString, + Optional: true, + Deprecated: "This field is deprecated and will be removed in a future release.", }, }, }, @@ -97,25 +91,15 @@ func resourceMeInstallationTemplate() *schema.Resource { Type: schema.TypeString, }, }, - "beta": { - Type: schema.TypeBool, - Computed: true, - Description: "This distribution is new and, although tested and functional, may still display odd behaviour", - }, "bit_format": { Type: schema.TypeInt, Computed: true, Description: "This template bit format (32 or 64)", }, "category": { - Type: schema.TypeString, - Computed: true, - Description: "Category of this template (informative only). (basic, customer, hosting, other, readyToUse, virtualisation)", - }, - "deprecated": { - Type: schema.TypeBool, - Computed: true, - Description: "is this distribution deprecated", + Type: schema.TypeString, + Computed: true, + Deprecated: "This field is deprecated and will be removed in a future release.", }, "description": { Type: schema.TypeString, @@ -145,21 +129,11 @@ func resourceMeInstallationTemplate() *schema.Resource { Type: schema.TypeString, }, }, - "last_modification": { - Type: schema.TypeString, - Computed: true, - Description: "Date of last modification of the base image", - }, "lvm_ready": { Type: schema.TypeBool, Computed: true, Description: "This distribution supports Logical Volumes (Linux LVM)", }, - "supports_sql_server": { - Type: schema.TypeBool, - Computed: true, - Description: "This distribution supports the microsoft SQL server", - }, }, } } diff --git a/ovh/resource_me_installation_template_partition_scheme_hardware_raid_test.go b/ovh/resource_me_installation_template_partition_scheme_hardware_raid_test.go index 6988e2bfa..f58567bb8 100644 --- a/ovh/resource_me_installation_template_partition_scheme_hardware_raid_test.go +++ b/ovh/resource_me_installation_template_partition_scheme_hardware_raid_test.go @@ -50,9 +50,8 @@ func TestAccMeInstallationTemplatePartitionSchemeHardwareRaidResource_basic(t *t const testAccMeInstallationTemplatePartitionSchemeHardwareRaidResourceConfig_basic = ` resource "ovh_me_installation_template" "template" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "%s" - default_language = "en" } resource "ovh_me_installation_template_partition_scheme" "scheme" { diff --git a/ovh/resource_me_installation_template_partition_scheme_partition_test.go b/ovh/resource_me_installation_template_partition_scheme_partition_test.go index c355a3adc..ee5be3800 100644 --- a/ovh/resource_me_installation_template_partition_scheme_partition_test.go +++ b/ovh/resource_me_installation_template_partition_scheme_partition_test.go @@ -60,9 +60,8 @@ func TestAccMeInstallationTemplatePartitionSchemePartitionResource_basic(t *test const testAccMeInstallationTemplatePartitionSchemePartitionResourceConfig_basic = ` resource "ovh_me_installation_template" "template" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "%s" - default_language = "en" } resource "ovh_me_installation_template_partition_scheme" "scheme" { diff --git a/ovh/resource_me_installation_template_partition_scheme_test.go b/ovh/resource_me_installation_template_partition_scheme_test.go index ef6bffe22..e935aa98f 100644 --- a/ovh/resource_me_installation_template_partition_scheme_test.go +++ b/ovh/resource_me_installation_template_partition_scheme_test.go @@ -75,9 +75,8 @@ func TestAccMeInstallationTemplatePartitionSchemeResource_priority_zero(t *testi const testAccMeInstallationTemplatePartitionSchemeResourceConfig_Basic = ` resource "ovh_me_installation_template" "template" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "%s" - default_language = "en" } resource "ovh_me_installation_template_partition_scheme" "scheme" { @@ -89,9 +88,8 @@ resource "ovh_me_installation_template_partition_scheme" "scheme" { const testAccMeInstallationTemplatePartitionSchemeResourceConfig_priority_zero = ` resource "ovh_me_installation_template" "template" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "%s" - default_language = "en" remove_default_partition_schemes = true } diff --git a/ovh/resource_me_installation_template_test.go b/ovh/resource_me_installation_template_test.go index 3b70d1ed2..1675b5ff0 100644 --- a/ovh/resource_me_installation_template_test.go +++ b/ovh/resource_me_installation_template_test.go @@ -109,11 +109,6 @@ func TestAccMeInstallationTemplateResource_customization(t *testing.T) { "customization.0.custom_hostname", "mytest", ), - resource.TestCheckResourceAttr( - "ovh_me_installation_template.template", - "customization.0.ssh_key_name", - "test", - ), resource.TestCheckResourceAttr( "ovh_me_installation_template.template", "customization.0.post_installation_script_link", @@ -136,20 +131,17 @@ func TestAccMeInstallationTemplateResource_customization(t *testing.T) { const testAccMeInstallationTemplateResourceConfig_Basic = ` resource "ovh_me_installation_template" "template" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "%s" - default_language = "en" } ` const testAccMeInstallationTemplateResourceConfig_Customization = ` resource "ovh_me_installation_template" "template" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "%s" - default_language = "en" customization { custom_hostname = "mytest" - ssh_key_name = "test" post_installation_script_link = "http://mylink.org" post_installation_script_return = "returned_string" } diff --git a/ovh/resource_me_ssh_key.go b/ovh/resource_me_ssh_key.go index 7ec9091dc..6d8c45a18 100644 --- a/ovh/resource_me_ssh_key.go +++ b/ovh/resource_me_ssh_key.go @@ -20,6 +20,7 @@ func resourceMeSshKey() *schema.Resource { return []*schema.ResourceData{d}, nil }, }, + DeprecationMessage: "This resource will be deprecated in next release, please use userMetadata instead", Schema: map[string]*schema.Schema{ "key_name": { @@ -27,18 +28,21 @@ func resourceMeSshKey() *schema.Resource { Required: true, ForceNew: true, Description: "Name of this public Ssh key", + Deprecated: "use userMetada instead", }, "key": { Type: schema.TypeString, Required: true, ForceNew: true, Description: "ASCII encoded public Ssh key", + Deprecated: "use userMetada instead", }, "default": { Type: schema.TypeBool, Computed: true, Optional: true, Description: "True when this public Ssh key is used for rescue mode and reinstallations", + Deprecated: "use userMetada instead", }, }, } @@ -60,6 +64,7 @@ func resourceMeSshKeyRead(d *schema.ResourceData, meta interface{}) error { d.Set("default", r.Default) return nil + } func resourceMeSshKeyCreate(d *schema.ResourceData, meta interface{}) error { diff --git a/ovh/types_dedicated_server.go b/ovh/types_dedicated_server.go index 5ddfc973f..b97c761c4 100644 --- a/ovh/types_dedicated_server.go +++ b/ovh/types_dedicated_server.go @@ -107,11 +107,16 @@ type DedicatedServerTask struct { StartDate time.Time `json:"startDate"` } +type DedicatedServerInstallTaskUserMetadata struct { + Key string `json:"key"` + Value string `json:"value"` +} + type DedicatedServerInstallTaskCreateOpts struct { - TemplateName string `json:"templateName"` - PartitionSchemeName *string `json:"partitionSchemeName,omitempty"` - Details *DedicatedServerInstallTaskDetails `json:"details"` - UserMetadata *[]map[string]string `json:"userMetadata"` + TemplateName string `json:"templateName"` + PartitionSchemeName *string `json:"partitionSchemeName,omitempty"` + Details *DedicatedServerInstallTaskDetails `json:"details"` + UserMetadata []DedicatedServerInstallTaskUserMetadata `json:"userMetadata,omitempty"` } func (opts *DedicatedServerInstallTaskCreateOpts) FromResource(d *schema.ResourceData) *DedicatedServerInstallTaskCreateOpts { @@ -124,18 +129,16 @@ func (opts *DedicatedServerInstallTaskCreateOpts) FromResource(d *schema.Resourc } userMetadata := d.Get("user_metadata").([]interface{}) - var userMetadatas []map[string]string + var userMetadatas []DedicatedServerInstallTaskUserMetadata if len(userMetadata) >= 1 { for _, metadata := range userMetadata { m := metadata.(map[string]interface{}) - metadatum := make(map[string]string) key := m["key"].(string) - metadatum["key"] = key value := m["value"].(string) - metadatum["value"] = value + metadatum := DedicatedServerInstallTaskUserMetadata{Key: key, Value: value} userMetadatas = append(userMetadatas, metadatum) } - opts.UserMetadata = &userMetadatas + opts.UserMetadata = userMetadatas } return opts @@ -144,7 +147,6 @@ func (opts *DedicatedServerInstallTaskCreateOpts) FromResource(d *schema.Resourc type DedicatedServerInstallTaskDetails struct { CustomHostname *string `json:"customHostname,omitempty"` DiskGroupId *int64 `json:"diskGroupId,omitempty"` - InstallSqlServer *bool `json:"installSqlServer,omitempty"` Language *string `json:"language,omitempty"` NoRaid *bool `json:"noRaid,omitempty"` PostInstallationScriptLink *string `json:"postInstallationScriptLink,omitempty"` @@ -157,7 +159,6 @@ type DedicatedServerInstallTaskDetails struct { func (opts *DedicatedServerInstallTaskDetails) FromResource(d *schema.ResourceData, parent string) *DedicatedServerInstallTaskDetails { opts.CustomHostname = helpers.GetNilStringPointerFromData(d, fmt.Sprintf("%s.custom_hostname", parent)) opts.DiskGroupId = helpers.GetNilInt64PointerFromData(d, fmt.Sprintf("%s.disk_group_id", parent)) - opts.InstallSqlServer = helpers.GetNilBoolPointerFromData(d, fmt.Sprintf("%s.install_sql_server", parent)) opts.Language = helpers.GetNilStringPointerFromData(d, fmt.Sprintf("%s.language", parent)) opts.NoRaid = helpers.GetNilBoolPointerFromData(d, fmt.Sprintf("%s.no_raid", parent)) opts.PostInstallationScriptLink = helpers.GetNilStringPointerFromData(d, fmt.Sprintf("%s.post_installation_script_link", parent)) diff --git a/ovh/types_installation_template.go b/ovh/types_installation_template.go index 94b9cb35c..0e2f4876d 100644 --- a/ovh/types_installation_template.go +++ b/ovh/types_installation_template.go @@ -10,20 +10,16 @@ import ( type InstallationTemplate struct { AvailableLanguages []string `json:"available_languages"` - Beta *bool `json:"beta,omitempty"` BitFormat int `json:"bitFormat"` Category string `json:"category"` Customization *InstallationTemplateCustomization `json:"customization,omitempty"` - DefaultLanguage string `json:"defaultLanguage"` - Deprecated *bool `json:"deprecated,omitempty"` + DefaultLanguage string `json:"defaultLanguage,omitempty"` Description string `json:"description"` Distribution string `json:"distribution"` Family string `json:"family"` Filesystems []string `json:"filesystems"` HardRaidConfiguration *bool `json:"hardRaidConfigurtion,omitempty"` - LastModification *string `json:"last_modification"` LvmReady *bool `json:"lvmReady,omitempty"` - SupportsSqlServer *bool `json:"supportsSqlServer,omitempty"` TemplateName string `json:"templateName"` } @@ -32,10 +28,6 @@ func (v InstallationTemplate) ToMap() map[string]interface{} { obj["available_languages"] = v.AvailableLanguages - if v.Beta != nil { - obj["beta"] = *v.Beta - } - obj["bit_format"] = v.BitFormat obj["category"] = v.Category @@ -46,10 +38,8 @@ func (v InstallationTemplate) ToMap() map[string]interface{} { } } - obj["default_language"] = v.DefaultLanguage - - if v.Deprecated != nil { - obj["deprecated"] = *v.Deprecated + if v.DefaultLanguage != "" { + obj["default_language"] = v.DefaultLanguage } obj["description"] = v.Description @@ -61,18 +51,10 @@ func (v InstallationTemplate) ToMap() map[string]interface{} { obj["hard_raid_configuration"] = *v.HardRaidConfiguration } - if v.LastModification != nil { - obj["last_modification"] = *v.LastModification - } - if v.LvmReady != nil { obj["lvm_ready"] = *v.LvmReady } - if v.SupportsSqlServer != nil { - obj["supports_sql_server"] = *v.SupportsSqlServer - } - obj["template_name"] = v.TemplateName return obj @@ -81,7 +63,7 @@ func (v InstallationTemplate) ToMap() map[string]interface{} { type InstallationTemplateCreateOpts struct { BaseTemplateName string `json:"baseTemplateName"` Name string `json:"name"` - DefaultLanguage string `json:"defaultLanguage"` + DefaultLanguage string `json:"defaultLanguage,omitempty"` } func (opts *InstallationTemplateCreateOpts) FromResource(d *schema.ResourceData) *InstallationTemplateCreateOpts { @@ -92,7 +74,7 @@ func (opts *InstallationTemplateCreateOpts) FromResource(d *schema.ResourceData) } type InstallationTemplateUpdateOpts struct { - DefaultLanguage string `json:"defaultLanguage"` + DefaultLanguage string `json:"defaultLanguage,omitempty"` Customization *InstallationTemplateCustomization `json:"customization"` TemplateName string `json:"templateName"` } @@ -100,7 +82,6 @@ type InstallationTemplateUpdateOpts struct { func (opts *InstallationTemplateUpdateOpts) FromResource(d *schema.ResourceData) *InstallationTemplateUpdateOpts { opts.TemplateName = d.Get("template_name").(string) opts.DefaultLanguage = d.Get("default_language").(string) - customizations := d.Get("customization").([]interface{}) if customizations != nil && len(customizations) == 1 { opts.Customization = (&InstallationTemplateCustomization{}).FromResource(d, "customization.0") @@ -139,7 +120,6 @@ func (v InstallationTemplateCustomization) ToMap() map[string]interface{} { obj["ssh_key_name"] = *v.SshKeyName custom_attr_set = true } - // dont return an object if nothing is set if custom_attr_set { return obj diff --git a/website/docs/d/me_installation_template.html.markdown b/website/docs/d/me_installation_template.html.markdown index 81de19cfb..a0ffb3927 100644 --- a/website/docs/d/me_installation_template.html.markdown +++ b/website/docs/d/me_installation_template.html.markdown @@ -22,24 +22,20 @@ data "ovh_me_installation_template" "mytemplate" { The following attributes are exported: -* `available_languages`: List of all language available for this template. -* `beta`: This distribution is new and, although tested and functional, may still display odd behaviour. +* `available_languages`: List of all language available for this template. Deprecated, will be removed in next release. * `bit_format`: This template bit format (32 or 64). * `category`: Category of this template (informative only). (basic, customer, hosting, other, readyToUse, virtualisation). * `customization`: * `custom_hostname`: Set up the server using the provided hostname instead of the default hostname. * `post_installation_script_link`: Indicate the URL where your postinstall customisation script is located. * `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'. - * `rating`: (DEPRECATED) Rating. - * `ssh_key_name`: Name of the ssh key that should be installed. Password login will be disabled. -* `default_language`: The default language of this template. -* `deprecated`: is this distribution deprecated. + * `ssh_key_name`: Name of the ssh key that should be installed. Password login will be disabled. Deprecated, will be removed in next release, use userMetada instead. +* `default_language`: The default language of this template. Deprecated, will be removed in next release. * `description`: information about this template. * `distribution`: the distribution this template is based on. * `family`: this template family type (bsd,linux,solaris,windows). * `hard_raid_configuration`: This distribution supports hardware raid configuration through the OVHcloud API. * `filesystems`: Filesystems available (btrfs,ext3,ext4,ntfs,reiserfs,swap,ufs,xfs,zfs). -* `last_modification`: Date of last modification of the base image. * `partition_scheme`: * `name`: name of this partitioning scheme. * `priority`: on a reinstall, if a partitioning scheme is not specified, the one with the higher priority will be used by default, among all the compatible partitioning schemes (given the underlying hardware specifications). @@ -55,5 +51,4 @@ The following attributes are exported: * `size`: size of partition in MB, 0 => rest of the space. * `order`: step or order. specifies the creation order of the partition on the disk * `type`: partition type. - * `volume_name`: The volume name needed for proxmox distribution -* `supports_sql_server`: This distribution supports the microsoft SQL server. + * `volume_name`: The volume name needed for proxmox distribution \ No newline at end of file diff --git a/website/docs/d/me_ssh_key.markdown b/website/docs/d/me_ssh_key.markdown index 7e16a35a0..03217246e 100644 --- a/website/docs/d/me_ssh_key.markdown +++ b/website/docs/d/me_ssh_key.markdown @@ -4,6 +4,8 @@ subcategory : "Account Management" # ovh_me_ssh_key (Data Source) +-> __NOTE__ This data source will be removed in next release. + Use this data source to retrieve information about an SSH key. ## Example Usage @@ -16,10 +18,16 @@ data "ovh_me_ssh_key" "mykey" { ## Argument Reference +-> __NOTE__ This data source will be removed in next release. + + * `key_name` - (Required) The name of the SSH key. ## Attributes Reference +-> __NOTE__ This data source will be removed in next release. + + * `key_name` - See Argument Reference above. * `key` - The content of the public key. E.g.: "ssh-ed25519 AAAAC3..." diff --git a/website/docs/r/dedicated_server_install_task.html.markdown b/website/docs/r/dedicated_server_install_task.html.markdown index ea0ce1e50..99c110797 100644 --- a/website/docs/r/dedicated_server_install_task.html.markdown +++ b/website/docs/r/dedicated_server_install_task.html.markdown @@ -20,18 +20,12 @@ data ovh_dedicated_server_boots "rescue" { boot_type = "rescue" } -resource "ovh_me_ssh_key" "key" { - key_name = "mykey" - key = "ssh-ed25519 AAAAC3..." -} - resource "ovh_me_installation_template" "debian" { - base_template_name = "debian11_64" - template_name = "mydebian11" - default_language = "en" - + base_template_name = "debian12_64" + template_name = "mydebian12" customization { - ssh_key_name = ovh_me_ssh_key.key.key_name + post_installation_script_link = "http://test" + post_installation_script_return = "ok" } } @@ -39,37 +33,35 @@ resource "ovh_dedicated_server_install_task" "server_install" { service_name = "nsxxxxxxx.ip-xx-xx-xx.eu" template_name = ovh_me_installation_template.debian.template_name bootid_on_destroy = data.ovh_dedicated_server_boots.rescue.result[0] - details { custom_hostname = "mytest" } + user_metadata { + key = "sshKey" + value = "ssh-ed25519 AAAAC3..." + } } ``` -Using a BringYourOwnLinux (BYOL) template (with userMetadata) + +Using a BringYourOwnLinux (BYOLinux) template (with userMetadata) + ```hcl data "ovh_dedicated_server" "server" { service_name = "nsxxxxxxx.ip-xx-xx-xx.eu" } -resource "ovh_me_ssh_key" "key" { - key_name = "mykey" - key = "ssh-ed25519 AAAAC3..." -} - data ovh_dedicated_server_boots "rescue" { service_name = "nsxxxxxxx.ip-xx-xx-xx.eu" boot_type = "rescue" } -resource "ovh_me_installation_template" "mytemplate" { - base_template_name = "byolinux_64" - template_name = "mybyol_test" -} - resource "ovh_dedicated_server_install_task" "server_install" { service_name = data.ovh_dedicated_server.server.service_name - template_name = ovh_me_installation_template.mytemplate.template_name + template_name = "byolinux_64" bootid_on_destroy = data.ovh_dedicated_server_boots.rescue.result[0] + details { + custom_hostname = "mytest" + } user_metadata { key = "imageURL" value = "https://myimage.qcow2" @@ -90,10 +82,6 @@ resource "ovh_dedicated_server_install_task" "server_install" { key = "imageChecksumType" value = "sha512" } - user_metadata { - key = "language" - value = "en" - } user_metadata { key = "imageCheckSum" value = "047122c9ff4d2a69512212104b06c678f5a9cdb22b75467353613ff87ccd03b57b38967e56d810e61366f9d22d6bd39ac0addf4e00a4c6445112a2416af8f225" @@ -102,13 +90,12 @@ resource "ovh_dedicated_server_install_task" "server_install" { key = "configDriveUserData" value = "#cloud-config\nssh_authorized_keys:\n - ${data.ovh_me_ssh_key.mykey.key}\n\nusers:\n - name: patient0\n sudo: ALL=(ALL) NOPASSWD:ALL\n groups: users, sudo\n shell: /bin/bash\n lock_passwd: false\n ssh_authorized_keys:\n - ${data.ovh_me_ssh_key.mykey.key}\ndisable_root: false\npackages:\n - vim\n - tree\nfinal_message: The system is finally up, after $UPTIME seconds\n" } - details { - custom_hostname = "mytest" - } } ``` + Using a Microsoft Windows server OVHcloud template with a specific language -hcl``` + +```hcl data "ovh_dedicated_server" "server" { service_name = "nsxxxxxxx.ip-xx-xx-xx.eu" } @@ -122,17 +109,18 @@ resource "ovh_dedicated_server_install_task" "server_install" { service_name = data.ovh_dedicated_server.server.service_name template_name = "win2019-std_64" bootid_on_destroy = data.ovh_dedicated_server_boots.rescue.result[0] + details { + custom_hostname = "mytest" + } user_metadata { key = "language" value ="fr-fr" } - user_metadata { + user_metadata { key = "useSpla" value = "true" } - details { - custom_hostname = "mytest" - } + } ``` @@ -152,30 +140,18 @@ The `details` block supports: * `custom_hostname` - Set up the server using the provided hostname instead of the default hostname. * `disk_group_id` - Disk group id. -* `install_sql_server` - Set to true to install sql server (Windows template only). -* `language` - Language. +* `language` - Deprecated, will be removed in next release. * `no_raid` - Set to true to disable RAID. * `post_installation_script_link` - Indicate the URL where your postinstall customisation script is located. * `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'. * `soft_raid_devices` - soft raid devices. -* `ssh_key_name` - Name of the ssh key that should be installed. Password login will be disabled. -* `use_spla` - Set to true to use SPLA. - -The `user_metadata` block supports : -(but is not limited to ! : [see documentation](https://help.ovhcloud.com/csm/world-documentation-bare-metal-cloud-dedicated-servers-managing-servers?id=kb_browse_cat&kb_id=203c4f65551974502d4c6e78b7421996&kb_category=97feff9459b0a510f078155c0c16be9b)) - -* `imageUrl` - Your Linux image URL. -* `imageType` - Your Linux image type (qcow2, raw). -* `imageCheckSum` - Your image's checksum. -* `imageCheckSumType` - Your image's checksum type. -* `httpHeadersNKey` - Your image's HTTP headers key (where N is a integer). -* `httpHeadersNValue` - Your image's HTTP headers value (where N is a integer). -* `configDriveUserData` - Your user config drive user data. -* `configDriveMetadata0Key` - Your user config drive user metadata key(where N is a integer). -* `configDriveMetadata0Value` - Your user config drive user metadata value (where N is a integer). -* `language` - Language. -* `useSpla` - Set to true to use SPLA. +* `use_spla` - Deprecated, will be removed in next release. + +The `user_metadata` block supports many arguments, here is a non-exhaustive list depending on the OS: + +-[see api](https://eu.api.ovh.com/console-preview/?section=%2Fdedicated%2FinstallationTemplate&branch=v1#get-/dedicated/installationTemplate/-templateName-) +-[see documentation](https://help.ovhcloud.com/csm/en-ie-dedicated-servers-api-os-installation?id=kb_article_view&sysparm_article=KB0061950#create-an-os-installation-task) to get more information ## Attributes Reference diff --git a/website/docs/r/me_installation_template.html.markdown b/website/docs/r/me_installation_template.html.markdown index ade0cc9e4..55acf6062 100644 --- a/website/docs/r/me_installation_template.html.markdown +++ b/website/docs/r/me_installation_template.html.markdown @@ -10,35 +10,30 @@ Use this resource to create a custom installation template available for dedicat ```hcl resource "ovh_me_installation_template" "mytemplate" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "mytemplate" - default_language = "en" + custom_hostname = "mytest" } ``` ## Argument Reference -* `available_languages`: List of all language available for this template. +* `available_languages`: Deprecated. * `base_template_name`: (Required) The name of an existing installation template, choose one among the list given by `ovh_dedicated_installation_templates` datasource. -* `beta`: This distribution is new and, although tested and functional, may still display odd behaviour. * `bit_format`: This template bit format (32 or 64). * `category`: Category of this template (informative only). (basic, customer, hosting, other, readyToUse, virtualisation). * `customization`: * `custom_hostname`: Set up the server using the provided hostname instead of the default hostname. * `post_installation_script_link`: Indicate the URL where your postinstall customisation script is located. * `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'. - * `rating`: (DEPRECATED) Rating. - * `ssh_key_name`: Name of the ssh key that should be installed. Password login will be disabled. -* `default_language`: (Required) The default language of this template. -* `deprecated`: is this distribution deprecated. + * `ssh_key_name`: Deprecated. +* `default_language`: Deprecated, use language in userMetadata instead. * `description`: information about this template. * `distribution`: the distribution this template is based on. * `family`: this template family type (bsd,linux,solaris,windows). * `filesystems`: Filesystems available (btrfs,ext3,ext4,ntfs,reiserfs,swap,ufs,xfs,zfs). * `hard_raid_configuration`: This distribution supports hardware raid configuration through the OVHcloud API. -* `last_modification`: Date of last modification of the base image. * `remove_default_partition_schemes`: (Required) Remove default partition schemes at creation. -* `supports_sql_server`: This distribution supports the microsoft SQL server. * `template_name`: (Required) This template name. ## Attributes Reference diff --git a/website/docs/r/me_installation_template_partition_scheme.html.markdown b/website/docs/r/me_installation_template_partition_scheme.html.markdown index 582e9e2c5..5920c32ba 100644 --- a/website/docs/r/me_installation_template_partition_scheme.html.markdown +++ b/website/docs/r/me_installation_template_partition_scheme.html.markdown @@ -10,9 +10,8 @@ Use this resource to create partition scheme for a custom installation template ```hcl resource "ovh_me_installation_template" "mytemplate" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "mytemplate" - default_language = "fr" } resource "ovh_me_installation_template_partition_scheme" "scheme" { diff --git a/website/docs/r/me_installation_template_partition_scheme_hardware_raid.html.markdown b/website/docs/r/me_installation_template_partition_scheme_hardware_raid.html.markdown index 0df87d8d4..f0cea02ad 100644 --- a/website/docs/r/me_installation_template_partition_scheme_hardware_raid.html.markdown +++ b/website/docs/r/me_installation_template_partition_scheme_hardware_raid.html.markdown @@ -10,9 +10,8 @@ Use this resource to create a hardware raid group in the partition scheme of a c ```hcl resource "ovh_me_installation_template" "mytemplate" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "mytemplate" - default_language = "fr" } resource "ovh_me_installation_template_partition_scheme" "scheme" { diff --git a/website/docs/r/me_installation_template_partition_scheme_partition.html.markdown b/website/docs/r/me_installation_template_partition_scheme_partition.html.markdown index 76da67514..df6f651ec 100644 --- a/website/docs/r/me_installation_template_partition_scheme_partition.html.markdown +++ b/website/docs/r/me_installation_template_partition_scheme_partition.html.markdown @@ -10,9 +10,8 @@ Use this resource to create a partition in the partition scheme of a custom inst ```hcl resource "ovh_me_installation_template" "mytemplate" { - base_template_name = "centos7_64" + base_template_name = "debian12_64" template_name = "mytemplate" - default_language = "fr" } resource "ovh_me_installation_template_partition_scheme" "scheme" { diff --git a/website/docs/r/me_ssh_key.html.markdown b/website/docs/r/me_ssh_key.html.markdown index 43c214bcb..7b02e0ad0 100644 --- a/website/docs/r/me_ssh_key.html.markdown +++ b/website/docs/r/me_ssh_key.html.markdown @@ -6,10 +6,28 @@ subcategory : "Account Management" Creates an SSH Key. +-> __NOTE__ This resource will be removed in next release, please use userMetada in a server install task instead. +```hcl +resource "ovh_dedicated_server_install_task" "server_install" { + service_name = "nsxxxxxxx.ip-xx-xx-xx.eu" + template_name = ovh_me_installation_template.debian.template_name + bootid_on_destroy = data.ovh_dedicated_server_boots.rescue.result[0] + details { + custom_hostname = "mytest" + } + user_metadata { + key = "sshKey" + value = "ssh-ed25519 AAAAC3..." + } +} +``` + -> __NOTE__ An SSH key in OVH provider cannot be currently used with Public Cloud instances through Terraform. We advise to use [OpenStack provider](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest) to manage Public Cloud instances. Hence, if you need to associate an SSH key to a Public Cloud instance, you need to use [openstack_compute_keypair_v2](https://registry.terraform.io/providers/terraform-provider-openstack/openstack/latest/docs/resources/compute_keypair_v2) resource. ## Example Usage +-> __NOTE__ This resource will be removed in next release, please use userMetada instead. + ```hcl resource "ovh_me_ssh_key" "mykey" { key_name = "mykey" @@ -19,6 +37,8 @@ resource "ovh_me_ssh_key" "mykey" { ## Argument Reference +-> __NOTE__ This resource will be removed in next release, please use userMetada instead. + The following arguments are supported: * `key_name` - (Required) The friendly name of this SSH key. @@ -29,6 +49,8 @@ The following arguments are supported: ## Attributes Reference +-> __NOTE__ This resource will be removed in next release, please use userMetada instead. + The following attributes are exported: * `key_name` - See Argument Reference above.