Skip to content

Commit

Permalink
Merge pull request #39 from sap-linuxlab/dev
Browse files Browse the repository at this point in the history
1.0.0 release qa
  • Loading branch information
sean-freeman authored Feb 1, 2024
2 parents 9389660 + 0d6237d commit 12e9a23
Show file tree
Hide file tree
Showing 13 changed files with 325 additions and 38 deletions.
134 changes: 130 additions & 4 deletions ibmcloud_powervs/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 @@ -16,9 +16,135 @@ 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_subscriptions.sh",
"$HOME/terraform_os_prep.sh"
]
}

# Specify the ssh connection
connection {
# The Bastion host ssh connection is established first, and then the host connection will be made from there.
# Checking Host Key is false when not using bastion_host_key
type = "ssh"
user = "root"
host = ibm_pi_instance.host_via_certified_profile.pi_network[0].ip_address
private_key = var.module_var_host_private_ssh_key
bastion_host = var.module_var_bastion_ip
#bastion_host_key =
bastion_port = var.module_var_bastion_ssh_port
bastion_user = var.module_var_bastion_user
bastion_private_key = var.module_var_bastion_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"
}

}


resource "null_resource" "execute_os_scripts_web_proxy" {

depends_on = [
null_resource.build_script_os_prepare,
null_resource.build_script_web_proxy_noninteractive,
null_resource.os_subscription_files,
null_resource.dns_resolv_files,
null_resource.execute_os_scripts_generic
]

count = var.module_var_web_proxy_enable ? 1 : 0

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


# Specify the ssh connection
connection {
# The Bastion host ssh connection is established first, and then the host connection will be made from there.
# Checking Host Key is false when not using bastion_host_key
type = "ssh"
user = "root"
host = ibm_pi_instance.host_via_certified_profile.pi_network[0].ip_address
private_key = var.module_var_host_private_ssh_key
bastion_host = var.module_var_bastion_ip
#bastion_host_key =
bastion_port = var.module_var_bastion_ssh_port
bastion_user = var.module_var_bastion_user
bastion_private_key = var.module_var_bastion_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"
}

}


resource "null_resource" "execute_os_scripts_os_vendor" {

depends_on = [
null_resource.build_script_os_prepare,
null_resource.build_script_web_proxy_noninteractive,
null_resource.os_subscription_files,
null_resource.dns_resolv_files,
null_resource.execute_os_scripts_generic,
null_resource.execute_os_scripts_web_proxy
]

count = var.module_var_os_vendor_enable ? 1 : 0

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


# Specify the ssh connection
connection {
# The Bastion host ssh connection is established first, and then the host connection will be made from there.
# Checking Host Key is false when not using bastion_host_key
type = "ssh"
user = "root"
host = ibm_pi_instance.host_via_certified_profile.pi_network[0].ip_address
private_key = var.module_var_host_private_ssh_key
bastion_host = var.module_var_bastion_ip
#bastion_host_key =
bastion_port = var.module_var_bastion_ssh_port
bastion_user = var.module_var_bastion_user
bastion_private_key = var.module_var_bastion_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"
}

}


resource "null_resource" "execute_os_scripts_dns" {

depends_on = [
null_resource.build_script_os_prepare,
null_resource.build_script_web_proxy_noninteractive,
null_resource.os_subscription_files,
null_resource.dns_resolv_files,
null_resource.execute_os_scripts_generic,
null_resource.execute_os_scripts_web_proxy,
null_resource.execute_os_scripts_os_vendor
]

# Execute, including all files provisioned by Terraform into $HOME
provisioner "remote-exec" {
inline = [
"echo 'Change DNS in resolv.conf'",
"if [ -f /tmp/resolv.conf ]; then mv /etc/resolv.conf /etc/resolv.conf.backup && mv /tmp/resolv.conf /etc/ ; fi",
"chmod 644 /etc/resolv.conf",
Expand Down
2 changes: 2 additions & 0 deletions ibmcloud_powervs/host_provision/build_os_subscriptions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

resource "null_resource" "os_subscription_files" {

count = var.module_var_os_vendor_enable ? 1 : 0

# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/file.sh
# "By default, OpenSSH's scp implementation runs in the remote user's home directory and so you can specify a relative path to upload into that home directory"
# https://www.terraform.io/language/resources/provisioners/file#destination-paths
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

resource "null_resource" "build_script_web_proxy_noninteractive" {

count = var.module_var_web_proxy_enable ? 1 : 0

# Specify the ssh connection
connection {
# The Bastion host ssh connection is established first, and then the host connection will be made from there.
Expand Down
9 changes: 7 additions & 2 deletions ibmcloud_powervs/host_provision/module_variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,18 @@ variable "module_var_dns_services_instance" {}

variable "module_var_dns_proxy_ip" {}

variable "module_var_web_proxy_url" {}

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_storage_definition" {}
71 changes: 68 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,73 @@ 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
]

count = var.module_var_web_proxy_enable ? 1 : 0

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
]

count = var.module_var_os_vendor_enable ? 1 : 0

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
Loading

0 comments on commit 12e9a23

Please sign in to comment.