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

Ability to set the box hostname and domain from Vagrantfile #139

Closed
johnae opened this issue Aug 12, 2010 · 11 comments
Closed

Ability to set the box hostname and domain from Vagrantfile #139

johnae opened this issue Aug 12, 2010 · 11 comments

Comments

@johnae
Copy link

johnae commented Aug 12, 2010

Well, not much more to say than the title already does but in general this would mean on an Ubuntu system to change the /etc/hostname, /etc/hosts so 127.0.1.1 points to hostname.domain.tld hostname and preferably also change the /etc/resolv.conf so domain and search is set.

Anyone already doing this through vagrant? Am I missing something?

@mitchellh
Copy link
Contributor

I would say this is more of a thing that should go into provisioners, unless you have a solid argument otherwise. I'm interested. Vagrant 0.6 should (if I can pack it all in!) enhance the provisioners functionality a bit more to make this an easy addition.

@AlexMikhalev
Copy link

Hi Mitchell,
I am second to the request. It will help me with Multiple VM and different webservers on it and also with automatic provisioning chef server using vagrant :)

@mitchellh
Copy link
Contributor

Alex,

You can already name your VM using this syntax to differentiate them in the Vagrant UI:

config.vm.customize do |vm|
  vm.name = "Anything Here"
end

As for setting the hostname, I still believe this can be done by a provisioner. Why can't you use chef to set the hostname?

Mitchell

@AlexMikhalev
Copy link

Mitchell,
Thanks for the tip. Will name of the VM change the name of chef client?
With regards to hostname, do you mean something like this:"Dynamic hosts file using Chef" - http://bit.ly/9gwk5t

Also I am curios on your feedback to my first attempts to use vagrant and chef: "Quick way to bootstrap chef server with vagrant" - http://bit.ly/cymYtX

Regards,
Alex

@mitchellh
Copy link
Contributor

Alex,

No, the name only affects the name that VirtualBox shows for it, not the hostname.

And yes, I suppose I am talking about something like what you linked but in a much less complicated way. I guess if you're using chef server you must set the hostname prior to running it. I have some ideas for working around this so I'll work on them, though they are still unrelated to this issue exactly.

Mitchell

@mitchellh
Copy link
Contributor

Alex,

Also, I'll review your article in a bit and comment there =]

Thanks!

@johnae
Copy link
Author

johnae commented Aug 26, 2010

Well, come to think about it, perhaps this could be a good way of doing this:

config.chef.node_name = "somehost.example.com" in the Vagrantfile and then
just add a recipe to chef which sets the hostname base on that.

When I found this setting it was easier to do what I wanted. The default nodename was "client" which was kind of troublesome for me since all vagrant boxes got the recipes etc from the node "client" which isn't at all what I wanted. I was used to setting the fqdn on an ec2 node(through some userdata) and then just run chef against my chef server but with vagrant it works differently... but in reality this could actually be a nice way of setting the fqdn on an ec2 node as well.

@morepanda
Copy link

Not sure when this was added, but this works for me to set the hostname:

 config.vm.host_name = 'foo.bar'

@mitchellh
Copy link
Contributor

This was added as of 0.7.1. I changed my stance on the issue since the hostname is so crucial to many tools working properly, it made sense to add this.

@guoqiao
Copy link

guoqiao commented Jun 19, 2019

Not sure when this was added, but this works for me to set the hostname:

 config.vm.host_name = 'foo.bar'

It should be hostname.

@ghost
Copy link

ghost commented Jan 28, 2020

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.

@hashicorp hashicorp locked and limited conversation to collaborators Jan 28, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants