Skip to content

Commit

Permalink
Merge pull request #21 from rawkode/fix/update-terraform-2023
Browse files Browse the repository at this point in the history
Fix/update terraform 2023
  • Loading branch information
displague authored Apr 28, 2023
2 parents 1a6c87a + 784e20b commit 5044c4a
Show file tree
Hide file tree
Showing 18 changed files with 144 additions and 205 deletions.
167 changes: 77 additions & 90 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/cnv/11_cnv_sample.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@lb-0.${TF_V

## Stage a Windows 2019 image from Vagrant on you bastion/LB

version=`curl -L -H "Accept: application/json" https://app.vagrantup.com/peru/boxes/windows-server-2019-standard-x64-eval | jq -r '.versions[0].version'`
version=`curl -fsSL -L -H "Accept: application/json" https://app.vagrantup.com/peru/boxes/windows-server-2019-standard-x64-eval | jq -r '.versions[0].version'`

#ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${TF_VAR_ssh_private_key_path} root@lb-0.${TF_VAR_cluster_name}.${TF_VAR_cluster_basedomain} << EOF
# wget https://app.vagrantup.com/peru/boxes/windows-server-2016-standard-x64-eval/versions/${version}/providers/libvirt.box -O /usr/share/nginx/html/libvirt.box
Expand Down
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module "bastion" {
depends_on = [module.sshkey]

project_id = var.project_id
facility = var.facility
metro = var.metro
plan = var.plan_bastion
operating_system = var.bastion_operating_system
ssh_private_key_path = module.sshkey.ssh_private_key_file
Expand Down Expand Up @@ -60,7 +60,7 @@ module "openshift_bootstrap" {
cluster_basedomain = var.cluster_basedomain
node_count = var.count_bootstrap
plan = var.plan_controlplane
facility = var.facility
metro = var.metro
ssh_private_key_path = module.sshkey.ssh_private_key_file
project_id = var.project_id
bastion_ip = module.bastion.lb_ip
Expand Down Expand Up @@ -88,7 +88,7 @@ module "openshift_controlplane" {
cluster_basedomain = var.cluster_basedomain
node_count = var.count_controlplane
plan = var.plan_controlplane
facility = var.facility
metro = var.metro
ssh_private_key_path = module.sshkey.ssh_private_key_file
project_id = var.project_id
bastion_ip = module.bastion.lb_ip
Expand Down Expand Up @@ -116,7 +116,7 @@ module "openshift_workers" {
cluster_basedomain = var.cluster_basedomain
node_count = var.count_compute
plan = var.plan_compute
facility = var.facility
metro = var.metro
ssh_private_key_path = module.sshkey.ssh_private_key_file
project_id = var.project_id
bastion_ip = module.bastion.lb_ip
Expand Down
63 changes: 21 additions & 42 deletions modules/bastion/main.tf
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
data "template_file" "user_data" {
template = file("${path.module}/assets/user_data_${var.operating_system}.sh")
}

data "template_file" "ipxe_script" {
depends_on = [equinix_metal_device.lb]
for_each = toset(var.nodes)
template = file("${path.module}/assets/ipxe.tpl")

vars = {
node_type = each.value
bastion_ip = equinix_metal_device.lb.access_public_ipv4
ocp_version = var.ocp_version
ocp_version_zstream = var.ocp_version_zstream
}
}

data "template_file" "ignition_append" {
depends_on = [equinix_metal_device.lb]
for_each = toset(var.nodes)
template = file("${path.module}/assets/ignition-append.json.tpl")

vars = {
node_type = each.value
bastion_ip = equinix_metal_device.lb.access_public_ipv4
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
}
}

locals {
arch = "x86_64"
coreos_baseurl = "https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos"
Expand All @@ -42,12 +12,11 @@ locals {
resource "equinix_metal_device" "lb" {
hostname = "lb-0.${var.cluster_name}.${var.cluster_basedomain}"
plan = var.plan
facilities = [var.facility]
metro = var.metro
operating_system = var.operating_system
billing_cycle = var.billing_cycle
project_id = var.project_id
user_data = data.template_file.user_data.rendered

user_data = file("${path.module}/assets/user_data_${var.operating_system}.sh")
}

resource "null_resource" "dircheck" {
Expand Down Expand Up @@ -81,18 +50,18 @@ resource "null_resource" "ocp_install_ignition" {


inline = [
"curl -L -o /usr/share/nginx/html/${local.coreos_img} ${local.coreos_url}/${local.coreos_img}",
"curl -L -o /usr/share/nginx/html/${local.coreos_kernel} ${local.coreos_url}/${local.coreos_kernel}",
"curl -L -o /usr/share/nginx/html/${local.coreos_initrd} ${local.coreos_url}/${local.coreos_initrd}",
"curl -fsSL -o /usr/share/nginx/html/${local.coreos_img} ${local.coreos_url}/${local.coreos_img}",
"curl -fsSL -o /usr/share/nginx/html/${local.coreos_kernel} ${local.coreos_url}/${local.coreos_kernel}",
"curl -fsSL -o /usr/share/nginx/html/${local.coreos_initrd} ${local.coreos_url}/${local.coreos_initrd}",
"chmod -R 0755 /usr/share/nginx/html/"
]
}
}

resource "null_resource" "ipxe_files" {

depends_on = [null_resource.dircheck]
for_each = data.template_file.ipxe_script
depends_on = [equinix_metal_device.lb, null_resource.dircheck]
for_each = toset(var.nodes)

provisioner "file" {

Expand All @@ -101,7 +70,12 @@ resource "null_resource" "ipxe_files" {
host = equinix_metal_device.lb.access_public_ipv4
}

content = each.value.rendered
content = templatefile("${path.module}/assets/ipxe.tpl", {
node_type = each.value
bastion_ip = equinix_metal_device.lb.access_public_ipv4
ocp_version = var.ocp_version
ocp_version_zstream = var.ocp_version_zstream
})
destination = "/usr/share/nginx/html/${each.key}.ipxe"
}

Expand All @@ -121,8 +95,8 @@ resource "null_resource" "ipxe_files" {

resource "null_resource" "ignition_append_files" {

depends_on = [null_resource.dircheck]
for_each = data.template_file.ignition_append
depends_on = [equinix_metal_device.lb, null_resource.dircheck]
for_each = toset(var.nodes)

provisioner "file" {

Expand All @@ -131,7 +105,12 @@ resource "null_resource" "ignition_append_files" {
host = equinix_metal_device.lb.access_public_ipv4
}

content = each.value.rendered
content = templatefile("${path.module}/assets/ignition-append.json.tpl", {
node_type = each.value
bastion_ip = equinix_metal_device.lb.access_public_ipv4
cluster_name = var.cluster_name
cluster_basedomain = var.cluster_basedomain
})
destination = "/usr/share/nginx/html/${each.key}-append.ign"
}

Expand Down
6 changes: 3 additions & 3 deletions modules/bastion/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ variable "billing_cycle" {

variable "plan" {
description = "The server type to deploy"
default = "c2.medium.x86"
default = "c3.small.x86"
type = string
}

variable "facility" {
variable "metro" {
description = "The location of the servers"
default = "sjc1"
default = "da"
type = string
}

Expand Down
Loading

0 comments on commit 5044c4a

Please sign in to comment.