Detecting the Host OS in the Vagrantfile

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Detecting the Host OS in the Vagrantfile

Lyndon Washington
Hi,

What is the best approach to detect the OS that vagrant is running in?  Full answers would be appreciated since something generic about using the Ruby convention is not much help since I am not really familiar with the stadanrd libraries for Ruby.

I thought that config.vagrant.host would be useful but I am not sure what method or attribute to use in an if check.

Thanks ahead of time for any assistance someone can provide.

Cheers,
-Lyndon

Lyndon Washington

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Detecting the Host OS in the Vagrantfile

_debo
Hi Lyndon,

in the projects I used to work on FFI has always been the choice. It has a platform module that does the trick. It might be a way too much for you but I personally don't know of any other.

Here a bit of specific documentation http://rdoc.info/github/ffi/ffi/FFI/Platform

Basically after requiring the module you can do something like:

FFI::Platform::IS_WINDOWS
FFI::Platform::IS_LINUX
FFI::Platform::IS_MAC

And so on. Those methods will return a boolean value true false.

I hope that helps.

Cheers,
Debo


On 9 April 2013 19:23, Lyndon Washington <[hidden email]> wrote:
Hi,

What is the best approach to detect the OS that vagrant is running in?  Full answers would be appreciated since something generic about using the Ruby convention is not much help since I am not really familiar with the stadanrd libraries for Ruby.

I thought that config.vagrant.host would be useful but I am not sure what method or attribute to use in an if check.

Thanks ahead of time for any assistance someone can provide.

Cheers,
-Lyndon

Lyndon Washington

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Detecting the Host OS in the Vagrantfile

Lyndon Washington
Thanks Marco, I will take a look.

Cheers,
-Lyndon-


On Tue, Apr 9, 2013 at 2:38 PM, Marco De Bortoli <[hidden email]> wrote:
Hi Lyndon,

in the projects I used to work on FFI has always been the choice. It has a platform module that does the trick. It might be a way too much for you but I personally don't know of any other.

Here a bit of specific documentation http://rdoc.info/github/ffi/ffi/FFI/Platform

Basically after requiring the module you can do something like:

FFI::Platform::IS_WINDOWS
FFI::Platform::IS_LINUX
FFI::Platform::IS_MAC

And so on. Those methods will return a boolean value true false.

I hope that helps.

Cheers,
Debo


On 9 April 2013 19:23, Lyndon Washington <[hidden email]> wrote:
Hi,

What is the best approach to detect the OS that vagrant is running in?  Full answers would be appreciated since something generic about using the Ruby convention is not much help since I am not really familiar with the stadanrd libraries for Ruby.

I thought that config.vagrant.host would be useful but I am not sure what method or attribute to use in an if check.

Thanks ahead of time for any assistance someone can provide.

Cheers,
-Lyndon

Lyndon Washington

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Detecting the Host OS in the Vagrantfile

Evelyn Killaby
In reply to this post by Lyndon Washington
The Vagrantfile is just Ruby, so you can use the built-in RUBY_PLATFORM constant.  For example:

print "RUBY_PLATFORM: " + RUBY_PLATFORM

This will output something like the following (you'll notice that I'm running OS X).

RUBY_PLATFORM: universal.x86_64-darwin12.2.1


See also:
http://stackoverflow.com/questions/170956/how-can-i-find-which-operating-system-my-ruby-program-is-running-on?lq=1





On Tuesday, April 9, 2013 11:23:53 AM UTC-7, Lyndon Washington wrote:
Hi,

What is the best approach to detect the OS that vagrant is running in?  Full answers would be appreciated since something generic about using the Ruby convention is not much help since I am not really familiar with the stadanrd libraries for Ruby.

I thought that config.vagrant.host would be useful but I am not sure what method or attribute to use in an if check.

Thanks ahead of time for any assistance someone can provide.

Cheers,
-Lyndon

Lyndon Washington

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.