-
Notifications
You must be signed in to change notification settings - Fork 137
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 Terraform setup #276
Fix Terraform setup #276
Conversation
This is part of the work I am doing with the Terraform Setup guide: tinkerbell/tinkerbell.org#129 Signed-off-by: Gianluca Arbezzano <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #276 +/- ##
=======================================
Coverage 20.61% 20.61%
=======================================
Files 15 15
Lines 1363 1363
=======================================
Hits 281 281
Misses 1068 1068
Partials 14 14 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting this working simpler, @gianarb
I have a few more changes that will benefit this setup and I'd rather see us get them in one shot. If we change resource names in a later commit people that started with this terraform example will have to transfer state to the renamed resources, for example.
I have my changes staged here: https://github.com/gianarb/tink/compare/fix/update-terraform-setup...displague:terraform-cleanup?expand=1
I'll push these changes into this branch once I have verified them.
Great thanks @displague ! |
Signed-off-by: Marques Johansson <[email protected]>
…isioning Signed-off-by: Marques Johansson <[email protected]>
deploy/terraform/main.tf
Outdated
type = "ssh" | ||
user = var.ssh_user | ||
host = packet_device.tink-provisioner.network[0].address | ||
private_key = file(var.ssh_private_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gianarb I removed the private_key
because Terraform will use your ssh-agent by default.
The problem with defaulting to "~/.ssh/id_rsa" is that this file is usually encrypted, and Terraform can not use that.
My suggestion is that we ask the user to add the key they want to use to their SSH agent before running terraform apply
. For most users, this should already be the case - nothing to do.
An alternative is to ask users to ssh-keygen
create a new key in this directory, and tell Terraform to use that.
If we can make private_key
optional (use the agent if ssh_private_key is empty) that would be even better. I can look into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the ssh-agent
note as part of the documentation. We can do the fallback work as follow up work 👍
hostname = "tink-provisioner" | ||
plan = var.device_type | ||
facilities = [var.facility] | ||
operating_system = "ubuntu_18_04" | ||
billing_cycle = "hourly" | ||
project_id = var.project_id | ||
user_data = file("install_package.sh") | ||
} | ||
|
||
resource "null_resource" "tink_directory" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gianarb by moving the provisioning to a null_resource
, provisioning failures (like a missing ssh key) will not require the tink_provisioner
host to be recreated. Changes to the tink/ directory can be reapplied (rsync'd) independently. terraform taint null_resource.tink_directory; terraform apply
deploy/terraform/main.tf
Outdated
type = "layer2-individual" | ||
} | ||
|
||
# Attach VLAN to provisioner | ||
resource "packet_port_vlan_attachment" "provisioner" { | ||
device_id = packet_device.tink-provisioner.id | ||
device_id = packet_device.tink_provisioner.id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran into Error: POST https://api.packet.net/ports/bff62cf9-5f23-49fd-b500-686e3d8730b6/assign: 422 still bonded
once while testing this. A follow-up terraform apply
was successful.
It may make sense to add depends_on = packet_device_network_type.tink_provisioner_network_type
here 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like a reasonable dependency to me, so let's be clear about that and write it down 👍
@@ -8,6 +8,11 @@ variable "project_id" { | |||
type = string | |||
} | |||
|
|||
variable "worker_count" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked tinkerbell/tinkerbell.org#129 to see if multiple workers will require any additional doc changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, they will just work! Nice!
I'm quite new to terraform, and for it to work for me I have had to
Also something that would make the process faster for the newbies is to include the file
Example: https://github.com/alexellis/sshdkit where the ssh.yml was ignored but we have an example for it in ssh.example.yml |
A small hicup running
But ounce insider the provisioner the
I went on but
|
…chment Signed-off-by: Marques Johansson <[email protected]>
Signed-off-by: Marques Johansson <[email protected]>
Signed-off-by: Marques Johansson <[email protected]>
…user@host in output Signed-off-by: Marques Johansson <[email protected]>
Signed-off-by: Marques Johansson <[email protected]>
This is part of the work I am doing with the Terraform Setup guide:
tinkerbell/tinkerbell.org#129