Skip to content

Commit 0d6237d

Browse files
committed
fix: additional optional web proxy and os vendor
1 parent b7f2794 commit 0d6237d

File tree

5 files changed

+145
-6
lines changed

5 files changed

+145
-6
lines changed

ibmcloud_powervs/host_provision/build_execution.tf

Lines changed: 130 additions & 4 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,
@@ -16,9 +16,135 @@ resource "null_resource" "execute_os_scripts" {
1616
"echo 'Show HOME directory for reference Shell scripts were transferred'",
1717
"ls -lha $HOME",
1818
"chmod +x $HOME/terraform_*",
19-
"$HOME/terraform_os_prep.sh",
20-
"$HOME/terraform_web_proxy_noninteractive.sh",
21-
"$HOME/terraform_os_subscriptions.sh",
19+
"$HOME/terraform_os_prep.sh"
20+
]
21+
}
22+
23+
# Specify the ssh connection
24+
connection {
25+
# The Bastion host ssh connection is established first, and then the host connection will be made from there.
26+
# Checking Host Key is false when not using bastion_host_key
27+
type = "ssh"
28+
user = "root"
29+
host = ibm_pi_instance.host_via_certified_profile.pi_network[0].ip_address
30+
private_key = var.module_var_host_private_ssh_key
31+
bastion_host = var.module_var_bastion_ip
32+
#bastion_host_key =
33+
bastion_port = var.module_var_bastion_ssh_port
34+
bastion_user = var.module_var_bastion_user
35+
bastion_private_key = var.module_var_bastion_private_ssh_key
36+
37+
# Required when using RHEL 8.x because /tmp is set with noexec
38+
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
39+
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
40+
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
41+
}
42+
43+
}
44+
45+
46+
resource "null_resource" "execute_os_scripts_web_proxy" {
47+
48+
depends_on = [
49+
null_resource.build_script_os_prepare,
50+
null_resource.build_script_web_proxy_noninteractive,
51+
null_resource.os_subscription_files,
52+
null_resource.dns_resolv_files,
53+
null_resource.execute_os_scripts_generic
54+
]
55+
56+
count = var.module_var_web_proxy_enable ? 1 : 0
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+
# Specify the ssh connection
67+
connection {
68+
# The Bastion host ssh connection is established first, and then the host connection will be made from there.
69+
# Checking Host Key is false when not using bastion_host_key
70+
type = "ssh"
71+
user = "root"
72+
host = ibm_pi_instance.host_via_certified_profile.pi_network[0].ip_address
73+
private_key = var.module_var_host_private_ssh_key
74+
bastion_host = var.module_var_bastion_ip
75+
#bastion_host_key =
76+
bastion_port = var.module_var_bastion_ssh_port
77+
bastion_user = var.module_var_bastion_user
78+
bastion_private_key = var.module_var_bastion_private_ssh_key
79+
80+
# Required when using RHEL 8.x because /tmp is set with noexec
81+
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
82+
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
83+
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
84+
}
85+
86+
}
87+
88+
89+
resource "null_resource" "execute_os_scripts_os_vendor" {
90+
91+
depends_on = [
92+
null_resource.build_script_os_prepare,
93+
null_resource.build_script_web_proxy_noninteractive,
94+
null_resource.os_subscription_files,
95+
null_resource.dns_resolv_files,
96+
null_resource.execute_os_scripts_generic,
97+
null_resource.execute_os_scripts_web_proxy
98+
]
99+
100+
count = var.module_var_os_vendor_enable ? 1 : 0
101+
102+
# Execute, including all files provisioned by Terraform into $HOME
103+
provisioner "remote-exec" {
104+
inline = [
105+
"$HOME/terraform_os_subscriptions.sh"
106+
]
107+
}
108+
109+
110+
# Specify the ssh connection
111+
connection {
112+
# The Bastion host ssh connection is established first, and then the host connection will be made from there.
113+
# Checking Host Key is false when not using bastion_host_key
114+
type = "ssh"
115+
user = "root"
116+
host = ibm_pi_instance.host_via_certified_profile.pi_network[0].ip_address
117+
private_key = var.module_var_host_private_ssh_key
118+
bastion_host = var.module_var_bastion_ip
119+
#bastion_host_key =
120+
bastion_port = var.module_var_bastion_ssh_port
121+
bastion_user = var.module_var_bastion_user
122+
bastion_private_key = var.module_var_bastion_private_ssh_key
123+
124+
# Required when using RHEL 8.x because /tmp is set with noexec
125+
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
126+
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
127+
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
128+
}
129+
130+
}
131+
132+
133+
resource "null_resource" "execute_os_scripts_dns" {
134+
135+
depends_on = [
136+
null_resource.build_script_os_prepare,
137+
null_resource.build_script_web_proxy_noninteractive,
138+
null_resource.os_subscription_files,
139+
null_resource.dns_resolv_files,
140+
null_resource.execute_os_scripts_generic,
141+
null_resource.execute_os_scripts_web_proxy,
142+
null_resource.execute_os_scripts_os_vendor
143+
]
144+
145+
# Execute, including all files provisioned by Terraform into $HOME
146+
provisioner "remote-exec" {
147+
inline = [
22148
"echo 'Change DNS in resolv.conf'",
23149
"if [ -f /tmp/resolv.conf ]; then mv /etc/resolv.conf /etc/resolv.conf.backup && mv /tmp/resolv.conf /etc/ ; fi",
24150
"chmod 644 /etc/resolv.conf",

ibmcloud_powervs/host_provision/build_os_subscriptions.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
resource "null_resource" "os_subscription_files" {
55

6+
count = var.module_var_os_vendor_enable ? 1 : 0
7+
68
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/file.sh
79
# "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"
810
# https://www.terraform.io/language/resources/provisioners/file#destination-paths

ibmcloud_powervs/host_provision/build_web_proxy_noninteractive.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
resource "null_resource" "build_script_web_proxy_noninteractive" {
33

4+
count = var.module_var_web_proxy_enable ? 1 : 0
5+
46
# Specify the ssh connection
57
connection {
68
# The Bastion host ssh connection is established first, and then the host connection will be made from there.

ibmcloud_powervs/host_provision/module_variables.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,18 @@ variable "module_var_dns_services_instance" {}
4848

4949
variable "module_var_dns_proxy_ip" {}
5050

51-
variable "module_var_web_proxy_url" {}
5251

52+
variable "module_var_web_proxy_enable" {
53+
default = true
54+
}
55+
variable "module_var_web_proxy_url" {}
5356
variable "module_var_web_proxy_exclusion" {}
5457

5558

59+
variable "module_var_os_vendor_enable" {
60+
default = true
61+
}
5662
variable "module_var_os_vendor_account_user" {}
57-
5863
variable "module_var_os_vendor_account_user_passcode" {}
5964

6065
variable "module_var_storage_definition" {}

ibmpowervc/host_provision/build_execution.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ resource "null_resource" "execute_os_scripts_web_proxy" {
4343
null_resource.execute_os_scripts_generic
4444
]
4545

46+
count = var.module_var_web_proxy_enable ? 1 : 0
47+
4648
connection {
4749
type = "ssh"
4850
user = "root"
@@ -75,6 +77,8 @@ resource "null_resource" "execute_os_scripts_os_vendor" {
7577
null_resource.execute_os_scripts_web_proxy
7678
]
7779

80+
count = var.module_var_os_vendor_enable ? 1 : 0
81+
7882
connection {
7983
type = "ssh"
8084
user = "root"

0 commit comments

Comments
 (0)