From fa75204a7d837eeeab6e1f62d3f6eee9360d338d Mon Sep 17 00:00:00 2001 From: Adam Pickering Date: Fri, 15 Nov 2024 11:20:46 -0700 Subject: [PATCH] Remove telemetry field from rancher2_bootstrap resource --- docs/index.md | 1 - docs/resources/bootstrap.md | 5 --- rancher2/0_provider_upgrade_test.go | 7 ---- rancher2/resource_rancher2_bootstrap.go | 34 -------------------- rancher2/resource_rancher2_bootstrap_test.go | 4 --- rancher2/schema_bootstrap.go | 6 ---- 6 files changed, 57 deletions(-) diff --git a/docs/index.md b/docs/index.md index 6399fe6d..3889cc25 100644 --- a/docs/index.md +++ b/docs/index.md @@ -45,7 +45,6 @@ resource "rancher2_bootstrap" "admin" { provider = "rancher2.bootstrap" password = "blahblah" - telemetry = true } # Provider config for admin diff --git a/docs/resources/bootstrap.md b/docs/resources/bootstrap.md index 7eba64a1..0424103a 100644 --- a/docs/resources/bootstrap.md +++ b/docs/resources/bootstrap.md @@ -9,7 +9,6 @@ Provides a Rancher v2 bootstrap resource. This can be used to bootstrap Rancher This resource bootstraps a Rancher system by performing the following tasks: - Updates the default admin password, provided by setting `password` or generating a random one. - Sets `server-url` setting, based on `api_url`. -- Sets `telemetry-opt` setting. - Creates a token for admin user with concrete TTL. **Note:** Starting from Rancher v2.6.0, the Rancher2 installation is setting a random initial admin password by default. To specify the initial password during rancher2 installation, helm chart [`bootstrapPassword`](https://github.com/rancher/rancher/blob/release/v2.6/chart/values.yaml#L157) value for HA installation or docker env variable [`CATTLE_BOOTSTRAP_PASSWORD`](https://github.com/rancher/rancher/blob/release/v2.6/chart/templates/deployment.yaml#L135) for single node installation can be used. To properly use this resource for Rancher v2.6.0 and above, set the `initial_password` argument to the password generated or set during installation. @@ -32,7 +31,6 @@ provider "rancher2" { # Create a new rancher2_bootstrap resource "rancher2_bootstrap" "admin" { password = "blahblah" - telemetry = true } ``` @@ -47,7 +45,6 @@ provider "rancher2" { resource "rancher2_bootstrap" "admin" { initial_password = "" password = "blahblah" - telemetry = true } ``` @@ -65,7 +62,6 @@ resource "rancher2_bootstrap" "admin" { provider = "rancher2.bootstrap" password = "blahblah" - telemetry = true } ``` @@ -75,7 +71,6 @@ The following arguments are supported: * `initial_password` - (Optional/Computed/Sensitive) Initial password for Admin user. Default: `admin` (string) * `password` - (Optional/Computed/Sensitive) Password for Admin user or random generated if empty (string) -* `telemetry` - (Optional) Send telemetry anonymous data. Default: `false` (bool) * `token_ttl` - (Optional) TTL in seconds for generated admin token. Default: `0` (int) * `token_update` - (Optional) Regenerate admin token. Default: `false` (bool) * `ui_default_landing` - (Optional) Default UI landing for k8s clusters. Available options: `ember` (cluster manager ui) and `vue` (cluster explorer ui). Default: `ember` (string) diff --git a/rancher2/0_provider_upgrade_test.go b/rancher2/0_provider_upgrade_test.go index c04d8e25..199a75cf 100644 --- a/rancher2/0_provider_upgrade_test.go +++ b/rancher2/0_provider_upgrade_test.go @@ -64,7 +64,6 @@ resource "rancher2_bootstrap" "foo" { provider = rancher2.bootstrap password = "` + testAccRancher2DefaultAdminPass + `" - telemetry = true } provider "rancher2" { api_url = rancher2_bootstrap.foo.url @@ -87,7 +86,6 @@ resource "rancher2_bootstrap" "foo" { provider = rancher2.bootstrap password = "` + testAccRancher2DefaultAdminPass + `" - telemetry = true } provider "rancher2" { api_url = rancher2_bootstrap.foo.url @@ -272,7 +270,6 @@ func TestAccRancher2Upgrade(t *testing.T) { testAccRancher2UpgradeVars(), testAccCheckRancher2BootstrapExists(testAccRancher2BootstrapType+".foo"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "password", testAccRancher2DefaultAdminPass), - resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "telemetry", "true"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "current_password", testAccRancher2DefaultAdminPass), ), }, @@ -281,7 +278,6 @@ func TestAccRancher2Upgrade(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRancher2BootstrapExists(testAccRancher2BootstrapType+".foo"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "password", testAccRancher2DefaultAdminPass), - resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "telemetry", "true"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "current_password", testAccRancher2DefaultAdminPass), resource.TestCheckResourceAttr(testAccRancher2CatalogType+".foo-global", "name", "foo-global"), resource.TestCheckResourceAttr(testAccRancher2CatalogType+".foo-global", "description", "Terraform catalog acceptance test"), @@ -296,7 +292,6 @@ func TestAccRancher2Upgrade(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRancher2BootstrapExists(testAccRancher2BootstrapType+".foo"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "password", testAccRancher2DefaultAdminPass), - resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "telemetry", "true"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "current_password", testAccRancher2DefaultAdminPass), resource.TestCheckResourceAttr(testAccRancher2CatalogType+".foo-global", "name", "foo-global"), resource.TestCheckResourceAttr(testAccRancher2CatalogType+".foo-global", "description", "Terraform catalog acceptance test"), @@ -312,7 +307,6 @@ func TestAccRancher2Upgrade(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRancher2BootstrapExists(testAccRancher2BootstrapType+".foo"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "password", testAccRancher2DefaultAdminPass), - resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "telemetry", "true"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "current_password", testAccRancher2DefaultAdminPass), resource.TestCheckResourceAttr(testAccRancher2CatalogType+".foo-global", "name", "foo-global"), resource.TestCheckResourceAttr(testAccRancher2CatalogType+".foo-global", "description", "Terraform catalog acceptance test"), @@ -328,7 +322,6 @@ func TestAccRancher2Upgrade(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRancher2BootstrapExists(testAccRancher2BootstrapType+".foo"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "password", testAccRancher2DefaultAdminPass), - resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "telemetry", "true"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "current_password", testAccRancher2DefaultAdminPass), resource.TestCheckResourceAttr(testAccRancher2CatalogType+".foo-global", "name", "foo-global"), resource.TestCheckResourceAttr(testAccRancher2CatalogType+".foo-global", "description", "Terraform catalog acceptance test"), diff --git a/rancher2/resource_rancher2_bootstrap.go b/rancher2/resource_rancher2_bootstrap.go index 2798fa01..ca4af486 100644 --- a/rancher2/resource_rancher2_bootstrap.go +++ b/rancher2/resource_rancher2_bootstrap.go @@ -38,17 +38,6 @@ func resourceRancher2BootstrapCreate(d *schema.ResourceData, meta interface{}) e return err } - // Set telemetry option - telemetry := "out" - if d.Get("telemetry").(bool) { - telemetry = "in" - } - - err = meta.(*Config).SetSetting(bootstrapSettingTelemetry, telemetry) - if err != nil { - return err - } - // Set ui default landing option for rancher up to 2.5.0 if ok, _ := meta.(*Config).IsRancherVersionGreaterThanOrEqual(rancher2UILandingVersion); ok { uiLanding := d.Get("ui_default_landing").(string) @@ -142,18 +131,6 @@ func resourceRancher2BootstrapRead(d *schema.ResourceData, meta interface{}) err d.Set("url", url) - // Get telemetry - telemetry, err := meta.(*Config).GetSettingValue(bootstrapSettingTelemetry) - if err != nil { - return err - } - - if telemetry == "in" { - d.Set("telemetry", true) - } else { - d.Set("telemetry", false) - } - return bootstrapCleanUpTempToken(d, meta) } @@ -172,17 +149,6 @@ func resourceRancher2BootstrapUpdate(d *schema.ResourceData, meta interface{}) e return err } - // Set telemetry option - telemetry := "out" - if d.Get("telemetry").(bool) { - telemetry = "in" - } - - err = meta.(*Config).SetSetting(bootstrapSettingTelemetry, telemetry) - if err != nil { - return err - } - // Update admin user password if needed pass := d.Get("password").(string) changedPass, newPass, adminUser, err := meta.(*Config).SetUserPasswordByName(bootstrapDefaultUser, pass) diff --git a/rancher2/resource_rancher2_bootstrap_test.go b/rancher2/resource_rancher2_bootstrap_test.go index e8e79f53..a5cbdea9 100644 --- a/rancher2/resource_rancher2_bootstrap_test.go +++ b/rancher2/resource_rancher2_bootstrap_test.go @@ -31,7 +31,6 @@ provider "rancher2" { testAccRancher2BootstrapConfig = testAccRancher2ProviderConfig + ` resource "` + testAccRancher2BootstrapType + `" "foo" { password = "` + testAccRancher2BootstrapPass + `" - telemetry = true } ` @@ -53,7 +52,6 @@ func TestAccRancher2Bootstrap_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRancher2BootstrapExists(testAccRancher2BootstrapType+".foo"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "password", testAccRancher2BootstrapPass), - resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "telemetry", "true"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "current_password", testAccRancher2BootstrapPass), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "ui_default_landing", bootstrapUILandingManager), ), @@ -63,7 +61,6 @@ func TestAccRancher2Bootstrap_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRancher2BootstrapExists(testAccRancher2BootstrapType+".foo"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "password", testAccRancher2BootstrapPass), - resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "telemetry", "false"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "current_password", testAccRancher2BootstrapPass), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "ui_default_landing", bootstrapUILandingExplorer), ), @@ -73,7 +70,6 @@ func TestAccRancher2Bootstrap_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRancher2BootstrapExists(testAccRancher2BootstrapType+".foo"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "password", testAccRancher2BootstrapPass), - resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "telemetry", "true"), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "current_password", testAccRancher2BootstrapPass), resource.TestCheckResourceAttr(testAccRancher2BootstrapType+".foo", "ui_default_landing", bootstrapUILandingManager), ), diff --git a/rancher2/schema_bootstrap.go b/rancher2/schema_bootstrap.go index 1c729961..ee6426a8 100644 --- a/rancher2/schema_bootstrap.go +++ b/rancher2/schema_bootstrap.go @@ -13,7 +13,6 @@ const ( bootstrapDefaultTTL = "60000" bootstrapSettingUILanding = "ui-default-landing" bootstrapSettingURL = "server-url" - bootstrapSettingTelemetry = "telemetry-opt" bootstrapUILandingExplorer = "vue" bootstrapUILandingManager = "ember" ) @@ -62,11 +61,6 @@ func bootstrapFields() map[string]*schema.Schema { Optional: true, Default: false, }, - "telemetry": { - Type: schema.TypeBool, - Optional: true, - Default: false, - }, "ui_default_landing": { Type: schema.TypeString, Optional: true,