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

Fix/update terraform 2023 #21

Merged
merged 4 commits into from
Apr 28, 2023
Merged
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
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
@@ -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'`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you can remove the -L since it's in the -fsSL now. not a big deal, though.


#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
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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
@@ -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
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"
@@ -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" {
@@ -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" {

@@ -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"
}

@@ -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" {

@@ -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"
}

6 changes: 3 additions & 3 deletions modules/bastion/variables.tf
Original file line number Diff line number Diff line change
@@ -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
}

Loading