Issue #10225 has been updated by Craig Miskell.
A simple patch for the problem is this:
--- util/virtual.rb 2013-09-27 14:49:33.982613353 +1200
+++ /home/craig/virtual.rb.new 2013-09-27 14:48:18.078843493 +1200
@@ -27,7 +27,8 @@
def self.vserver_type
if self.vserver?
- if FileTest.exists?("/proc/virtual")
+ txt = File.read("/proc/self/status")
+ if txt =~ /^(s_context|VxID): 0/
"vserver_host"
else
"vserver"
I'd love to see this get committed so this bug can be sorted/closed.
----------------------------------------
Bug #10225: virtual fact does not detect linux vserver host/guest correctly
https://projects.puppetlabs.com/issues/10225#change-98083
* Author: ghislain -
* Status: Investigating
* Priority: Normal
* Assignee:
* Category: library
* Target version:
* Keywords: vserver
* Branch:
* Affected Facter version: 1.6.2
----------------------------------------
the virtual fact does not work on vserver 2.3.1 because /proc/virtual is hidden
but still detected by facter:
The only REAL way to tell is to test /proc/self/status and look for the vxid,
if zero => host, if 1 => special spectator context facter will nerver see this
one, if more => guest
i wrote this one for me:
<pre>
if File.exists?("/proc/self/status")
File.open('/proc/self/status').each_line{ |s|
procstatus = s.split(': ');
if procstatus[0] == 'VxID'
if procstatus[1].strip! == '0'
# this is the host
Facter.add("vps") do
setcode{ "vserverhost" }
end
else
# this is the guest
Facter.add("vps") do
setcode{ "vserverguest" }
end
end
else
# pas un vserver
end
}
end
</pre>
This does not relly on file xx or yy to be there it just test if the current
process has a virtual ID.
<pre>
GUEST:/%(root)> facter virtual
vserver_host
GUEST:/%(root)> grep -i VXid /proc/self/status
VxID: 40410
(root)> vserver-info
Versions:
Kernel: 3.0.7-vs2.3.1aq
VS-API: 0x00020308
VCI: 0x0000000013001f11
util-vserver: 0.30.216-pre2994; Oct 21 2011, 17:32:30
</pre>
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.