Skip to content

Commit 12e9a23

Browse files
authored
Merge pull request #39 from sap-linuxlab/dev
1.0.0 release qa
2 parents 9389660 + 0d6237d commit 12e9a23

13 files changed

+325
-38
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: 68 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,73 @@ 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+
count = var.module_var_web_proxy_enable ? 1 : 0
47+
48+
connection {
49+
type = "ssh"
50+
user = "root"
51+
host = openstack_compute_instance_v2.host_provision.access_ip_v4
52+
private_key = var.module_var_host_private_ssh_key
53+
54+
# Required when using RHEL 8.x because /tmp is set with noexec
55+
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
56+
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
57+
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
58+
}
59+
60+
# Execute, including all files provisioned by Terraform into $HOME
61+
provisioner "remote-exec" {
62+
inline = [
63+
"$HOME/terraform_web_proxy_noninteractive.sh"
64+
]
65+
}
66+
67+
}
68+
69+
70+
resource "null_resource" "execute_os_scripts_os_vendor" {
71+
72+
depends_on = [
73+
null_resource.build_script_os_prepare,
74+
null_resource.os_subscription_files,
75+
openstack_compute_volume_attach_v2.block_volume_attachment,
76+
null_resource.execute_os_scripts_generic,
77+
null_resource.execute_os_scripts_web_proxy
78+
]
79+
80+
count = var.module_var_os_vendor_enable ? 1 : 0
81+
82+
connection {
83+
type = "ssh"
84+
user = "root"
85+
host = openstack_compute_instance_v2.host_provision.access_ip_v4
86+
private_key = var.module_var_host_private_ssh_key
87+
88+
# Required when using RHEL 8.x because /tmp is set with noexec
89+
# Path must already exist and must not use Bash shell special variable, e.g. cannot use $HOME/terraform/tmp/
90+
# https://www.terraform.io/language/resources/provisioners/connection#executing-scripts-using-ssh-scp
91+
script_path = "/root/terraform_tmp_remote_exec_inline.sh"
92+
}
93+
94+
# Execute, including all files provisioned by Terraform into $HOME
95+
provisioner "remote-exec" {
96+
inline = [
3297
"$HOME/terraform_os_subscriptions.sh"
3398
]
3499
}

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
}

0 commit comments

Comments
 (0)