Skip to content

Commit

Permalink
fix: optional run of web proxy and os vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-freeman committed Feb 1, 2024
1 parent 8f46fa7 commit b7f2794
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 6 deletions.
67 changes: 64 additions & 3 deletions ibmpowervc/host_provision/build_execution.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Execute all scripts pushed to target

resource "null_resource" "execute_os_scripts" {
resource "null_resource" "execute_os_scripts_generic" {

depends_on = [
null_resource.build_script_os_prepare,
Expand All @@ -27,8 +27,69 @@ resource "null_resource" "execute_os_scripts" {
"echo 'Show HOME directory for reference Shell scripts were transferred'",
"ls -lha $HOME",
"chmod +x $HOME/terraform_*",
"$HOME/terraform_os_prep.sh",
"$HOME/terraform_web_proxy_noninteractive.sh",
"$HOME/terraform_os_prep.sh"
]
}

}


resource "null_resource" "execute_os_scripts_web_proxy" {

depends_on = [
null_resource.build_script_os_prepare,
null_resource.os_subscription_files,
openstack_compute_volume_attach_v2.block_volume_attachment,
null_resource.execute_os_scripts_generic
]

connection {
type = "ssh"
user = "root"
host = openstack_compute_instance_v2.host_provision.access_ip_v4
private_key = var.module_var_host_private_ssh_key

# Required when using RHEL 8.x because /tmp is set with noexec
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
}

# Execute, including all files provisioned by Terraform into $HOME
provisioner "remote-exec" {
inline = [
"$HOME/terraform_web_proxy_noninteractive.sh"
]
}

}


resource "null_resource" "execute_os_scripts_os_vendor" {

depends_on = [
null_resource.build_script_os_prepare,
null_resource.os_subscription_files,
openstack_compute_volume_attach_v2.block_volume_attachment,
null_resource.execute_os_scripts_generic,
null_resource.execute_os_scripts_web_proxy
]

connection {
type = "ssh"
user = "root"
host = openstack_compute_instance_v2.host_provision.access_ip_v4
private_key = var.module_var_host_private_ssh_key

# Required when using RHEL 8.x because /tmp is set with noexec
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
}

# Execute, including all files provisioned by Terraform into $HOME
provisioner "remote-exec" {
inline = [
"$HOME/terraform_os_subscriptions.sh"
]
}
Expand Down
2 changes: 2 additions & 0 deletions ibmpowervc/host_provision/build_os_subscriptions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ resource "null_resource" "os_subscription_files" {
openstack_compute_volume_attach_v2.block_volume_attachment
]

count = var.module_var_os_vendor_enable ? 1 : 0

connection {
type = "ssh"
user = "root"
Expand Down
2 changes: 2 additions & 0 deletions ibmpowervc/host_provision/build_web_proxy_noninteractive.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ resource "null_resource" "build_script_web_proxy_noninteractive" {
openstack_compute_volume_attach_v2.block_volume_attachment
]

count = var.module_var_web_proxy_enable ? 1 : 0

# Specify the ssh connection
connection {
type = "ssh"
Expand Down
7 changes: 7 additions & 0 deletions ibmpowervc/host_provision/module_variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,16 @@ variable "module_var_lpar_hostname" {
variable "module_var_dns_root_domain_name" {
}


variable "module_var_web_proxy_enable" {
default = true
}
variable "module_var_web_proxy_url" {}
variable "module_var_web_proxy_exclusion" {}

variable "module_var_os_vendor_enable" {
default = true
}
variable "module_var_os_vendor_account_user" {}
variable "module_var_os_vendor_account_user_passcode" {}
variable "module_var_os_systems_mgmt_host" {
Expand Down
75 changes: 72 additions & 3 deletions vmware_vm/host_provision/build_execution.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Execute all scripts pushed to target

resource "null_resource" "execute_os_scripts" {
resource "null_resource" "execute_os_scripts_generic" {

depends_on = [
vsphere_virtual_disk.virtual_disk_provision,
Expand Down Expand Up @@ -29,8 +29,77 @@ resource "null_resource" "execute_os_scripts" {
"echo 'Show HOME directory for reference Shell scripts were transferred'",
"ls -lha $HOME",
"chmod +x $HOME/terraform_*",
"$HOME/terraform_os_prep.sh",
"$HOME/terraform_web_proxy_noninteractive.sh",
"$HOME/terraform_os_prep.sh"
]
}

}


resource "null_resource" "execute_os_scripts_web_proxy" {

depends_on = [
vsphere_virtual_disk.virtual_disk_provision,
null_resource.build_script_os_prepare,
null_resource.os_subscription_files,
vsphere_virtual_machine.host_provision,
null_resource.execute_os_scripts_generic
]

count = var.module_var_web_proxy_enable ? 1 : 0

connection {
type = "ssh"
user = "root"
host = vsphere_virtual_machine.host_provision.default_ip_address
private_key = var.module_var_host_private_ssh_key
timeout = "30s"

# Required when using RHEL 8.x because /tmp is set with noexec
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
}

# Execute, including all files provisioned by Terraform into $HOME
provisioner "remote-exec" {
inline = [
"$HOME/terraform_web_proxy_noninteractive.sh"
]
}

}


resource "null_resource" "execute_os_scripts_os_vendor" {

depends_on = [
vsphere_virtual_disk.virtual_disk_provision,
null_resource.build_script_os_prepare,
null_resource.os_subscription_files,
vsphere_virtual_machine.host_provision,
null_resource.execute_os_scripts_generic,
null_resource.execute_os_scripts_web_proxy
]

count = var.module_var_os_vendor_enable ? 1 : 0

connection {
type = "ssh"
user = "root"
host = vsphere_virtual_machine.host_provision.default_ip_address
private_key = var.module_var_host_private_ssh_key
timeout = "30s"

# Required when using RHEL 8.x because /tmp is set with noexec
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
}

# Execute, including all files provisioned by Terraform into $HOME
provisioner "remote-exec" {
inline = [
"$HOME/terraform_os_subscriptions.sh"
]
}
Expand Down
2 changes: 2 additions & 0 deletions vmware_vm/host_provision/build_os_subscriptions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ resource "null_resource" "os_subscription_files" {
vsphere_virtual_machine.host_provision
]

count = var.module_var_os_vendor_enable ? 1 : 0

connection {
type = "ssh"
user = "root"
Expand Down
2 changes: 2 additions & 0 deletions vmware_vm/host_provision/build_web_proxy_noninteractive.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ resource "null_resource" "build_script_web_proxy_noninteractive" {
vsphere_virtual_machine.host_provision
]

count = var.module_var_web_proxy_enable ? 1 : 0

# Specify the ssh connection
connection {
type = "ssh"
Expand Down
10 changes: 10 additions & 0 deletions vmware_vm/host_provision/module_variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,23 @@ variable "module_var_host_public_ssh_key" {}

variable "module_var_host_private_ssh_key" {}


variable "module_var_web_proxy_enable" {
default = true
}

variable "module_var_web_proxy_url" {}
variable "module_var_web_proxy_exclusion" {}

variable "module_var_os_vendor_enable" {
default = true
}

variable "module_var_os_vendor_account_user" {}
variable "module_var_os_vendor_account_user_passcode" {}
variable "module_var_os_systems_mgmt_host" {
default = ""
}


variable "module_var_storage_definition" {}

0 comments on commit b7f2794

Please sign in to comment.