Skip to content

Commit

Permalink
update packet provider
Browse files Browse the repository at this point in the history
  • Loading branch information
jawabuu committed May 15, 2021
1 parent a80bdc6 commit 384c80b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions provider/packet/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,32 @@ variable "hostname_format" {
default = ""
}

variable "ssh_key_path" {
type = string
}

variable "ssh_pubkey_path" {
type = string
}

resource "time_static" "id" {}

provider "packet" {
auth_token = var.auth_token
}

resource "packet_project_ssh_key" "tf-kube" {
name = "tf-kube-${time_static.id.unix}"
public_key = file("${var.ssh_pubkey_path}")
project_id = local.project_id

lifecycle {
ignore_changes = [
public_key
]
}
}

resource "packet_device" "host" {
count = var.hosts
hostname = format(var.hostname_format, count.index + 1)
Expand All @@ -48,12 +70,14 @@ resource "packet_device" "host" {
billing_cycle = var.billing_cycle
project_id = var.project_id
user_data = var.user_data
ssh_keys = [packet_project_ssh_key.tf-kube.id]

connection {
user = "root"
type = "ssh"
timeout = "2m"
host = self.access_public_ipv4
private_key = file("${var.ssh_key_path}")
}

provisioner "remote-exec" {
Expand All @@ -78,6 +102,24 @@ output "private_ips" {
value = "${packet_device.host.*.access_private_ipv4}"
}

output "public_network_interface" {
value = "bond0"
}

output "private_network_interface" {
value = "bond0"
}

output "region" {
value = var.facility
}

output "nodes" {

value = [for index, server in packet_device.host : {
hostname = server.name
public_ip = server.access_public_ipv4
private_ip = server.access_private_ipv4
}]

}

0 comments on commit 384c80b

Please sign in to comment.