1
1
2
2
# Execute all scripts pushed to target
3
3
4
- resource "null_resource" "execute_os_scripts " {
4
+ resource "null_resource" "execute_os_scripts_generic " {
5
5
6
6
depends_on = [
7
7
null_resource. build_script_os_prepare ,
@@ -16,9 +16,135 @@ resource "null_resource" "execute_os_scripts" {
16
16
" echo 'Show HOME directory for reference Shell scripts were transferred'" ,
17
17
" ls -lha $HOME" ,
18
18
" 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 = [
22
148
" echo 'Change DNS in resolv.conf'" ,
23
149
" if [ -f /tmp/resolv.conf ]; then mv /etc/resolv.conf /etc/resolv.conf.backup && mv /tmp/resolv.conf /etc/ ; fi" ,
24
150
" chmod 644 /etc/resolv.conf" ,
0 commit comments