-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
provider/azurerm: Fix an issue with azurerm_virtual_machine
ssh_keys
#6541
Conversation
@clstokes / @HX-Rd / @clintonm9 / @jlecren / @gdhagger hopefully this will make you all happy :) Sorry for the time this has taken to resolve! |
ssh_keys were throwing an error similar to this: ``` * azurerm_virtual_machine.test: [DEBUG] Error setting Virtual Machine * Storage OS Profile Linux Configuration: &errors.errorString{s:"Invalid * address to set: []string{\"os_profile_linux_config\", \"0\", * \"ssh_keys\"}"} ``` This was because of nesting of Set within a Set in the schema. By changing this to a List within a Set, the schema works as expected. This means we can now set SSH Keys on VMs. This has been tested using a remote-exec and a connection block with the ssh key ``` azurerm_virtual_machine.test: Still creating... (2m10s elapsed) azurerm_virtual_machine.test (remote-exec): Connected! azurerm_virtual_machine.test (remote-exec): CONNECTED! ```
cfac08d
to
712fc83
Compare
Thanks @stack72 - that's a big improvement! |
Hey, I'm struggling with the syntax required to fix the ssh_keys error above. When you say "By Thanks in advance |
Hi @heywoodj There is no difference to the end user - this was a code issue within my original development P. |
Hey, os_profile_linux_config {
Thanks again |
Hi @heywoodj YEs, that will work but only when 0.6.16 gets released today / tomorrow 1 thing to note though (again going into the documentation today / tomorrow) is that the path is fixed to a known location. For example, if the admin Username for the machine is foo, then the ssh_keys path needs to be:
|
Ah, didn't realise was release dependent just thought I had an issue with my config. Thanks for the heads up with the path, I have been setting that correctly and it does copy up the public key up to the correct place :-) but the Terraform script must fail afterwards. |
yes, it was failing reading the information back and setting it to terraform state and causing the resource to fallover - it'll be fixed really soon now :) P. |
@stack72 Hey, I noticed a copy of .16 was available for download and has fixed the issue above. os_profile_linux_config {
|
Hi @heywoodj this param:
What is the key_data that you are trying to use? P. |
Hey, the path the public key file that I am generating via Putty. If I do not try to run the remote execution the server is created correctly and the public key is copied up. I can then access no problem via a ssh client using private key. It seems like it is trying to connect before VM provisioned properly and failing rather than trying to reconnect like the password only scenario. Thanks J |
This is the example i am using for this part:
|
As you can see, I am doing the connection and provisioner INSIDE the vm resource. Otherwise you will need to put a |
@stack72 Hey, sorry my bad, the error was actually the private key file. I'd forgotten to use openssh format hence the 'no key found' error. I swift to correct format and is working now. Thanks |
Excellent - glad it's working! P. |
omg guys thanks, this was driving me crazy! (+ thanks for the people posting examples here) |
@stack72
Ragards |
Hi @lmeyemezu What part isn't working for you? Paul |
Hi, 1 error(s) occurred:
Terraform does not automatically rollback in the face of errors. bastion vm module tf (except)
main.tf (except)
Regards |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Fixes part of #5793, #6212
ssh_keys were throwing an error similar to this:
This was because of nesting of Set within a Set in the schema. By
changing this to a List within a Set, the schema works as expected. This
means we can now set SSH Keys on VMs. This has been tested using a
remote-exec and a connection block with the ssh key