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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying content for vagrantfile_template #104

Open
flmmartins opened this issue Nov 19, 2023 · 3 comments 路 May be fixed by #112
Open

Allow specifying content for vagrantfile_template #104

flmmartins opened this issue Nov 19, 2023 · 3 comments 路 May be fixed by #112

Comments

@flmmartins
Copy link

flmmartins commented Nov 19, 2023

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.

Description

Today vagrantfile_template needs to be a file path.

Allow to specify vagrantfile_template_content in Vagrant post processor so I can use templatefile with it.

Use Case(s)

I want to specify my own SSH to be used in Vagrant instead of the public one therefore I would like to inject a vagrant with the following:

Vagrant.configure("2") do |config|
  config.ssh.private_key_path = ${my_ssh_key}
  config.ssh.forward_agent = true
end

This could be applied many configurations in the Vagrantfile. This is only an example.

Potential configuration

locals {
   vagrantfile = templatefile("vagrantfile.pkrtpl.hcl", { 
      my_ssh_key = "~/.ssh/rsa
    })
 }
 ....
 post-processor "vagrant" {
    vagrantfile_template_content = local.vagrantfile
 }  

Potential References

https://developer.hashicorp.com/packer/integrations/hashicorp/vagrant/latest/components/post-processor/vagrant

@lbajolet-hashicorp
Copy link
Contributor

Hi @flmmartins,

Thanks for the suggestion, this is a Vagrant plugin specific issue so I'll transfer it to the plugin now.

This is likely simple to implement, would you be interested in contributing it potentially? We'd happily help if so, and review the code for certain!

@lbajolet-hashicorp lbajolet-hashicorp transferred this issue from hashicorp/packer Nov 20, 2023
@flmmartins
Copy link
Author

Sure. I will see if I can propose a PR although I don't have experience with Go but it will be a good learning opportunity.

@lbajolet-hashicorp
Copy link
Contributor

Awesome, thanks @flmmartins

Don't hesitate to reach out if you need some help, happy to provide!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants