diff --git a/README.md b/README.md index ce904c0..6ef3510 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,15 @@ Terraform module for deploying a CCEv2 cluster. > > Please comment out the `key_pair` parameters of the existing nodes and declare `key_pair` parameter as a global as shown in the examples bellow. +> **Important Note regarding new module version (as of v2.2.0)** + +> Now you need to add two parameters on the node configuration `postinstall_script` and `preinstall_script`. If you don't use this parameters, set the value to null as the example below. + ## Terraform format ```hcl module "cce2_cluster" { source = "FlexibleEngineCloud/cce/flexibleengine" - version = "2.1.0" + version = "2.2.0" cluster_name = "cluster-test" cluster_desc = " Cluster for testing purpose" @@ -59,6 +63,8 @@ module "cce2_cluster" { data_volume_size = 100 node_labels = {} # this paramters si to be set empty for an existing node vm_tags = {} # this parameters can added to an existing node + postinstall_script = null + preinstall_script = null }, { node_name = "new-node2" @@ -75,6 +81,8 @@ module "cce2_cluster" { Owner = "Me" Env = "Prod" } + postinstall_script = null + preinstall_script = null } ] } @@ -119,6 +127,8 @@ inputs = { data_volume_size = 100 node_labels = {} # this paramters si to be set empty for an existing node vm_tags = {} # this parameters can added to an existing node + postinstall_script = null + preinstall_script = null }, { node_name = "new-node-2" @@ -135,6 +145,8 @@ inputs = { Owner = "Me" Env = "Prod" } + postinstall_script = null + preinstall_script = null } ] } @@ -164,7 +176,7 @@ inputs = { | key\_pair | Name of the SSH key pair | `string` | n/a | yes | | network\_id | ID of the Network | `string` | n/a | yes | | node\_os | Operating System of the CCE Worker Node | `string` | n/a | yes | -| nodes\_list | Nodes list of the CCE2 Cluster |
list(object({
node_name = string
node_flavor = string
availability_zone = string
root_volume_size = number
root_volume_type = string
data_volume_size = number
data_volume_type = string
node_labels = map(string)
vm_tags = map(string)
}))
| `[]` | no | +| nodes\_list | Nodes list of the CCE2 Cluster |
list(object({
node_name = string
node_flavor = string
availability_zone = string
root_volume_size = number
root_volume_type = string
data_volume_size = number
data_volume_type = string
node_labels = map(string)
vm_tags = map(string)
postinstall_script= string
preinstall_script = string
}))
| `[]` | no | | vpc\_id | ID of the VPC | `string` | n/a | yes | ## Outputs diff --git a/examples/postinstall-script/main.tf b/examples/postinstall-script/main.tf new file mode 100644 index 0000000..6503bd5 --- /dev/null +++ b/examples/postinstall-script/main.tf @@ -0,0 +1,32 @@ +module "cce2_cluster" { + source = "FlexibleEngineCloud/cce/flexibleengine" + version = "2.2.0" + + cluster_name = "cluster-test" + cluster_desc = " Cluster for testing purpose" + availability_zone = "eu-west-0a" + + cluster_flavor = "cce.s1.small" + vpc_id = "" + network_id = "" //Caution here, you have to use NETWORK_ID even if argument is "subnet_id". Will be fixed soon + cluster_version = "v1.15.6-r1" + + node_os = "CentOS 7.5" // Can be "EulerOS 2.5" or "CentOS 7.5" + key_pair = "" + + nodes_list = [ + { + node_name = "new-node1" + node_flavor = "s3.large.2" + availability_zone = "eu-west-0a" + root_volume_type = "SATA" + root_volume_size = 40 + data_volume_type = "SATA" + data_volume_size = 100 + node_labels = null # this paramters si to be set empty for an existing node + vm_tags = null # this parameters can added to an existing node + postinstall_script = data.template_file.test.rendered + preinstall_script = null + } + ] +} \ No newline at end of file diff --git a/examples/postinstall-script/provider.tf b/examples/postinstall-script/provider.tf new file mode 100644 index 0000000..6fdf7b7 --- /dev/null +++ b/examples/postinstall-script/provider.tf @@ -0,0 +1,4 @@ +provider "flexibleengine" { + auth_url = "https://iam.eu-west-0.prod-cloud-ocb.orange-business.com/v3" + region = "eu-west-0" +} diff --git a/examples/postinstall-script/test.sh b/examples/postinstall-script/test.sh new file mode 100644 index 0000000..fed2450 --- /dev/null +++ b/examples/postinstall-script/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# Script executed on the postinstall step of the node + +echo "File content" > /root/my_file_content \ No newline at end of file diff --git a/examples/postinstall-script/user-data.tf b/examples/postinstall-script/user-data.tf new file mode 100644 index 0000000..5db9630 --- /dev/null +++ b/examples/postinstall-script/user-data.tf @@ -0,0 +1,3 @@ +data "template_file" "test" { + template = file("test.sh") +} \ No newline at end of file diff --git a/examples/postinstall-script/versions.tf b/examples/postinstall-script/versions.tf new file mode 100644 index 0000000..3eaf345 --- /dev/null +++ b/examples/postinstall-script/versions.tf @@ -0,0 +1,8 @@ +terraform { + required_providers { + flexibleengine = { + source = "FlexibleEngineCloud/flexibleengine" + } + } + required_version = ">= 0.13" +} diff --git a/main.tf b/main.tf index 59ae69a..a7a54f3 100644 --- a/main.tf +++ b/main.tf @@ -17,6 +17,8 @@ resource "flexibleengine_cce_node_v3" "cce_cluster_node" { os = var.node_os availability_zone = var.nodes_list[count.index]["availability_zone"] key_pair = var.key_pair + postinstall = var.nodes_list[count.index]["postinstall_script"] + preinstall = var.nodes_list[count.index]["preinstall_script"] labels = var.nodes_list[count.index]["node_labels"] tags = var.nodes_list[count.index]["vm_tags"] diff --git a/variables.tf b/variables.tf index aa2b9b0..0a19ded 100644 --- a/variables.tf +++ b/variables.tf @@ -56,15 +56,17 @@ variable "nodes_list" { description = "Nodes list of the CCE2 Cluster" default = [] type = list(object({ - node_name = string - node_flavor = string - availability_zone = string - root_volume_size = number - root_volume_type = string - data_volume_size = number - data_volume_type = string - node_labels = map(string) - vm_tags = map(string) + node_name = string + node_flavor = string + availability_zone = string + root_volume_size = number + root_volume_type = string + data_volume_size = number + data_volume_type = string + node_labels = map(string) + vm_tags = map(string) + postinstall_script = string + preinstall_script = string })) }