diff --git a/docs/var.tfvars-doc.md b/docs/var.tfvars-doc.md index b680b97c0a..e8d2794865 100644 --- a/docs/var.tfvars-doc.md +++ b/docs/var.tfvars-doc.md @@ -179,12 +179,38 @@ This variable can be used for trying out custom OpenShift install image for deve release_image_override = "" ``` -These variables specify the ansible playbooks that are used for OpenShift install and post-install customizations. +These variables specify the ansible playbooks that are used for OpenShift install and post-install customizations. If the URL ends with a file name extension .zip, then it is assumed that it points to a HTTP/HTTPS server and curl/unzip will be used to extract the package. URLs without ending with .zip are recognized as GitHub repositories and git clone && git checkout are used. +`Only .zip is supported file format on web servers. The all files must be placed in folders starting with ocp4-playbooks, or ocp4-helpernode! It is allowed to extend the directory name with additional informations: e.g. ocp4-helpernode- 0 ? 1 : 0 + + connection { + type = "ssh" + user = var.rhel_username + host = var.bastion_ip[0] + private_key = var.private_key + agent = var.ssh_agent + timeout = "${var.connection_timeout}m" + bastion_host = var.jump_host + } + + provisioner "remote-exec" { + inline = [ + "mkdir -p .openshift", + "rm -rf ocp4-helpernode", + "rm -rf ocp4-extract-helper", + "mkdir -p ocp4-extract-helper", + "echo 'Downloading ocp4-helpernode...'", + "curl -o ocp4-extract-helper/ocp4-helpernode.zip ${var.helpernode_repo}", + "echo 'Extracting ocp4-helpernode...'", + "cd ocp4-extract-helper && unzip ocp4-helpernode.zip", + "rm -rf ocp4-extract-helper/ocp4-helpernode.zip", + "mv ocp4-extract-helper/ocp4-helpernode* ocp4-helpernode", + "rm -rf ocp4-extract-helper" + ] + } +} + +resource "null_resource" "config" { + depends_on = [null_resource.prep_helpernode_tools_git, null_resource.prep_helpernode_tools_curl] + triggers = { + bootstrap_count = var.bootstrap_port_ip == "" ? 0 : 1 + worker_count = length(var.worker_port_ips) + } + + connection { + type = "ssh" + user = var.rhel_username + host = var.bastion_ip[0] + private_key = var.private_key + agent = var.ssh_agent + timeout = "${var.connection_timeout}m" + bastion_host = var.jump_host + } + provisioner "file" { content = templatefile("${path.module}/templates/helpernode_inventory", local.helpernode_inventory) destination = "$HOME/ocp4-helpernode/inventory" diff --git a/modules/3_helpernode/templates/helpernode_vars.yaml b/modules/3_helpernode/templates/helpernode_vars.yaml index 5f3edc414c..2908dc3572 100644 --- a/modules/3_helpernode/templates/helpernode_vars.yaml +++ b/modules/3_helpernode/templates/helpernode_vars.yaml @@ -84,4 +84,4 @@ ocp_initramfs: "file:///dev/null" ocp_install_kernel: "file:///dev/null" # This is required for latest helpernode. TODO: Remove when https://github.com/RedHatOfficial/ocp4-helpernode/pull/140 is merged -helm_source: "https://get.helm.sh/helm-v3.4.0-linux-ppc64le.tar.gz" +helm_source: "${helm_repo}" diff --git a/modules/3_helpernode/variables.tf b/modules/3_helpernode/variables.tf index e17d6f869a..138098e966 100644 --- a/modules/3_helpernode/variables.tf +++ b/modules/3_helpernode/variables.tf @@ -58,6 +58,7 @@ variable "ocp_release_tag" {} variable "helpernode_repo" {} variable "helpernode_tag" {} +variable "helm_repo" {} variable "ansible_extra_options" {} diff --git a/modules/5_install/install.tf b/modules/5_install/install.tf index fce5343704..335c05e32e 100644 --- a/modules/5_install/install.tf +++ b/modules/5_install/install.tf @@ -73,10 +73,8 @@ locals { } } -resource "null_resource" "install" { - triggers = { - worker_count = length(var.worker_ips) - } +resource "null_resource" "prep_playbooks_tools_git" { + count = length(regexall("\\.zip$", var.install_playbook_repo)) == 0 ? 1 : 0 connection { type = "ssh" @@ -96,6 +94,53 @@ resource "null_resource" "install" { "cd ocp4-playbooks && git checkout ${var.install_playbook_tag}" ] } +} + +resource "null_resource" "prep_playbooks_tools_curl" { + count = length(regexall("\\.zip$", var.install_playbook_repo)) > 0 ? 1 : 0 + + connection { + type = "ssh" + user = var.rhel_username + host = var.bastion_ip[0] + private_key = var.private_key + agent = var.ssh_agent + timeout = "${var.connection_timeout}m" + bastion_host = var.jump_host + } + + provisioner "remote-exec" { + inline = [ + "rm -rf ocp4-playbooks", + "rm -rf ocp4-extract-helper", + "mkdir -p ocp4-extract-helper", + "echo 'Downloading ocp4-playbooks...'", + "curl -o ocp4-extract-helper/ocp4-playbooks.zip ${var.install_playbook_repo}", + "echo 'Extracting ocp4-playbooks...'", + "cd ocp4-extract-helper && unzip ocp4-playbooks.zip", + "rm -rf ocp4-extract-helper/ocp4-playbooks.zip" + "mv ocp4-extract-helper/ocp4-playbooks* ocp4-playbooks", + "rm -rf ocp4-extract-helper" + ] + } +} + +resource "null_resource" "install" { + depends_on = [null_resource.prep_playbooks_tools_git, null_resource.prep_playbooks_tools_curl] + triggers = { + worker_count = length(var.worker_ips) + } + + connection { + type = "ssh" + user = var.rhel_username + host = var.bastion_ip[0] + private_key = var.private_key + agent = var.ssh_agent + timeout = "${var.connection_timeout}m" + bastion_host = var.jump_host + } + provisioner "file" { content = templatefile("${path.module}/templates/install_inventory", local.install_inventory) destination = "$HOME/ocp4-playbooks/inventory" diff --git a/ocp.tf b/ocp.tf index 54d447c7d4..6b9f0545d0 100644 --- a/ocp.tf +++ b/ocp.tf @@ -111,6 +111,7 @@ module "helpernode" { ocp_release_tag = var.ocp_release_tag helpernode_repo = var.helpernode_repo helpernode_tag = var.helpernode_tag + helm_repo = var.helm_repo ansible_extra_options = var.ansible_extra_options chrony_config = var.chrony_config chrony_config_servers = var.chrony_config_servers diff --git a/var.tfvars b/var.tfvars index ccdc5bddf7..cd4503ea4e 100644 --- a/var.tfvars +++ b/var.tfvars @@ -61,6 +61,7 @@ cluster_id = "" # It will use random generated id with #helpernode_tag = "" #install_playbook_repo = "https://github.com/ocp-power-automation/ocp4-playbooks" #install_playbook_tag = "" +#helm_repo = "https://get.helm.sh/helm-v3.6.3-linux-ppc64le.tar.gz" #installer_log_level = "info" #ansible_extra_options = "-v" diff --git a/variables.tf b/variables.tf index b878c92a10..5047797de9 100644 --- a/variables.tf +++ b/variables.tf @@ -278,6 +278,11 @@ variable "install_playbook_tag" { default = "10fec74c9e987b39f7af1127abe304a9e41f8e65" } +variable "helm_repo" { + description = "Set the URL after http_server_repo_main_dir pointing to the Python helm modules" + default = "https://get.helm.sh/helm-v3.6.3-linux-ppc64le.tar.gz" +} + variable "ansible_extra_options" { description = "Extra options string to append to ansible-playbook commands" default = "-v"