Skip to content

Commit

Permalink
Update SDC Host Linux module to add autobuild scini case
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhar-j committed Aug 23, 2024
1 parent 13e39bb commit c28261c
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 58 deletions.
32 changes: 18 additions & 14 deletions examples/sdc_host_linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,34 @@ remote_host={
}
ip="1.2.11.10"
scini_url="http://example.com/sw_dev/Artifacts/Build-All-Ubuntu22.04/3.6.700.103/release/5.15.0-112-generic"
ip="1.2.11.4"
versions={
pflex = "3.6.700.103"
kernel = "5.15.0-112-generic"
pflex = "4.5.3000.118"
kernel = "5.15.0-1-generic"
}
scini = {
url = "http://example.com/release/5.15.0-1-generic"
linux_distro = "RHEL" #"Ubuntu"
autobuild_scini = true
}
sdc_pkg = {
url = "http://example.com/release/SIGNED/EMC-ScaleIO-sdc-3.6-700.103.Ubuntu.22.04.x86_64.tar"
local_pkg = "EMC-ScaleIO-sdc-3.6-700.103.Ubuntu.22.04.x86_64.tar"
url = "http://example.com/release/SIGNED/EMC-ScaleIO-sdc-4.5-3000.118.Ubuntu.22.04.x86_64.tar"
local_dir = "/tmp"
pkg_name = "EMC-ScaleIO-sdc-3.6-700.103.Ubuntu.22.04.x86_64.tar"
pkg_name = "EMC-ScaleIO-sdc-4.5-3000.118.Ubuntu.22.04.x86_64.tar"
remote_pkg_name = "emc-sdc-package.tar"
remote_dir = "/tmp"
remote_file = "EMC-ScaleIO-sdc-3.6-700.103.Ubuntu.22.04.x86_64.tar"
use_remote_path = false
remote_file = "EMC-ScaleIO-sdc-4.5-3000.118.Ubuntu.22.04.x86_64.tar"
use_remote_path = true
skip_download_sdc = false
}
powerflex_config = {
username = "admin"
endpoint = "https://1.2.3.4:443"
password = "Password"
endpoint = "https://1.2.6.4:443"
password = "Password"
}
```

## Usage
Expand All @@ -77,7 +82,6 @@ After successful operation of above commands, to remove deployment, you need to
```bash
terraform destroy
```

<!-- BEGIN_TF_DOCS -->
## Requirements

Expand Down Expand Up @@ -107,8 +111,8 @@ No resources.
| <a name="input_mdm_ips"></a> [mdm\_ips](#input\_mdm\_ips) | all the mdms (either primary,secondary or virtual ips) in a comma separated list by cluster if unset will use the mdms of the cluster set in the provider block eg. ['10.10.10.5,10.10.10.6', '10.10.10.7,10.10.10.8'] | `list(string)` | `[]` | no |
| <a name="input_powerflex_config"></a> [powerflex\_config](#input\_powerflex\_config) | Stores the configuration for terraform PowerFlex provider. | <pre>object({<br> # Define the attributes of the configuration for terraform PowerFlex provider.<br> username = string<br> endpoint = string<br> password = string<br> })</pre> | n/a | yes |
| <a name="input_remote_host"></a> [remote\_host](#input\_remote\_host) | Stores the SSH credentials for connecting to the remote Linux host. | <pre>object({<br> # Define the `user` attribute of the `remote` variable.<br> user = string<br> # Define the ssh `private_key` file with path for the SDC login user<br> private_key = optional(string, "")<br> # Define the ssh `certificate` file path, issued to the SDC login user<br> certificate = optional(string, "")<br> password = optional(string)<br> })</pre> | n/a | yes |
| <a name="input_scini_url"></a> [scini\_url](#input\_scini\_url) | The URL where the SCINI module package is located. | `string` | n/a | yes |
| <a name="input_sdc_pkg"></a> [sdc\_pkg](#input\_sdc\_pkg) | configuration for SDC package like url to download package from, copy as local package or directory on remote server. One of local\_dir or remote\_dir will be used based on the variable use\_remote\_path | <pre>object({<br> # examples "http://example.com/EMC-ScaleIO-sdc-3.6-700.103.Ubuntu.22.04.x86_64.tar", "ftp://username:password@ftpserver/path/to/file"<br> url = string<br> pkg_name = string<br> remote_pkg_name = optional(string)<br> local_dir = string<br> remote_dir = optional(string, "/tmp")<br> # use the SDC package on remote machine path (where SDC is deployed)<br> use_remote_path = bool<br> })</pre> | n/a | yes |
| <a name="input_scini"></a> [scini](#input\_scini) | The SCINI module package related variables. | <pre>object({<br> # The URL where the SCINI module package is located.<br> url = optional(string)<br> # specify distro where SDC will be deployed eg. RHEL, Ubuntu, SLES etc. as case sensitive<br> linux_distro = string<br> #allow to build scini on destination machine. This may not work on PowerFlex v3.X. Prerequisites here https://www.dell.com/support/kbdoc/en-us/000224134/how-to-on-demand-compilation-of-the-powerflex-sdc-driver <br> autobuild_scini = optional(bool, false)<br> })</pre> | n/a | yes |
| <a name="input_sdc_pkg"></a> [sdc\_pkg](#input\_sdc\_pkg) | configuration for SDC package like url to download package from, copy as local package or directory on remote server. One of local\_dir or remote\_dir will be used based on the variable use\_remote\_path | <pre>object({<br> # examples "http://example.com/EMC-ScaleIO-sdc-3.6-700.103.Ubuntu.22.04.x86_64.tar", "ftp://username:password@ftpserver/path/to/file"<br> url = optional(string)<br> #the name of the SDC package for local.<br> pkg_name = optional(string)<br> #the name of the SDC package for remote machine. It should be emc-sdc-package.(tar/rpm)<br> remote_pkg_name = optional(string)<br> #local directory where the SDC package will be downloaded.<br> local_dir = optional(string)<br> #remote directory where the SDC package will be downloaded. (if use_remote_path is true)<br> remote_dir = optional(string, "/tmp")<br> # use the SDC package on remote machine path (where SDC is deployed)<br> use_remote_path = bool<br> # if SDC package is available in local directory, download can be skipped by setting to true<br> skip_download_sdc = optional(bool, false)<br> })</pre> | n/a | yes |
| <a name="input_versions"></a> [versions](#input\_versions) | n/a | <pre>object({<br> pflex = string<br> kernel = string<br> })</pre> | n/a | yes |

## Outputs
Expand Down
2 changes: 1 addition & 1 deletion examples/sdc_host_linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module "sdc_host_linux" {
versions = var.versions
ip = var.ip
remote_host = var.remote_host
scini_url = var.scini_url
scini = var.scini
sdc_pkg = var.sdc_pkg
mdm_ips = var.mdm_ips
}
Expand Down
27 changes: 21 additions & 6 deletions examples/sdc_host_linux/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,37 @@ variable "mdm_ips" {
default = []
}

variable "scini_url" {
type = string
description = "The URL where the SCINI module package is located."

variable "scini" {

description = "The SCINI module package related variables."
type = object({
# The URL where the SCINI module package is located.
url = optional(string)
# specify distro where SDC will be deployed eg. RHEL, Ubuntu, SLES etc. as case sensitive
linux_distro = string
#allow to build scini on destination machine. This may not work on PowerFlex v3.X. Prerequisites here https://www.dell.com/support/kbdoc/en-us/000224134/how-to-on-demand-compilation-of-the-powerflex-sdc-driver
autobuild_scini = optional(bool, false)
})
}

variable "sdc_pkg" {
description = "configuration for SDC package like url to download package from, copy as local package or directory on remote server. One of local_dir or remote_dir will be used based on the variable use_remote_path"
type = object({
# examples "http://example.com/EMC-ScaleIO-sdc-3.6-700.103.Ubuntu.22.04.x86_64.tar", "ftp://username:password@ftpserver/path/to/file"
url = string
pkg_name = string
url = optional(string)
#the name of the SDC package for local.
pkg_name = optional(string)
#the name of the SDC package for remote machine. It should be emc-sdc-package.(tar/rpm)
remote_pkg_name = optional(string)
local_dir = string
#local directory where the SDC package will be downloaded.
local_dir = optional(string)
#remote directory where the SDC package will be downloaded. (if use_remote_path is true)
remote_dir = optional(string, "/tmp")
# use the SDC package on remote machine path (where SDC is deployed)
use_remote_path = bool
# if SDC package is available in local directory, download can be skipped by setting to true
skip_download_sdc = optional(bool, false)
})
}

Expand Down
29 changes: 4 additions & 25 deletions modules/sdc_host_linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,6 @@ limitations under the License.

This Terraform module installs the SDC package on a remote Linux host using the `powerflex_sdc_host` resource.

## Variables

| Variable Name | Description |
|---------------|-------------|
| `ip` | Stores the IP address of the remote Linux host. |
| `remote_host` | Stores the SSH credentials for connecting to the remote Linux host. |
| `remote_host.user` | Stores the username for connecting to the remote Linux host. root will have all required privileges.|
| `remote_host.private_key` | Stores the SSH private key for connecting to the remote Linux host. |
| `remote_host.certificate` | Stores the SSH certificate for connecting to the remote Linux host. |
| `remote_host.password` | Stores the password for connecting to the remote Linux host. |
| `sdc_pkg` | Stores the SDC package information. |
| `sdc_pkg.url` | Stores the URL to download the SDC package from. eg. "http://example.com/path/to/file", "ftp://username:password@ftpserver/path/to/file"|
| `sdc_pkg.pkg_name` | Stores the name of the SDC package for local. |
| `sdc_pkg.remote_pkg_name` | Stores the name of the SDC package for remote machine. It should be emc-sdc-package.(tar/rpm)|
| `sdc_pkg.local_dir` | Stores the local directory where the SDC package will be downloaded. |
| `sdc_pkg.remote_dir` | Stores the remote directory where the SDC package will be downloaded. Dir should be present. |
| `sdc_pkg.use_remote_path` | Stores the flag to use the SDC package on a remote machine path or not. |
| `versions` | Stores the kernel and PowerFlex versions. |
| `scini_url` | The URL where the SCINI module package is located. |


### Prerequisites

SDC Host module can only be used with terraform provider PowerFlex v1.6.0 and above.
Expand All @@ -57,7 +36,7 @@ module "sdc_host" {
versions = var.versions
ip = var.ip
remote_host = var.remote_host
scini_url = var.scini_url
scini = var.scini
sdc_pkg = var.sdc_pkg
}
```
Expand All @@ -69,7 +48,6 @@ After providing proper values to all the attributes eg. using terraform.tfvars,
terraform init
terraform apply
```

<!-- BEGIN_TF_DOCS -->
## Requirements

Expand Down Expand Up @@ -97,6 +75,7 @@ No modules.
| powerflex_sdc_host.sdc_remote_path | resource |
| [terraform_data.compare_version](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
| [terraform_data.linux_scini](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
| [terraform_data.linux_scini_auto](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
| [terraform_data.sdc_pkg_local](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
| [terraform_data.sdc_pkg_remote](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
| [local_sensitive_file.ssh_cert](https://registry.terraform.io/providers/hashicorp/local/latest/docs/data-sources/sensitive_file) | data source |
Expand All @@ -109,8 +88,8 @@ No modules.
| <a name="input_ip"></a> [ip](#input\_ip) | Stores the IP address of the remote Linux host. | `string` | n/a | yes |
| <a name="input_mdm_ips"></a> [mdm\_ips](#input\_mdm\_ips) | all the mdms (either primary,secondary or virtual ips) in a comma separated list by cluster if unset will use the mdms of the cluster set in the provider block eg. ['10.10.10.5,10.10.10.6', '10.10.10.7,10.10.10.8'] | `list(string)` | n/a | yes |
| <a name="input_remote_host"></a> [remote\_host](#input\_remote\_host) | Stores the SSH credentials for connecting to the remote Linux host. | <pre>object({<br> # Define the `user` attribute of the `remote` variable.<br> user = string<br> # Define the ssh `private_key` file with path for the SDC login user<br> private_key = optional(string, "")<br> # Define the ssh `certificate` file path, issued to the SDC login user<br> certificate = optional(string, "")<br> password = optional(string)<br> })</pre> | n/a | yes |
| <a name="input_scini_url"></a> [scini\_url](#input\_scini\_url) | The URL where the SCINI module package is located. | `string` | n/a | yes |
| <a name="input_sdc_pkg"></a> [sdc\_pkg](#input\_sdc\_pkg) | configuration for SDC package like url to download package from, copy as local package or directory on remote server. One of local\_dir or remote\_dir will be used based on the variable use\_remote\_path | <pre>object({<br> # examples "http://example.com/EMC-ScaleIO-sdc-3.6-700.103.Ubuntu.22.04.x86_64.tar", "ftp://username:password@ftpserver/path/to/file"<br> url = string<br> pkg_name = string<br> remote_pkg_name = optional(string)<br> local_dir = string<br> remote_dir = optional(string, "/tmp")<br> # use the SDC package on remote machine path (where SDC is deployed)<br> use_remote_path = bool<br> })</pre> | n/a | yes |
| <a name="input_scini"></a> [scini](#input\_scini) | The SCINI module package related variables. | <pre>object({<br> # The URL where the SCINI module package is located.<br> url = optional(string)<br> # specify distro where SDC will be deployed eg. RHEL, Ubuntu, SLES etc. as case sensitive<br> linux_distro = string<br> #allow to build scini on destination machine. This may not work on PowerFlex v3.X. Prerequisites here https://www.dell.com/support/kbdoc/en-us/000224134/how-to-on-demand-compilation-of-the-powerflex-sdc-driver <br> autobuild_scini = optional(bool, false)<br> })</pre> | n/a | yes |
| <a name="input_sdc_pkg"></a> [sdc\_pkg](#input\_sdc\_pkg) | configuration for SDC package like url to download package from, copy as local package or directory on remote server. One of local\_dir or remote\_dir will be used based on the variable use\_remote\_path | <pre>object({<br> # examples "http://example.com/EMC-ScaleIO-sdc-3.6-700.103.Ubuntu.22.04.x86_64.tar", "ftp://username:password@ftpserver/path/to/file"<br> url = optional(string)<br> #the name of the SDC package for local.<br> pkg_name = optional(string)<br> #the name of the SDC package for remote machine. It should be emc-sdc-package.(tar/rpm)<br> remote_pkg_name = optional(string)<br> #local directory where the SDC package will be downloaded.<br> local_dir = optional(string)<br> #remote directory where the SDC package will be downloaded. (if use_remote_path is true)<br> remote_dir = optional(string, "/tmp")<br> # use the SDC package on remote machine path (where SDC is deployed)<br> use_remote_path = bool<br> # if SDC package is available in local directory, download can be skipped by setting to true<br> skip_download_sdc = optional(bool, false)<br> })</pre> | n/a | yes |
| <a name="input_versions"></a> [versions](#input\_versions) | n/a | <pre>object({<br> pflex = string<br> kernel = string<br> })</pre> | n/a | yes |

## Outputs
Expand Down
53 changes: 47 additions & 6 deletions modules/sdc_host_linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ locals {

locals {
use_remote_path = var.sdc_pkg.use_remote_path
share_url_scini = var.scini_url
share_url_scini = var.scini.url
}
resource terraform_data sdc_pkg_local {
#do if use_remote_path is false.
count = var.sdc_pkg.use_remote_path ? 0: 1
count = ( var.sdc_pkg.use_remote_path && !var.sdc_pkg.skip_download_sdc) ? 0: 1
input = var.sdc_pkg
#One option is to download sdc on local drive and provide local path
provisioner "local-exec" {
Expand Down Expand Up @@ -113,7 +113,7 @@ resource "terraform_data" "compare_version" {
#copy SDC package on remote server
resource terraform_data sdc_pkg_remote {
# perform if variable is true
count = local.use_remote_path ? 1 : 0
count = ( local.use_remote_path && !var.sdc_pkg.skip_download_sdc) ? 1: 0
connection {
type = "ssh"
user = self.output.user.name
Expand Down Expand Up @@ -154,6 +154,7 @@ resource terraform_data sdc_pkg_remote {
# # STEP 3 - install pre-requisites (scini module)
# # provisioner to install scini module on SDC
resource "terraform_data" "linux_scini" {
count = ( var.scini.linux_distro == "RHEL" || var.scini.autobuild_scini) ? 0 : 1
connection {
type = "ssh"
user = self.output.user.name
Expand All @@ -175,7 +176,7 @@ resource "terraform_data" "linux_scini" {
password = var.remote_host.password
}
ip = var.ip
scini_url = var.scini_url
scini_url = var.scini.url
}

provisioner "remote-exec" {
Expand All @@ -192,12 +193,51 @@ resource "terraform_data" "linux_scini" {
}
}

# # provisioner to install scini module on SDC
resource "terraform_data" "linux_scini_auto" {
# Execute when autobuild flag is set and if it is not RHEL
count = ( var.scini.linux_distro != "RHEL" && var.scini.autobuild_scini) ? 1 : 0
connection {
type = "ssh"
user = self.output.user.name
private_key = self.output.user.private_key
certificate = self.output.user.certificate
host = self.output.ip
password = self.output.user.password
}
input = {
user = {
name = var.remote_host.user
#user can use keys or userid/password. Make sure to copy the keys to remote server before using keys
private_key = var.remote_host.private_key == "" ? "" : data.local_sensitive_file.ssh_key[0].content
certificate = var.remote_host.certificate == "" ? "" : data.local_sensitive_file.ssh_cert[0].content
password = var.remote_host.password
}
ip = var.ip
}

provisioner "remote-exec" {
inline = [
"mkdir -p /etc/emc/scaleio/scini_sync",
"touch /etc/emc/scaleio/scini_sync/.build_scini",
]
}
provisioner "remote-exec" {
when = destroy
inline = [
"rm /etc/emc/scaleio/scini_sync/.build_scini"
]
}
}


# # STEP 4 - Install actual SDC
# # SDC configuration
resource powerflex_sdc_host sdc_local_path {

count = local.use_remote_path ? 0 : 1 #deploy if variable is false
depends_on = [ terraform_data.linux_scini ]
depends_on = [ terraform_data.compare_version,
terraform_data.linux_scini]
ip = var.ip
remote = {
user = var.remote_host.user
Expand All @@ -215,7 +255,8 @@ resource "terraform_data" "linux_scini" {

resource powerflex_sdc_host sdc_remote_path {
count = local.use_remote_path ? 1 : 0 #deploy if variable is true
depends_on = [ terraform_data.linux_scini ]
depends_on = [ terraform_data.compare_version,
terraform_data.linux_scini]
ip = var.ip
remote = {
user = var.remote_host.user
Expand Down
26 changes: 20 additions & 6 deletions modules/sdc_host_linux/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,36 @@ variable "mdm_ips" {
}


variable "scini_url" {
type = string
description = "The URL where the SCINI module package is located."
variable "scini" {

description = "The SCINI module package related variables."
type = object({
# The URL where the SCINI module package is located.
url = optional(string)
# specify distro where SDC will be deployed eg. RHEL, Ubuntu, SLES etc. as case sensitive
linux_distro = string
#allow to build scini on destination machine. This may not work on PowerFlex v3.X. Prerequisites here https://www.dell.com/support/kbdoc/en-us/000224134/how-to-on-demand-compilation-of-the-powerflex-sdc-driver
autobuild_scini = optional(bool, false)
})
}

variable "sdc_pkg" {
description = "configuration for SDC package like url to download package from, copy as local package or directory on remote server. One of local_dir or remote_dir will be used based on the variable use_remote_path"
type = object({
# examples "http://example.com/EMC-ScaleIO-sdc-3.6-700.103.Ubuntu.22.04.x86_64.tar", "ftp://username:password@ftpserver/path/to/file"
url = string
pkg_name = string
url = optional(string)
#the name of the SDC package for local.
pkg_name = optional(string)
#the name of the SDC package for remote machine. It should be emc-sdc-package.(tar/rpm)
remote_pkg_name = optional(string)
local_dir = string
#local directory where the SDC package will be downloaded.
local_dir = optional(string)
#remote directory where the SDC package will be downloaded. (if use_remote_path is true)
remote_dir = optional(string, "/tmp")
# use the SDC package on remote machine path (where SDC is deployed)
use_remote_path = bool
# if SDC package is available in local directory, download can be skipped by setting to true
skip_download_sdc = optional(bool, false)
})
}

Expand Down

0 comments on commit c28261c

Please sign in to comment.