Skip to content

Commit 74d6720

Browse files
committed
Fixes ocp-power-automation#220 Implementation how I did it at another customer. I have tested it again on our local test env and both (git and curl) was working like it should be.
1 parent fd9751e commit 74d6720

File tree

8 files changed

+143
-14
lines changed

8 files changed

+143
-14
lines changed

docs/var.tfvars-doc.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,36 @@ This variable can be used for trying out custom OpenShift install image for deve
179179
release_image_override = ""
180180
```
181181

182-
These variables specify the ansible playbooks that are used for OpenShift install and post-install customizations.
182+
These variables specify the ansible playbooks that are used for OpenShift install and post-install customizations. If the URL starts with the tag `git:`, then it is assumed that it points to a GitHub server and git clone and git checkout will be used. URLs without this tag and starting with http:/https: will be interpreted as standard web servers and curl will be used to download the packages.
183+
`Only .tar.gz, or .tgz are supported formats on web servers and must be contain a complete git clone of the corresponding project!`
184+
Valid options: Requires a URL pointing to the packages/GitHub project.
183185
```
184-
helpernode_repo = "https://github.com/RedHatOfficial/ocp4-helpernode"
186+
helpernode_repo = "https://<HTTP SERVER>/ocp4-ansible-modules/ocp4-helpernode-latest.tar.gz"
187+
OR
188+
helpernode_repo = "git:https://github.com/RedHatOfficial/ocp4-helpernode"
185189
helpernode_tag = "5eab3db53976bb16be582f2edc2de02f7510050d"
186-
install_playbook_repo = "https://github.com/ocp-power-automation/ocp4-playbooks"
190+
191+
install_playbook_repo = "https://<HTTP SERVER>/ocp4-ansible-modules/ocp4-playbooks-latest.tar.gz"
192+
OR
193+
install_playbook_repo = "git:https://github.com/ocp-power-automation/ocp4-playbooks"
187194
install_playbook_tag = "02a598faa332aa2c3d53e8edd0e840440ff74bd5"
195+
helm_repo = "https://<HTTP SERVER>/python-modules/helm-latest-linux-ppc64le.tar.gz"
196+
```
197+
198+
If you want to provide the ansible playbooks by your local HTTP server, follow these steps to clone both git repositories:
199+
```
200+
git clone https://github.com/RedHatOfficial/ocp4-helpernode
201+
tar czvf ocp4-helpernode.tgz ocp4-helpernode
202+
cp ocp4-helpernode.tgz /var/www/html/repos/
203+
204+
git clone https://github.com/ocp-power-automation/ocp4-playbooks
205+
tar czvf ocp4-playbooks.tgz ocp4-playbooks
206+
cp ocp4-playbooks.tgz /var/www/html/repos/
207+
208+
ls -la /var/www/html/repos/
209+
total 13452
210+
-rw-r--r--. 1 root root 13624204 Jul 8 13:43 ocp4-helpernode.tgz
211+
-rw-r--r--. 1 root root 145165 Jul 8 13:44 ocp4-playbooks.tgz
188212
```
189213

190214
These variables can be used when debugging ansible playbooks

modules/3_helpernode/helpernode.tf

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ locals {
6767
]
6868

6969
local_registry = local.local_registry
70+
helm_repo = var.helm_repo
7071
client_tarball = var.openshift_client_tarball
7172
install_tarball = var.openshift_install_tarball
7273
}
@@ -75,12 +76,12 @@ locals {
7576
}
7677
}
7778

78-
resource "null_resource" "config" {
79-
79+
resource "null_resource" "prep_helpernode_tools_git" {
8080
triggers = {
8181
bootstrap_count = var.bootstrap_port_ip == "" ? 0 : 1
8282
worker_count = length(var.worker_port_ips)
8383
}
84+
count = length(regexall("^git:", var.helpernode_repo)) > 0 ? 1 : 0
8485

8586
connection {
8687
type = "ssh"
@@ -94,13 +95,61 @@ resource "null_resource" "config" {
9495

9596
provisioner "remote-exec" {
9697
inline = [
97-
"mkdir -p .openshift",
9898
"rm -rf ocp4-helpernode",
9999
"echo 'Cloning into ocp4-helpernode...'",
100-
"git clone ${var.helpernode_repo} --quiet",
100+
"git clone ${replace(var.helpernode_repo, "/^git:/", "")} --quiet",
101101
"cd ocp4-helpernode && git checkout ${var.helpernode_tag}"
102102
]
103103
}
104+
}
105+
106+
resource "null_resource" "prep_helpernode_tools_curl" {
107+
triggers = {
108+
bootstrap_count = var.bootstrap_port_ip == "" ? 0 : 1
109+
worker_count = length(var.worker_port_ips)
110+
}
111+
count = length(regexall("^http:|^https:", var.helpernode_repo)) > 0 ? 1 : 0
112+
113+
connection {
114+
type = "ssh"
115+
user = var.rhel_username
116+
host = var.bastion_ip[0]
117+
private_key = var.private_key
118+
agent = var.ssh_agent
119+
timeout = "${var.connection_timeout}m"
120+
bastion_host = var.jump_host
121+
}
122+
123+
provisioner "remote-exec" {
124+
inline = [
125+
"rm -rf ocp4-helpernode",
126+
"echo 'Downloading ocp4-helpernode...'",
127+
"curl -o ocp4-helpernode.tar.gz ${var.helpernode_repo}",
128+
"echo 'Extracting ocp4-helpernode...'",
129+
"tar zxvf ocp4-helpernode.tar.gz",
130+
"rm ocp4-helpernode.tar.gz",
131+
"cd ocp4-helpernode && git checkout ${var.helpernode_tag}"
132+
]
133+
}
134+
}
135+
136+
resource "null_resource" "config" {
137+
depends_on = [null_resource.prep_helpernode_tools_git, null_resource.prep_helpernode_tools_curl]
138+
triggers = {
139+
bootstrap_count = var.bootstrap_port_ip == "" ? 0 : 1
140+
worker_count = length(var.worker_port_ips)
141+
}
142+
143+
connection {
144+
type = "ssh"
145+
user = var.rhel_username
146+
host = var.bastion_ip[0]
147+
private_key = var.private_key
148+
agent = var.ssh_agent
149+
timeout = "${var.connection_timeout}m"
150+
bastion_host = var.jump_host
151+
}
152+
104153
provisioner "file" {
105154
content = templatefile("${path.module}/templates/helpernode_inventory", local.helpernode_inventory)
106155
destination = "$HOME/ocp4-helpernode/inventory"

modules/3_helpernode/templates/helpernode_vars.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ ocp_initramfs: "file:///dev/null"
8484
ocp_install_kernel: "file:///dev/null"
8585

8686
# This is required for latest helpernode. TODO: Remove when https://github.com/RedHatOfficial/ocp4-helpernode/pull/140 is merged
87-
helm_source: "https://get.helm.sh/helm-v3.4.0-linux-ppc64le.tar.gz"
87+
helm_source: "${helm_repo}"

modules/3_helpernode/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ variable "ocp_release_tag" {}
5858

5959
variable "helpernode_repo" {}
6060
variable "helpernode_tag" {}
61+
variable "helm_repo" {}
6162

6263
variable "ansible_extra_options" {}
6364

modules/5_install/install.tf

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ locals {
7373
}
7474
}
7575

76-
resource "null_resource" "install" {
76+
resource "null_resource" "prep_playbooks_tools_git" {
7777
triggers = {
7878
worker_count = length(var.worker_ips)
7979
}
80+
count = length(regexall("^git:", var.install_playbook_repo)) > 0 ? 1 : 0
8081

8182
connection {
8283
type = "ssh"
@@ -92,10 +93,57 @@ resource "null_resource" "install" {
9293
inline = [
9394
"rm -rf ocp4-playbooks",
9495
"echo 'Cloning into ocp4-playbooks...'",
95-
"git clone ${var.install_playbook_repo} --quiet",
96+
"git clone ${replace(var.install_playbook_repo, "/^git:/", "")} --quiet",
97+
"cd ocp4-playbooks && git checkout ${var.install_playbook_tag}"
98+
]
99+
}
100+
}
101+
102+
resource "null_resource" "prep_playbooks_tools_curl" {
103+
triggers = {
104+
worker_count = length(var.worker_ips)
105+
}
106+
count = length(regexall("^http:|^https:", var.install_playbook_repo)) > 0 ? 1 : 0
107+
108+
connection {
109+
type = "ssh"
110+
user = var.rhel_username
111+
host = var.bastion_ip[0]
112+
private_key = var.private_key
113+
agent = var.ssh_agent
114+
timeout = "${var.connection_timeout}m"
115+
bastion_host = var.jump_host
116+
}
117+
118+
provisioner "remote-exec" {
119+
inline = [
120+
"rm -rf ocp4-playbooks",
121+
"echo 'Downloading ocp4-playbooks...'",
122+
"curl -o ocp4-playbooks.tar.gz ${var.install_playbook_repo}",
123+
"echo 'Extracting ocp4-playbooks...'",
124+
"tar zxvf ocp4-playbooks.tar.gz",
125+
"rm ocp4-playbooks.tar.gz",
96126
"cd ocp4-playbooks && git checkout ${var.install_playbook_tag}"
97127
]
98128
}
129+
}
130+
131+
resource "null_resource" "install" {
132+
depends_on = [null_resource.prep_playbooks_tools_git, null_resource.prep_playbooks_tools_curl]
133+
triggers = {
134+
worker_count = length(var.worker_ips)
135+
}
136+
137+
connection {
138+
type = "ssh"
139+
user = var.rhel_username
140+
host = var.bastion_ip[0]
141+
private_key = var.private_key
142+
agent = var.ssh_agent
143+
timeout = "${var.connection_timeout}m"
144+
bastion_host = var.jump_host
145+
}
146+
99147
provisioner "file" {
100148
content = templatefile("${path.module}/templates/install_inventory", local.install_inventory)
101149
destination = "$HOME/ocp4-playbooks/inventory"

ocp.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ module "helpernode" {
111111
ocp_release_tag = var.ocp_release_tag
112112
helpernode_repo = var.helpernode_repo
113113
helpernode_tag = var.helpernode_tag
114+
helm_repo = var.helm_repo
114115
ansible_extra_options = var.ansible_extra_options
115116
chrony_config = var.chrony_config
116117
chrony_config_servers = var.chrony_config_servers

var.tfvars

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ cluster_id = "" # It will use random generated id with
5757
#release_image_override = ""
5858

5959

60-
#helpernode_repo = "https://github.com/RedHatOfficial/ocp4-helpernode"
60+
#helpernode_repo = "git:https://github.com/RedHatOfficial/ocp4-helpernode"
6161
#helpernode_tag = ""
62-
#install_playbook_repo = "https://github.com/ocp-power-automation/ocp4-playbooks"
62+
#install_playbook_repo = "git:https://github.com/ocp-power-automation/ocp4-playbooks"
6363
#install_playbook_tag = ""
64+
#helm_repo = "https://get.helm.sh/helm-v3.4.0-linux-ppc64le.tar.gz"
6465

6566
#installer_log_level = "info"
6667
#ansible_extra_options = "-v"

variables.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ variable "installer_log_level" {
257257
variable "helpernode_repo" {
258258
description = "Set the repo URL for using ocp4-helpernode"
259259
# Repo for running ocp4 helpernode setup steps.
260-
default = "https://github.com/RedHatOfficial/ocp4-helpernode"
260+
default = "git:https://github.com/RedHatOfficial/ocp4-helpernode"
261261
}
262262

263263
variable "helpernode_tag" {
@@ -269,7 +269,7 @@ variable "helpernode_tag" {
269269
variable "install_playbook_repo" {
270270
description = "Set the repo URL for using ocp4-playbooks"
271271
# Repo for running ocp4 installations steps.
272-
default = "https://github.com/ocp-power-automation/ocp4-playbooks"
272+
default = "git:https://github.com/ocp-power-automation/ocp4-playbooks"
273273
}
274274

275275
variable "install_playbook_tag" {
@@ -278,6 +278,11 @@ variable "install_playbook_tag" {
278278
default = "10fec74c9e987b39f7af1127abe304a9e41f8e65"
279279
}
280280

281+
variable "helm_repo" {
282+
description = "Set the URL after http_server_repo_main_dir pointing to the Python helm modules"
283+
default = "https://get.helm.sh/helm-v3.4.0-linux-ppc64le.tar.gz"
284+
}
285+
281286
variable "ansible_extra_options" {
282287
description = "Extra options string to append to ansible-playbook commands"
283288
default = "-v"

0 commit comments

Comments
 (0)