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

chore: update the module for June 2024 current TF Provider and upstream module behaviors #31

Merged
merged 5 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.terraform
.terraform*
!.terraform.lock.hcl
.terraform.lock.hcl
ignition.bu
terraform.tfstate
terraform.tfstate.backup
Expand Down
190 changes: 0 additions & 190 deletions .terraform.lock.hcl

This file was deleted.

8 changes: 0 additions & 8 deletions OWNERS.md

This file was deleted.

25 changes: 15 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
provider "equinix" {
auth_token = var.auth_token
auth_token = var.metal_auth_token
}

module "sshkey" {
Expand All @@ -12,8 +12,8 @@ module "bastion" {
source = "./modules/bastion"
depends_on = [module.sshkey]

project_id = var.project_id
metro = var.metro
project_id = var.metal_project_id
metro = var.metal_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,9 +60,9 @@ module "openshift_bootstrap" {
cluster_basedomain = var.cluster_basedomain
node_count = var.count_bootstrap
plan = var.plan_controlplane
metro = var.metro
metro = var.metal_metro
ssh_private_key_path = module.sshkey.ssh_private_key_file
project_id = var.project_id
project_id = var.metal_project_id
bastion_ip = module.bastion.lb_ip
node_type = "bootstrap"
depends = [module.prepare_openshift.finished]
Expand All @@ -88,9 +88,9 @@ module "openshift_controlplane" {
cluster_basedomain = var.cluster_basedomain
node_count = var.count_controlplane
plan = var.plan_controlplane
metro = var.metro
metro = var.metal_metro
ssh_private_key_path = module.sshkey.ssh_private_key_file
project_id = var.project_id
project_id = var.metal_project_id
bastion_ip = module.bastion.lb_ip
node_type = "master"
depends = [module.prepare_openshift.finished]
Expand All @@ -116,9 +116,9 @@ module "openshift_workers" {
cluster_basedomain = var.cluster_basedomain
node_count = var.count_compute
plan = var.plan_compute
metro = var.metro
metro = var.metal_metro
ssh_private_key_path = module.sshkey.ssh_private_key_file
project_id = var.project_id
project_id = var.metal_project_id
bastion_ip = module.bastion.lb_ip
node_type = "worker"
depends = [module.prepare_openshift.finished]
Expand Down Expand Up @@ -156,11 +156,16 @@ module "openshift_install" {
ocp_virtualization_enable = var.ocp_virtualization_enable
}


resource "null_resource" "get_kubeconfig" {
depends_on = [module.prepare_openshift.finished]

provisioner "local-exec" {
command = "mkdir -p ${path.root}/auth; scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${module.sshkey.ssh_private_key_file} root@${module.bastion.lb_ip}:/tmp/artifacts/install/auth/* ${path.root}/auth/"
command = <<EOT
[[ -d ${path.root}/auth ]] || mkdir -p ${path.root}/auth
displague marked this conversation as resolved.
Show resolved Hide resolved
/usr/bin/scp -r -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i ${module.sshkey.ssh_private_key_file} root@${module.bastion.lb_ip}:/tmp/artifacts/install/auth/ ${path.root}/auth/
displague marked this conversation as resolved.
Show resolved Hide resolved
EOT
interpreter = [ "/bin/bash", "-c" ]
displague marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
31 changes: 21 additions & 10 deletions modules/dns/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@
// provider definitions to this layer and assume that an invalid token for the
// unused provider will not prevent the needed provider from succeeding.

provider "cloudflare" {
api_token = try(var.dns_options.api_token, "")
api_key = try(var.dns_options.api_key, null)
email = try(var.dns_options.email, "")
}

provider "linode" {
token = try(var.dns_options.api_token, "")
}
# provider "cloudflare" {
# must use environment CLOUDFLARE_API_TOKEN
# see https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs
# api_token = try(var.dns_options.api_token, "")
# api_key = try(var.dns_options.api_key, null)
# email = try(var.dns_options.email, "")
# }

# provider "linode" {
# must use environment -- LINODE_TOKEN
# }

provider "aws" {
region = "us-east-1" # doesn't matter
# AWS credentials are optional for this module. Skip AWS settings that require credentials.
# see https://registry.terraform.io/providers/-/aws/latest/docs#environment-variables
skip_credentials_validation = (var.dns_provider == "aws" ? false : true)
skip_metadata_api_check = (var.dns_provider == "aws" ? false : true) # AWS_EC2_METADATA_DISABLED
skip_region_validation = (var.dns_provider == "aws" ? false : true) # AWS_REGION
skip_requesting_account_id = (var.dns_provider == "aws" ? false : true)

access_key = (var.dns_provider == "aws" ? null : "none") # use local profile config or environment AWS_ACCESS_KEY_ID
secret_key = (var.dns_provider == "aws" ? null : "none") # use local profile config or environment AWS_SECRET_ACCESS_KEY
region = "us-east-1"
}

module "aws" {
Expand Down
1 change: 0 additions & 1 deletion modules/dns/modules/aws/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
1 change: 1 addition & 0 deletions modules/dns/modules/cloudflare/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 4.35"
}
}
required_version = ">= 0.13"
Expand Down
3 changes: 3 additions & 0 deletions modules/dns/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ terraform {
linode = {
source = "linode/linode"
}
aws = {
source = "hashicorp/aws"
}
}
required_version = ">= 0.13"
displague marked this conversation as resolved.
Show resolved Hide resolved
}
1 change: 0 additions & 1 deletion modules/node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ resource "equinix_metal_device" "node" {
count = var.node_count
billing_cycle = "hourly"
project_id = var.project_id

}

2 changes: 1 addition & 1 deletion modules/sshkey/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resource "equinix_metal_ssh_key" "ssh_pub_key" {
}

resource "local_file" "cluster_private_key_pem" {
content = chomp(tls_private_key.ssh_key_pair.private_key_openssh)
content = chomp(tls_private_key.ssh_key_pair.private_key_pem)
displague marked this conversation as resolved.
Show resolved Hide resolved
filename = pathexpand(format("~/.ssh/%s", local.ssh_key_name))
file_permission = "0600"
}
10 changes: 10 additions & 0 deletions terraform.tfvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# metal_project_id="uuid"
displague marked this conversation as resolved.
Show resolved Hide resolved
# metal_auth_token="token"

# cluster_basedomain="example.com" # This is the zone in your DNS provider. cluster_name will be suffixed for all DNS names. worker-1.{cluster_name}.{cluster_basedomain}
# cluster_name="openshift"
# ocp_cluster_manager_token="..." # OpenShift Cluster Manager API Token used to generate your pullSecret (https://cloud.redhat.com/openshift/token)

# dns_provider="linode" # also set LINODE_TOKEN environment variable
# dns_provider="aws" # also use locally configured AWS profile
# dns_provider="cloudflare" # also set CLOUDFLARE_API_TOKEN environment variable
Loading
Loading