Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplemented and merged code for #220 #244

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion docs/var.tfvars-doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,44 @@ 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-<master/version number)`
Valid options: Requires a URL pointing to the packages/GitHub project.
```
helpernode_repo = "https://<HTTP SERVER>/ocp4-ansible-modules/ocp4-helpernode-master.zip"
OR
helpernode_repo = "https://github.com/RedHatOfficial/ocp4-helpernode"
helpernode_tag = "5eab3db53976bb16be582f2edc2de02f7510050d"

install_playbook_repo = "https://<HTTP SERVER>/ocp4-ansible-modules/ocp4-playbooks-master.zip"
OR
install_playbook_repo = "https://github.com/ocp-power-automation/ocp4-playbooks"
install_playbook_tag = "02a598faa332aa2c3d53e8edd0e840440ff74bd5"
```

If you want to provide the ansible playbooks by your local HTTP server, follow these steps:
```
Use your web browser and visit https://github.com/RedHatOfficial/ocp4-helpernode
On the main page, stay on the master repository page, or select any supported branch and click on the green "Code" button with a download symbol in front of it
Click on "Download ZIP"
Upload the file to your local HTTP server and place it in the appropriate directory

Use your web browser and visit https://github.com/ocp-power-automation/ocp4-playbooks
On the main page, stay on the master repository page, or select any supported branch and click on the green "Code" button with a download symbol in front of it
Click on "Download ZIP"
Upload the file to your local HTTP server and place it in the appropriate directory, like the example below

ls -la /var/www/html/repos/
total 13452
-rw-r--r--. 1 root root 13624204 Jul 8 13:43 ocp4-helpernode.zip
-rw-r--r--. 1 root root 145165 Jul 8 13:44 ocp4-playbooks.zip
```

This variable can be used to define a different source for the helm package, like a local web server. By default, the help package will be downloaded from the official internet source.
```
helm_repo = "https://<HTTP SERVER>/python-modules/helm-latest-linux-ppc64le.tar.gz"
```

This variable specify the MTU value for the private network interface on RHEL and RHCOS nodes. The CNI network will have <private_network_mtu> - 50 for OpenshiftSDN and <private_network_mtu> - 100 for OVNKubernetes network provider.
```
private_network_mtu = 1450
Expand Down
2 changes: 1 addition & 1 deletion modules/1_bastion/bastion.tf
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ resource "null_resource" "bastion_packages" {
provisioner "remote-exec" {
inline = [
"#sudo yum update -y --skip-broken",
"sudo yum install -y wget jq git net-tools vim python3 tar"
"sudo yum install -y wget jq git net-tools vim python3 tar curl unzip"
]
}
provisioner "remote-exec" {
Expand Down
59 changes: 56 additions & 3 deletions modules/3_helpernode/helpernode.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ locals {
]

local_registry = local.local_registry
helm_repo = var.helm_repo
client_tarball = var.openshift_client_tarball
install_tarball = var.openshift_install_tarball
}
Expand All @@ -78,12 +79,11 @@ locals {
}
}

resource "null_resource" "config" {

resource "null_resource" "prep_helpernode_tools_git" {
triggers = {
bootstrap_count = var.bootstrap_port_ip == "" ? 0 : 1
worker_count = length(var.worker_port_ips)
}
count = length(regexall("\\.zip$", var.helpernode_repo)) == 0 ? 1 : 0

connection {
type = "ssh"
Expand All @@ -104,6 +104,59 @@ resource "null_resource" "config" {
"cd ocp4-helpernode && git checkout ${var.helpernode_tag}"
]
}
}

resource "null_resource" "prep_helpernode_tools_curl" {
triggers = {
bootstrap_count = var.bootstrap_port_ip == "" ? 0 : 1
}
count = length(regexall("\\.zip$", var.helpernode_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 = [
"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",
"cd .. && 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 = "ocp4-helpernode/inventory"
Expand Down
2 changes: 1 addition & 1 deletion modules/3_helpernode/templates/helpernode_vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,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}"
1 change: 1 addition & 0 deletions modules/3_helpernode/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ variable "ocp_release_tag" {}

variable "helpernode_repo" {}
variable "helpernode_tag" {}
variable "helm_repo" {}

variable "ansible_extra_options" {}

Expand Down
62 changes: 53 additions & 9 deletions modules/5_install/install.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,58 @@ locals {
}
}

resource "null_resource" "prep_playbooks_tools_git" {
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",
"echo 'Cloning into ocp4-playbooks...'",
"git clone ${var.install_playbook_repo} --quiet",
"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",
"cd .. && rm -rf ocp4-extract-helper/ocp4-playbooks.zip",
"mv ocp4-extract-helper/ocp4-playbooks* ocp4-playbooks",
"rm -rf ocp4-extract-helper"
]
}
}

resource "null_resource" "pre_install" {
count = local.bastion_count

Expand Down Expand Up @@ -111,7 +163,7 @@ resource "null_resource" "pre_install" {
}

resource "null_resource" "install" {
depends_on = [null_resource.pre_install]
depends_on = [null_resource.prep_playbooks_tools_git, null_resource.prep_playbooks_tools_curl, null_resource.pre_install]

triggers = {
worker_count = length(var.worker_ips)
Expand All @@ -127,14 +179,6 @@ resource "null_resource" "install" {
bastion_host = var.jump_host
}

provisioner "remote-exec" {
inline = [
"rm -rf ocp4-playbooks",
"echo 'Cloning into ocp4-playbooks...'",
"git clone ${var.install_playbook_repo} --quiet",
"cd ocp4-playbooks && git checkout ${var.install_playbook_tag}"
]
}
provisioner "file" {
content = templatefile("${path.module}/templates/install_inventory", local.install_inventory)
destination = "ocp4-playbooks/inventory"
Expand Down
1 change: 1 addition & 0 deletions ocp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,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
Expand Down
1 change: 1 addition & 0 deletions var.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ variable "install_playbook_tag" {
default = "284b597b3e88c635e3069b82926aa16812238492"
}

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"
Expand Down