From 2012e944a5af8022005ac6fbbf6490b19d3f56d6 Mon Sep 17 00:00:00 2001 From: Chris King <kingtc@uab.edu> Date: Mon, 19 Jul 2021 09:47:28 -0500 Subject: [PATCH] Add variable for image visibility * Add variable and docs in variables, tfvars example, and README * Add locals (for null interpretation) to compute.tf --- README.md | 31 ++++++++++++++++--------------- compute.tf | 7 ++++++- terraform.tfvars.example | 2 ++ variables.tf | 10 ++++++++++ 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 079626e..92b2279 100644 --- a/README.md +++ b/README.md @@ -32,19 +32,20 @@ ssh-add ~/path/to/private/key # Variables -| Variable | Type | Required | Default | Description | -| :--- | :--- | :--- | :--- | :--- | -| `user_name` | string | yes | | OpenStack username | -| `user_domain_name` | string | yes | | The login domain to use for the user | -| `appcred_id` | string | yes | | Application credential ID. Get one from the openstack dashboard | -| `appcred_name` | string | yes | | Name of the application credential | -| `appcred_secret` | string | yes | | Application credential secret | -| `ssh_keypair` | string | yes | | ssh keypair name to use for authentication | -| `base_image_name` | string | no | `sles-15-sp2-x86_64` | Base image to use for all instances | -| `osd_node_count` | number | no | 3 | Amount of OSD node(s) to provision | -| `public_network_dns` | list(string) | yes | | DNS to use for hosts | -| `sles_reg_code` | string | yes | | SUSE Enterprise registration code | -| `sles_reg_email` | string | yes | | email for use with SUSE registration | -| `sles_ses_reg` | string | yes | | code to register for the storage package in SUSE | -| `osd_disk_sizes` | list(number) | no | \[8, 8\] | Amount/size of disks to add, in GB | +| Variable | Type | Required | Default | Description | +| :--- | :--- | :--- | :--- | :--- | +| `user_name` | string | yes | | OpenStack username | +| `user_domain_name` | string | yes | | The login domain to use for the user | +| `appcred_id` | string | yes | | Application credential ID. Get one from the openstack dashboard | +| `appcred_name` | string | yes | | Name of the application credential | +| `appcred_secret` | string | yes | | Application credential secret | +| `ssh_keypair` | string | yes | | ssh keypair name to use for authentication | +| `base_image_name` | string | no | `sles-15-sp2-x86_64` | Base image to use for all instances | +| `base_image_visibility` | string | no | `null` | Visibility of image. Must be one of "public", "private", "community", or "shared" | +| `osd_node_count` | number | no | 3 | Amount of OSD node(s) to provision | +| `public_network_dns` | list(string) | yes | | DNS to use for hosts | +| `sles_reg_code` | string | yes | | SUSE Enterprise registration code | +| `sles_reg_email` | string | yes | | email for use with SUSE registration | +| `sles_ses_reg` | string | yes | | code to register for the storage package in SUSE | +| `osd_disk_sizes` | list(number) | no | \[8, 8\] | Amount/size of disks to add, in GB | diff --git a/compute.tf b/compute.tf index d12737e..9477ff6 100644 --- a/compute.tf +++ b/compute.tf @@ -1,7 +1,12 @@ +locals { + local_base_image_visibility = var.base_image_visibility == "null" ? null : var.base_image_visibility +} + # data for reference image data "openstack_images_image_v2" "base_image" { - name = var.base_image_name + name = var.base_image_name + visibility = local.local_base_image_visibility } # data for different instance sizes diff --git a/terraform.tfvars.example b/terraform.tfvars.example index e518494..fca2711 100644 --- a/terraform.tfvars.example +++ b/terraform.tfvars.example @@ -18,6 +18,8 @@ ssh_keypair = "ssh_keypair_name" # base image name; right now only suse is supported #base_image_name = "sles-15-sp2-x86_64" +# image visibility; must be one of "public", "private", "community", or "shared" +#base_image_visibility = "community" # the number of OSD instance(s) to deploy #osd_node_count = 1 # an array of IPs to use for dns in the instance diff --git a/variables.tf b/variables.tf index 5333ee6..ed696be 100644 --- a/variables.tf +++ b/variables.tf @@ -34,6 +34,16 @@ variable "base_image_name" { description = "base image to use for the cluster" } +variable "base_image_visibility" { + type = string + default = "null" + description = "visibility of base image" + validation { + condition = can(regex("^(public|private|community|shared|null)$", var.base_image_visibility)) + error_message = "Must be one of \"public\", \"private\", \"community\", or \"shared\"." + } +} + variable "osd_node_count" { type = number default = 3 -- GitLab