diff options
author | Micah Anderson <micah@riseup.net> | 2007-10-12 16:14:11 +0000 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2007-10-12 16:14:11 +0000 |
commit | 284b50a1d07310c8c10f1c1f953d1e979762c476 (patch) | |
tree | 3974da499c584648e3aefbb8be13270f3d90ff93 /plugins/facter/vserver.rb | |
download | puppet-virtual-284b50a1d07310c8c10f1c1f953d1e979762c476.tar.gz puppet-virtual-284b50a1d07310c8c10f1c1f953d1e979762c476.tar.bz2 |
add the virtual module
Diffstat (limited to 'plugins/facter/vserver.rb')
-rw-r--r-- | plugins/facter/vserver.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/plugins/facter/vserver.rb b/plugins/facter/vserver.rb new file mode 100644 index 0000000..bd8218d --- /dev/null +++ b/plugins/facter/vserver.rb @@ -0,0 +1,29 @@ +# vserver.rb -- linux-vserver.org related facts +# Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at> +# See LICENSE for the full license granted to you. +# Based on abnormaliti's "virtual" fact from +# http://reductivelabs.com/trac/puppet/wiki/VirtualRecipe + +# This defines the fact "vserver" with the possible values of "none", "guest", +# or "host" + +Facter.add("vserver") do + confine :kernel => :linux + + ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin" + + result = "none" + + setcode do + if FileTest.directory?('/proc/virtual') + result = "host" + elsif ! FileTest.directory?('/proc/2') + # gross hack: PID 2 is usually a + # kernel thread, which doesn't existin vserver + result = "guest" + end + + result + end +end + |