From 366fc952c7900aef60db3fa7f872b82800136656 Mon Sep 17 00:00:00 2001 From: Saad Malik Date: Sun, 17 Jan 2021 13:45:02 -0800 Subject: [PATCH] Update example --- .../spectrocloud_cluster_profile/providers.tf | 20 ++++ .../spectrocloud_cluster_profile/resource.tf | 101 ++++++++++++++++-- .../terraform.template.tfvars | 4 + 3 files changed, 117 insertions(+), 8 deletions(-) create mode 100644 examples/resources/spectrocloud_cluster_profile/providers.tf create mode 100644 examples/resources/spectrocloud_cluster_profile/terraform.template.tfvars diff --git a/examples/resources/spectrocloud_cluster_profile/providers.tf b/examples/resources/spectrocloud_cluster_profile/providers.tf new file mode 100644 index 00000000..330a1102 --- /dev/null +++ b/examples/resources/spectrocloud_cluster_profile/providers.tf @@ -0,0 +1,20 @@ +terraform { + required_providers { + spectrocloud = { + version = ">= 0.1" + source = "spectrocloud/spectrocloud" + } + } +} + +variable "sc_host" {} +variable "sc_username" {} +variable "sc_password" {} +variable "sc_project_name" {} + +provider "spectrocloud" { + host = var.sc_host + username = var.sc_username + password = var.sc_password + project_name = var.sc_project_name +} diff --git a/examples/resources/spectrocloud_cluster_profile/resource.tf b/examples/resources/spectrocloud_cluster_profile/resource.tf index 6b39da86..04bea76b 100644 --- a/examples/resources/spectrocloud_cluster_profile/resource.tf +++ b/examples/resources/spectrocloud_cluster_profile/resource.tf @@ -1,14 +1,72 @@ -resource "spectrocloud_cluster_profile" "cp-addon-azure" { - name = "cp-basic" +# If looking up a cluster profile instead of creating a new one +# data "spectrocloud_cluster_profile" "profile" { +# # id = +# name = var.cluster_cluster_profile_name +# } + +# # Example of a Basic add-on profile +# resource "spectrocloud_cluster_profile" "cp-addon-vsphere" { +# name = "cp-basic" +# description = "basic cp" +# cloud = "vsphere" +# type = "add-on" +# pack { +# name = "spectro-byo-manifest" +# tag = "1.0.x" +# uid = "5faad584f244cfe0b98cf489" +# # layer = "" +# values = <<-EOT +# manifests: +# byo-manifest: +# contents: | +# # Add manifests here +# apiVersion: v1 +# kind: Namespace +# metadata: +# labels: +# app: wordpress +# app3: wordpress3 +# name: wordpress +# EOT +# } +# } + + +data "spectrocloud_pack" "byom" { + name = "spectro-byo-manifest" + # version = "1.0.x" +} + +data "spectrocloud_pack" "csi" { + name = "csi-vsphere-volume" + # version = "1.0.x" +} + +data "spectrocloud_pack" "cni" { + name = "cni-calico" + version = "3.16.0" +} + +data "spectrocloud_pack" "k8s" { + name = "kubernetes" + version = "1.18.14" +} + +data "spectrocloud_pack" "ubuntu" { + name = "ubuntu-vsphere" + # version = "1.0.x" +} + +resource "spectrocloud_cluster_profile" "profile" { + name = "vsphere-picard-3" description = "basic cp" - cloud = "azure" - type = "add-on" + cloud = "vsphere" + type = "cluster" pack { - name = "spectro-byo-manifest" - tag = "1.0.x" - uid = "5faad584f244cfe0b98cf489" - # layer = "" + name = "spectro-byo-manifest" + tag = "1.0.x" + uid = data.spectrocloud_pack.byom.id values = <<-EOT manifests: byo-manifest: @@ -24,4 +82,31 @@ resource "spectrocloud_cluster_profile" "cp-addon-azure" { EOT } + pack { + name = "csi-vsphere-volume" + tag = "1.0.x" + uid = data.spectrocloud_pack.csi.id + values = data.spectrocloud_pack.csi.values + } + + pack { + name = "cni-calico" + tag = "3.16.x" + uid = data.spectrocloud_pack.cni.id + values = data.spectrocloud_pack.cni.values + } + + pack { + name = "kubernetes" + tag = "1.18.x" + uid = data.spectrocloud_pack.k8s.id + values = data.spectrocloud_pack.k8s.values + } + + pack { + name = "ubuntu-vsphere" + tag = "LTS__18.4.x" + uid = data.spectrocloud_pack.ubuntu.id + values = data.spectrocloud_pack.ubuntu.values + } } diff --git a/examples/resources/spectrocloud_cluster_profile/terraform.template.tfvars b/examples/resources/spectrocloud_cluster_profile/terraform.template.tfvars new file mode 100644 index 00000000..6d82eb2b --- /dev/null +++ b/examples/resources/spectrocloud_cluster_profile/terraform.template.tfvars @@ -0,0 +1,4 @@ +sc_host = "{enter host}" +sc_username = "{enter username}" +sc_password = "{enter password}" +sc_project_name = "{enter Project}"