Skip to content

Commit b7f2794

Browse files
committed
fix: optional run of web proxy and os vendor
1 parent 8f46fa7 commit b7f2794

File tree

8 files changed

+161
-6
lines changed

8 files changed

+161
-6
lines changed

ibmpowervc/host_provision/build_execution.tf

Lines changed: 64 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Execute all scripts pushed to target
33

4-
resource "null_resource" "execute_os_scripts" {
4+
resource "null_resource" "execute_os_scripts_generic" {
55

66
depends_on = [
77
null_resource.build_script_os_prepare,
@@ -27,8 +27,69 @@ resource "null_resource" "execute_os_scripts" {
2727
"echo 'Show HOME directory for reference Shell scripts were transferred'",
2828
"ls -lha $HOME",
2929
"chmod +x $HOME/terraform_*",
30-
"$HOME/terraform_os_prep.sh",
31-
"$HOME/terraform_web_proxy_noninteractive.sh",
30+
"$HOME/terraform_os_prep.sh"
31+
]
32+
}
33+
34+
}
35+
36+
37+
resource "null_resource" "execute_os_scripts_web_proxy" {
38+
39+
depends_on = [
40+
null_resource.build_script_os_prepare,
41+
null_resource.os_subscription_files,
42+
openstack_compute_volume_attach_v2.block_volume_attachment,
43+
null_resource.execute_os_scripts_generic
44+
]
45+
46+
connection {
47+
type = "ssh"
48+
user = "root"
49+
host = openstack_compute_instance_v2.host_provision.access_ip_v4
50+
private_key = var.module_var_host_private_ssh_key
51+
52+
# Required when using RHEL 8.x because /tmp is set with noexec
53+
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
54+
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
55+
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
56+
}
57+
58+
# Execute, including all files provisioned by Terraform into $HOME
59+
provisioner "remote-exec" {
60+
inline = [
61+
"$HOME/terraform_web_proxy_noninteractive.sh"
62+
]
63+
}
64+
65+
}
66+
67+
68+
resource "null_resource" "execute_os_scripts_os_vendor" {
69+
70+
depends_on = [
71+
null_resource.build_script_os_prepare,
72+
null_resource.os_subscription_files,
73+
openstack_compute_volume_attach_v2.block_volume_attachment,
74+
null_resource.execute_os_scripts_generic,
75+
null_resource.execute_os_scripts_web_proxy
76+
]
77+
78+
connection {
79+
type = "ssh"
80+
user = "root"
81+
host = openstack_compute_instance_v2.host_provision.access_ip_v4
82+
private_key = var.module_var_host_private_ssh_key
83+
84+
# Required when using RHEL 8.x because /tmp is set with noexec
85+
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
86+
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
87+
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
88+
}
89+
90+
# Execute, including all files provisioned by Terraform into $HOME
91+
provisioner "remote-exec" {
92+
inline = [
3293
"$HOME/terraform_os_subscriptions.sh"
3394
]
3495
}

ibmpowervc/host_provision/build_os_subscriptions.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ resource "null_resource" "os_subscription_files" {
77
openstack_compute_volume_attach_v2.block_volume_attachment
88
]
99

10+
count = var.module_var_os_vendor_enable ? 1 : 0
11+
1012
connection {
1113
type = "ssh"
1214
user = "root"

ibmpowervc/host_provision/build_web_proxy_noninteractive.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ resource "null_resource" "build_script_web_proxy_noninteractive" {
55
openstack_compute_volume_attach_v2.block_volume_attachment
66
]
77

8+
count = var.module_var_web_proxy_enable ? 1 : 0
9+
810
# Specify the ssh connection
911
connection {
1012
type = "ssh"

ibmpowervc/host_provision/module_variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,16 @@ variable "module_var_lpar_hostname" {
5252
variable "module_var_dns_root_domain_name" {
5353
}
5454

55+
56+
variable "module_var_web_proxy_enable" {
57+
default = true
58+
}
5559
variable "module_var_web_proxy_url" {}
5660
variable "module_var_web_proxy_exclusion" {}
5761

62+
variable "module_var_os_vendor_enable" {
63+
default = true
64+
}
5865
variable "module_var_os_vendor_account_user" {}
5966
variable "module_var_os_vendor_account_user_passcode" {}
6067
variable "module_var_os_systems_mgmt_host" {

vmware_vm/host_provision/build_execution.tf

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Execute all scripts pushed to target
33

4-
resource "null_resource" "execute_os_scripts" {
4+
resource "null_resource" "execute_os_scripts_generic" {
55

66
depends_on = [
77
vsphere_virtual_disk.virtual_disk_provision,
@@ -29,8 +29,77 @@ resource "null_resource" "execute_os_scripts" {
2929
"echo 'Show HOME directory for reference Shell scripts were transferred'",
3030
"ls -lha $HOME",
3131
"chmod +x $HOME/terraform_*",
32-
"$HOME/terraform_os_prep.sh",
33-
"$HOME/terraform_web_proxy_noninteractive.sh",
32+
"$HOME/terraform_os_prep.sh"
33+
]
34+
}
35+
36+
}
37+
38+
39+
resource "null_resource" "execute_os_scripts_web_proxy" {
40+
41+
depends_on = [
42+
vsphere_virtual_disk.virtual_disk_provision,
43+
null_resource.build_script_os_prepare,
44+
null_resource.os_subscription_files,
45+
vsphere_virtual_machine.host_provision,
46+
null_resource.execute_os_scripts_generic
47+
]
48+
49+
count = var.module_var_web_proxy_enable ? 1 : 0
50+
51+
connection {
52+
type = "ssh"
53+
user = "root"
54+
host = vsphere_virtual_machine.host_provision.default_ip_address
55+
private_key = var.module_var_host_private_ssh_key
56+
timeout = "30s"
57+
58+
# Required when using RHEL 8.x because /tmp is set with noexec
59+
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
60+
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
61+
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
62+
}
63+
64+
# Execute, including all files provisioned by Terraform into $HOME
65+
provisioner "remote-exec" {
66+
inline = [
67+
"$HOME/terraform_web_proxy_noninteractive.sh"
68+
]
69+
}
70+
71+
}
72+
73+
74+
resource "null_resource" "execute_os_scripts_os_vendor" {
75+
76+
depends_on = [
77+
vsphere_virtual_disk.virtual_disk_provision,
78+
null_resource.build_script_os_prepare,
79+
null_resource.os_subscription_files,
80+
vsphere_virtual_machine.host_provision,
81+
null_resource.execute_os_scripts_generic,
82+
null_resource.execute_os_scripts_web_proxy
83+
]
84+
85+
count = var.module_var_os_vendor_enable ? 1 : 0
86+
87+
connection {
88+
type = "ssh"
89+
user = "root"
90+
host = vsphere_virtual_machine.host_provision.default_ip_address
91+
private_key = var.module_var_host_private_ssh_key
92+
timeout = "30s"
93+
94+
# Required when using RHEL 8.x because /tmp is set with noexec
95+
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
96+
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
97+
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
98+
}
99+
100+
# Execute, including all files provisioned by Terraform into $HOME
101+
provisioner "remote-exec" {
102+
inline = [
34103
"$HOME/terraform_os_subscriptions.sh"
35104
]
36105
}

vmware_vm/host_provision/build_os_subscriptions.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ resource "null_resource" "os_subscription_files" {
77
vsphere_virtual_machine.host_provision
88
]
99

10+
count = var.module_var_os_vendor_enable ? 1 : 0
11+
1012
connection {
1113
type = "ssh"
1214
user = "root"

vmware_vm/host_provision/build_web_proxy_noninteractive.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ resource "null_resource" "build_script_web_proxy_noninteractive" {
55
vsphere_virtual_machine.host_provision
66
]
77

8+
count = var.module_var_web_proxy_enable ? 1 : 0
9+
810
# Specify the ssh connection
911
connection {
1012
type = "ssh"

vmware_vm/host_provision/module_variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,23 @@ variable "module_var_host_public_ssh_key" {}
5353

5454
variable "module_var_host_private_ssh_key" {}
5555

56+
57+
variable "module_var_web_proxy_enable" {
58+
default = true
59+
}
60+
5661
variable "module_var_web_proxy_url" {}
5762
variable "module_var_web_proxy_exclusion" {}
5863

64+
variable "module_var_os_vendor_enable" {
65+
default = true
66+
}
67+
5968
variable "module_var_os_vendor_account_user" {}
6069
variable "module_var_os_vendor_account_user_passcode" {}
6170
variable "module_var_os_systems_mgmt_host" {
6271
default = ""
6372
}
6473

74+
6575
variable "module_var_storage_definition" {}

0 commit comments

Comments
 (0)