SecureRandom.random_number(99999)
Adjust the number of digits.
Alvaro
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/270f87fb-6bf0-48c7-a676-25ce8d16e256%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
HelloNot sure about mac, but you can use:
SecureRandom.random_number(99999)
Adjust the number of digits.
Alvaro
On Tue, May 2, 2017 at 5:34 PM, Abhishek Verma <abhishe...@uptopoint.com> wrote:
Hi All,
I am trying to setup a Vagrant machine with dynamic hostname.
I can setup hostname using "config.vm.hostname = "DummyReefServer"" in VagrantFile and it works fine.
But I wish to make this hostname dynamic , if possibile based on macaddress so everytime its unique..
Is it possible to setup hostname dunamic possibly something like this
config.vm.hostname = "DummyReefServer"+ethernet0.address
Thanks in Advance
Regards,
Abhishek
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/270f87fb-6bf0-48c7-a676-25ce8d16e256%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Alvaro
Vagrant.configure("2") do |config|
File.open("hostname.txt", "w") {|f| f.write("dummy-ngs-#{SecureRandom.random_number(9999)}")} unless File.file?("hostname.txt")
hostname = File.read("hostname.txt")
config.vm.hostname = hostname
config.vm.box = "hashicorp/precise64"
end
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to a topic in the Google Groups "Vagrant" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vagrant-up/rXpN5TCCFUo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0eybpdJxaazonwk5ZbQX8QrW%2BW-z5FDZH%3DJq5LWbXGMJSg%40mail.gmail.com.
To unsubscribe from this group and all its topics, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0eybpdJxaazonwk5ZbQX8QrW%2BW-z5FDZH%3DJq5LWbXGMJSg%40mail.gmail.com.