From: cel@kernel.org
To: <kdevops@lists.linux.dev>
Cc: Chandan Babu R <chandanbabu@kernel.org>,
Chuck Lever <chuck.lever@oracle.com>
Subject: [RFC PATCH 02/31] terraform/OCI: One default value to rule them
Date: Mon, 31 Mar 2025 20:59:31 -0400 [thread overview]
Message-ID: <20250401010000.764234-3-cel@kernel.org> (raw)
In-Reply-To: <20250401010000.764234-1-cel@kernel.org>
From: Chuck Lever <chuck.lever@oracle.com>
There are 3 sets of default values for each terraform setting.
1. The default value set in terraform/oci/Kconfig
2. The default value in playbooks/roles/gen_tfvars/defaults/main.yml
3. The default value specified in terraform/oci/vars.tf
Often these defaults are different values. It's confusing for
developers, but worse is that it can result in hard-to-diagnose
terraform provider error messages (eg, "Where did that 'invalid'
come from?").
IMO a better plan is to let Kconfig provide the only default value,
and remove the other two. We then have a single authoritative
default value for each setting.
If a required variable is missing a value during "terraform plan",
that will always be a local bug, not something exposed to the
provider to report via an obscure error message.
There are two exceptions:
- For Kconfig booleans, often the variable is defined with a "y"
value in the "true" case, but not defined at all in the "false"
case. So for booleans, the gen_tfvars template needs a default
value in gen_tfvars/defaults/main.yml of "false".
- Where a terraform resource expects an argument to be not present
in some configurations, then vars.tf needs to explicitly define a
default value of "null". Only in those cases it is OK for no
value to be provided by Kconfig.
This is a refactoring change; no behavior change is intended.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
playbooks/roles/gen_tfvars/defaults/main.yml | 18 +--------
terraform/oci/vars.tf | 42 ++++++++++----------
2 files changed, 21 insertions(+), 39 deletions(-)
diff --git a/playbooks/roles/gen_tfvars/defaults/main.yml b/playbooks/roles/gen_tfvars/defaults/main.yml
index e892d85572a8..f64102b2fbf5 100644
--- a/playbooks/roles/gen_tfvars/defaults/main.yml
+++ b/playbooks/roles/gen_tfvars/defaults/main.yml
@@ -48,23 +48,7 @@ terraform_gce_scatch_disk_type: "invalid"
terraform_gce_image_name: "invalid"
terraform_gce_credentials: "invalid"
-terraform_oci_region: "invalid"
-terraform_oci_tenancy_ocid: "invalid"
-terraform_oci_user_ocid: "invalid"
-terraform_oci_user_private_key_path: "invalid"
-terraform_oci_user_fingerprint: "invalid"
-terraform_oci_availablity_domain_ocid: "invalid"
-terraform_oci_compartment_ocid: "invalid"
-terraform_oci_shape: "invalid"
-terraform_oci_instance_flex_ocpus: "invalid"
-terraform_oci_instance_flex_memory_in_gbs: "invalid"
-terraform_oci_os_image_ocid: "invalid"
-terraform_oci_assign_public_ip: "invalid"
-terraform_oci_subnet_ocid: "invalid"
-terraform_oci_data_volume_display_name: "invalid"
-terraform_oci_data_volume_device_file_name: "invalid"
-terraform_oci_sparse_volume_display_name: "invalid"
-terraform_oci_sparse_volume_device_file_name: "invalid"
+terraform_oci_assign_public_ip: "false"
terraform_openstack_cloud_name: "invalid"
terraform_openstack_instance_prefix: "invalid"
diff --git a/terraform/oci/vars.tf b/terraform/oci/vars.tf
index f43e1ee281fc..4c6383d9b231 100644
--- a/terraform/oci/vars.tf
+++ b/terraform/oci/vars.tf
@@ -1,103 +1,101 @@
variable "oci_region" {
description = "An OCI region"
- default = ""
+ type = string
}
variable "oci_tenancy_ocid" {
description = "OCID of your tenancy"
- default = ""
+ type = string
}
variable "oci_user_ocid" {
description = "OCID of the user calling the API"
- default = ""
+ type = string
}
variable "oci_user_private_key_path" {
description = "The path of the private key stored on your computer"
- default = ""
+ type = string
}
variable "oci_user_fingerprint" {
description = "Fingerprint for the key pair being used"
- default = ""
+ type = string
}
variable "oci_availablity_domain" {
description = "Name of availability domain"
- default = ""
+ type = string
}
variable "oci_compartment_ocid" {
description = "OCID of compartment"
- default = ""
+ type = string
}
variable "oci_shape" {
description = "Shape name"
- default = ""
+ type = string
}
variable "oci_instance_flex_ocpus" {
+ default = null
description = "The total number of OCPUs available to the instance."
- type = number
- default = null
+ type = number
}
variable "oci_instance_flex_memory_in_gbs" {
+ default = null
description = "The total amount of memory available to the instance, in gigabytes."
- type = number
- default = null
+ type = number
}
variable "oci_os_image_ocid" {
description = "OCID of OS image"
- default = ""
+ type = string
}
variable "oci_assign_public_ip" {
description = "Assign public IP to the instance"
- default = false
+ type = bool
}
variable "oci_subnet_ocid" {
description = "Subnet OCID"
- default = ""
+ type = string
}
variable "oci_volumes_enable_extra" {
description = "Create additional block volumes per instance"
- default = false
+ type = bool
}
variable "oci_volumes_per_instance" {
description = "The count of additional block volumes per instance"
type = number
- default = 0
}
variable "oci_volumes_size" {
description = "The size of additional block volumes, in gibibytes"
type = number
- default = 0
}
variable "oci_data_volume_display_name" {
description = "Display name to use for the data volume"
- default = "data"
+ type = string
}
variable oci_data_volume_device_file_name {
description = "Data volume's device file name"
- default = "/dev/oracleoci/oraclevdb"
+ type = string
}
variable "oci_sparse_volume_display_name" {
description = "Display name to use for the sparse volume"
- default = "sparse"
+ type = string
}
variable oci_sparse_volume_device_file_name {
description = "Sparse volume's device file name"
- default = "/dev/oracleoci/oraclevdc"
+ type = string
}
--
2.48.1
next prev parent reply other threads:[~2025-04-01 1:00 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 0:59 [RFC PATCH 00/31] Simplify OCI configuration menu cel
2025-04-01 0:59 ` [RFC PATCH 01/31] terraform/OCI: Remove terraform_oci_instance_display_name cel
2025-04-01 0:59 ` cel [this message]
2025-04-01 0:59 ` [RFC PATCH 03/31] terraform/OCI: Add an "Identity & Access" submenu cel
2025-04-01 0:59 ` [RFC PATCH 04/31] terraform/OCI: Add a "Resource location" submenu cel
2025-04-01 0:59 ` [RFC PATCH 05/31] terraform/OCI: Add a "Compute" Kconfig submenu cel
2025-04-01 0:59 ` [RFC PATCH 06/31] terraform/OCI: Add a "Storage" " cel
2025-04-01 0:59 ` [RFC PATCH 07/31] terraform/OCI: Add a "Networking" " cel
2025-04-01 0:59 ` [RFC PATCH 08/31] terraform/OCI: Use "output yaml" for the tenancy OCID cel
2025-04-01 0:59 ` [RFC PATCH 09/31] terraform/OCI: Use "output yaml" for the user OCID cel
2025-04-01 0:59 ` [RFC PATCH 10/31] terraform/OCI: Use "output yaml" for the signing key cel
2025-04-01 0:59 ` [RFC PATCH 11/31] terraform/OCI: Use "output yaml" for the fingerprint cel
2025-04-01 0:59 ` [RFC PATCH 12/31] terraform/OCI: Add a Region selector cel
2025-04-01 0:59 ` [RFC PATCH 13/31] terraform/OCI: Add an availability domain selector cel
2025-04-01 0:59 ` [RFC PATCH 14/31] terraform/OCI: Select your compartment by name instead of by OCID cel
2025-04-01 0:59 ` [RFC PATCH 15/31] terraform/OCI: Use "output yaml" for the instance shape setting cel
2025-04-01 0:59 ` [RFC PATCH 16/31] terraform/OCI: Add a shape selector for Flex shapes cel
2025-04-01 0:59 ` [RFC PATCH 17/31] terraform/OCI: Use "output yaml" for the OCPUs setting cel
2025-04-01 0:59 ` [RFC PATCH 18/31] terraform/OCI: Use "output yaml" for the memory_in_gbs setting cel
2025-04-01 0:59 ` [RFC PATCH 19/31] terraform/OCI: Add a shape family selector cel
2025-04-01 0:59 ` [RFC PATCH 20/31] terraform/OCI: Add a bare metal shape selector cel
2025-04-01 0:59 ` [RFC PATCH 21/31] terraform/OCI: Use "output yaml" for the source image setting cel
2025-04-01 0:59 ` [RFC PATCH 22/31] terraform/OCI: Simplify image selection cel
2025-04-01 0:59 ` [RFC PATCH 23/31] terraform/OCI: Remove TERRAFORM_OCI_VOLUMES_ENABLE_EXTRA cel
2025-04-01 0:59 ` [RFC PATCH 24/31] terraform/OCI: Use "output yaml" for the assign_public_ip" setting cel
2025-04-01 0:59 ` [RFC PATCH 25/31] terraform/OCI: Use "output yaml" for the subnet_ocid setting cel
2025-04-01 0:59 ` [RFC PATCH 26/31] terraform/OCI: Add a default VCN cel
2025-04-01 0:59 ` [RFC PATCH 27/31] terraform/OCI: Add a Kconfig switch to create a VCN on the fly cel
2025-04-01 0:59 ` [RFC PATCH 28/31] terraform/OCI: Run "terraform fmt" on provider.tf cel
2025-04-01 0:59 ` [RFC PATCH 29/31] terraform/OCI: Run "terraform fmt" on main.tf cel
2025-04-01 0:59 ` [RFC PATCH 30/31] terraform/OCI: Nit: alphabetize vars.tf cel
2025-04-01 1:00 ` [RFC PATCH 31/31] terraform/OCI: Update the OCI section of docs/kdevops-terraform.md cel
2025-04-02 19:21 ` [RFC PATCH 00/31] Simplify OCI configuration menu Luis Chamberlain
2025-04-02 19:24 ` Luis Chamberlain
2025-04-02 19:38 ` Chuck Lever
2025-04-02 20:08 ` Luis Chamberlain
2025-04-08 12:42 ` Chandan Babu R
2025-04-08 13:20 ` Chuck Lever
2025-04-09 4:04 ` Chandan Babu R
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250401010000.764234-3-cel@kernel.org \
--to=cel@kernel.org \
--cc=chandanbabu@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=kdevops@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox