facter 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of facter might be problematic. Click here for more details.

Files changed (55) hide show
  1. data/CHANGELOG +42 -0
  2. data/COPYING +0 -458
  3. data/LICENSE +670 -13
  4. data/Rakefile +54 -10
  5. data/bin/facter +6 -2
  6. data/conf/osx/createpackage.sh +2 -1
  7. data/conf/osx/preflight +2 -1
  8. data/conf/redhat/facter.spec +25 -9
  9. data/install.rb +0 -0
  10. data/lib/facter.rb +6 -6
  11. data/lib/facter/Cfkey.rb +2 -2
  12. data/lib/facter/domain.rb +21 -52
  13. data/lib/facter/fqdn.rb +2 -1
  14. data/lib/facter/hardwareisa.rb +1 -1
  15. data/lib/facter/id.rb +12 -1
  16. data/lib/facter/interfaces.rb +32 -0
  17. data/lib/facter/ipaddress.rb +1 -1
  18. data/lib/facter/kernelrelease.rb +2 -2
  19. data/lib/facter/kernelversion.rb +4 -4
  20. data/lib/facter/lsb.rb +1 -1
  21. data/lib/facter/lsbmajdistrelease.rb +1 -1
  22. data/lib/facter/macaddress.rb +27 -27
  23. data/lib/facter/macosx.rb +3 -3
  24. data/lib/facter/manufacturer.rb +11 -2
  25. data/lib/facter/network.rb +10 -0
  26. data/lib/facter/operatingsystem.rb +4 -0
  27. data/lib/facter/operatingsystemrelease.rb +12 -15
  28. data/lib/facter/processor.rb +1 -1
  29. data/lib/facter/puppetversion.rb +2 -2
  30. data/lib/facter/uniqueid.rb +1 -1
  31. data/lib/facter/uptime.rb +20 -0
  32. data/lib/facter/util/fact.rb +1 -1
  33. data/lib/facter/util/ip.rb +134 -66
  34. data/lib/facter/util/macosx.rb +43 -30
  35. data/lib/facter/util/manufacturer.rb +13 -6
  36. data/lib/facter/util/netmask.rb +21 -23
  37. data/lib/facter/util/plist.rb +1 -1
  38. data/lib/facter/util/uptime.rb +32 -0
  39. data/lib/facter/virtual.rb +66 -53
  40. data/spec/integration/facter.rb +0 -0
  41. data/spec/spec_helper.rb +1 -10
  42. data/spec/unit/data/6.0-STABLE_FreeBSD_ifconfig +12 -0
  43. data/spec/unit/data/Mac_OS_X_10.5.5_ifconfig +26 -0
  44. data/spec/unit/data/darwin_ifconfig_single_interface +6 -0
  45. data/spec/unit/facter.rb +1 -1
  46. data/spec/unit/interfaces.rb +19 -0
  47. data/spec/unit/util/collection.rb +2 -2
  48. data/spec/unit/util/confine.rb +0 -0
  49. data/spec/unit/util/fact.rb +0 -0
  50. data/spec/unit/util/ip.rb +65 -9
  51. data/spec/unit/util/loader.rb +1 -1
  52. data/spec/unit/util/macosx.rb +47 -0
  53. data/spec/unit/util/resolution.rb +0 -0
  54. metadata +12 -4
  55. data/lib/facter/ipmess.rb +0 -46
data/Rakefile CHANGED
@@ -27,9 +27,6 @@ project = Rake::RedLabProject.new("facter") do |p|
27
27
  'etc/*'
28
28
  ]
29
29
 
30
- #p.epmhosts = %w{culain}
31
- #p.rpmhost = "fedora1"
32
- #p.sunpkghost = "sol10b"
33
30
  end
34
31
 
35
32
  project.mkgemtask do |gem|
@@ -42,15 +39,62 @@ project.mkgemtask do |gem|
42
39
  gem.author = "Luke Kanies"
43
40
  end
44
41
 
45
- if project.has?(:epm)
46
- project.mkepmtask do |task|
47
- task.bins = FileList.new("bin/facter")
48
- task.rubylibs = FileList.new('lib/**/*')
49
- end
50
- end
51
-
52
42
  task :archive do
53
43
  raise ArgumentError, "You must specify the archive name by setting ARCHIVE; e.g., ARCHIVE=1.5.1rc1" unless archive = ENV["ARCHIVE"]
54
44
 
55
45
  sh "git archive --format=tar --prefix=facter-#{archive}/ HEAD | gzip -c > facter-#{archive}.tgz"
56
46
  end
47
+
48
+ namespace :ci do
49
+
50
+ desc "Run the CI prep tasks"
51
+ task :prep do
52
+ require 'rubygems'
53
+ gem 'ci_reporter'
54
+ require 'ci/reporter/rake/rspec'
55
+ require 'ci/reporter/rake/test_unit'
56
+ ENV['CI_REPORTS'] = 'results'
57
+ end
58
+
59
+ desc "Run CI RSpec tests"
60
+ task :spec => [:prep, 'ci:setup:rspec'] do
61
+ sh "cd spec; rake all; exit 0"
62
+ end
63
+
64
+ end
65
+
66
+ desc "Send patch information to the puppet-dev list"
67
+ task :mail_patches do
68
+ if Dir.glob("00*.patch").length > 0
69
+ raise "Patches already exist matching '00*.patch'; clean up first"
70
+ end
71
+
72
+ unless %x{git status} =~ /On branch (.+)/
73
+ raise "Could not get branch from 'git status'"
74
+ end
75
+ branch = $1
76
+
77
+ unless branch =~ %r{^([^\/]+)/([^\/]+)/([^\/]+)$}
78
+ raise "Branch name does not follow <type>/<parent>/<name> model; cannot autodetect parent branch"
79
+ end
80
+
81
+ type, parent, name = $1, $2, $3
82
+
83
+ # Create all of the patches
84
+ sh "git format-patch -C -M -s -n #{parent}..HEAD"
85
+
86
+ # And then mail them out.
87
+
88
+ # If we've got more than one patch, add --compose
89
+ if Dir.glob("00*.patch").length > 1
90
+ compose = "--compose"
91
+ else
92
+ compose = ""
93
+ end
94
+
95
+ # Now send the mail.
96
+ sh "git send-email #{compose} --no-chain-reply-to --no-signed-off-by-cc --suppress-from --no-thread --to puppet-dev@googlegroups.com 00*.patch"
97
+
98
+ # Finally, clean up the patches
99
+ sh "rm 00*.patch"
100
+ end
data/bin/facter CHANGED
@@ -75,7 +75,8 @@ options = {
75
75
  :yaml => false
76
76
  }
77
77
 
78
- result.each { |opt,arg|
78
+ begin
79
+ result.each { |opt,arg|
79
80
  case opt
80
81
  when "--version"
81
82
  puts "%s" % Facter.version
@@ -101,7 +102,10 @@ result.each { |opt,arg|
101
102
  $stderr.puts "Invalid option '#{opt}'"
102
103
  exit(12)
103
104
  end
104
- }
105
+ }
106
+ rescue
107
+ exit(12)
108
+ end
105
109
 
106
110
  names = []
107
111
 
@@ -49,7 +49,8 @@ function find_facter_root() {
49
49
 
50
50
  function install_facter() {
51
51
  echo "Installing Facter to ${pkgroot}"
52
- "${installer}" --destdir="${pkgroot}" --bindir="${BINDIR}" --sitelibdir="${SITELIBDIR}" &> /dev/null
52
+ cd "$facter_root"
53
+ ./"${INSTALLRB}" --destdir="${pkgroot}" --bindir="${BINDIR}" --sitelibdir="${SITELIBDIR}"
53
54
  chown -R root:admin "${pkgroot}"
54
55
  }
55
56
 
@@ -8,4 +8,5 @@
8
8
  # ${3} is the destination volume so that this works correctly
9
9
  # when being installed to volumes other than the current OS.
10
10
 
11
- rm -Rf "${3}{SITELIBDIR}/facter*"
11
+ /bin/rm -Rf "${3}{SITELIBDIR}/facter"
12
+ /bin/rm -Rf "${3}{SITELIBDIR/facter.rb"
@@ -1,19 +1,19 @@
1
1
  %{!?ruby_sitelibdir: %define ruby_sitelibdir %(ruby -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')}
2
2
 
3
- %define has_ruby_abi 0%{?fedora:%fedora} >= 5 || 0%{?rhel:%rhel} >= 5
3
+ %define has_ruby_abi 0%{?fedora} || 0%{?rhel} >= 5
4
4
  %define has_ruby_noarch %has_ruby_abi
5
5
 
6
6
  Summary: Ruby module for collecting simple facts about a host operating system
7
7
  Name: facter
8
8
  Version: 1.5.2
9
9
  Release: 1%{?dist}
10
- License: GPL
10
+ License: GPLv2+
11
11
  Group: System Environment/Base
12
12
  URL: http://reductivelabs.com/projects/facter
13
13
  Source0: http://reductivelabs.com/downloads/facter/%{name}-%{version}.tgz
14
14
  BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
15
15
  %if %has_ruby_noarch
16
- BuildArchitectures: noarch
16
+ BuildArch: noarch
17
17
  %endif
18
18
 
19
19
  Requires: ruby >= 1.8.1
@@ -23,7 +23,7 @@ Requires: ruby(abi) = 1.8
23
23
  %endif
24
24
  BuildRequires: ruby >= 1.8.1
25
25
 
26
- %description
26
+ %description
27
27
  Ruby module for collecting simple facts about a host Operating
28
28
  system. Some of the facts are preconfigured, such as the hostname and the
29
29
  operating system. Additional facts can be added through simple Ruby scripts
@@ -36,7 +36,7 @@ sed -i -e 's@^#!.*$@#! /usr/bin/ruby@' bin/facter
36
36
 
37
37
  %install
38
38
  rm -rf %{buildroot}
39
- mkdir %{buildroot}
39
+ mkdir -p %{buildroot}
40
40
 
41
41
  %{__install} -d -m0755 %{buildroot}%{ruby_sitelibdir}
42
42
  %{__install} -d -m0755 %{buildroot}%{ruby_sitelibdir}/facter
@@ -60,18 +60,34 @@ rm -rf %{buildroot}
60
60
  %{_bindir}/facter
61
61
  %{ruby_sitelibdir}/facter.rb
62
62
  %{ruby_sitelibdir}/facter
63
- %{ruby_sitelibdir}/facter/util
64
- %{ruby_sitelibdir}/facter/util/plist
65
- %{ruby_sitelibdir}/facter/util/*.rb
66
- %{ruby_sitelibdir}/facter/util/plist/*.rb
67
63
  %doc CHANGELOG COPYING INSTALL LICENSE README
68
64
 
69
65
 
70
66
  %changelog
67
+ * Tue Sep 09 2008 Todd Zullinger <tmz@pobox.com> - 1.5.2-1
68
+ - New version
69
+ - Simplify spec file checking for Fedora and RHEL versions
70
+
71
+ * Mon Sep 8 2008 David Lutterkort <dlutter@redhat.com> - 1.5.1-1
72
+ - New version
73
+
74
+ * Thu Jul 17 2008 David Lutterkort <dlutter@redhat.com> - 1.5.0-3
75
+ - Change 'mkdir' in install to 'mkdir -p'
76
+
77
+ * Thu Jul 17 2008 David Lutterkort <dlutter@redhat.com> - 1.5.0-2
78
+ - Remove files that were listed twice in files section
79
+
71
80
  * Mon May 19 2008 James Turnbull <james@lovedthanlosty.net> - 1.5.0-1
72
81
  - New version
73
82
  - Added util and plist files
74
83
 
84
+ * Mon Sep 24 2007 David Lutterkort <dlutter@redhat.com> - 1.3.8-1
85
+ - Update license tag
86
+ - Copy all of lib/ into ruby_sitelibdir
87
+
88
+ * Thu Mar 29 2007 David Lutterkort <dlutter@redhat.com> - 1.3.7-1
89
+ - New version
90
+
75
91
  * Fri Jan 19 2007 David Lutterkort <dlutter@redhat.com> - 1.3.6-1
76
92
  - New version
77
93
 
data/install.rb CHANGED
File without changes
@@ -1,20 +1,20 @@
1
1
  #--
2
2
  # Copyright 2006 Luke Kanies <luke@madstop.com>
3
- #
3
+ #
4
4
  # This library is free software; you can redistribute it and/or
5
5
  # modify it under the terms of the GNU Lesser General Public
6
6
  # License as published by the Free Software Foundation; either
7
7
  # version 2.1 of the License, or (at your option) any later version.
8
- #
8
+ #
9
9
  # This library is distributed in the hope that it will be useful,
10
10
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
12
  # Lesser General Public License for more details.
13
- #
13
+ #
14
14
  # You should have received a copy of the GNU Lesser General Public
15
15
  # License along with this library; if not, write to the Free Software
16
16
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
- #
17
+ #
18
18
  #--
19
19
 
20
20
  module Facter
@@ -27,7 +27,7 @@ module Facter
27
27
  include Comparable
28
28
  include Enumerable
29
29
 
30
- FACTERVERSION = '1.5.2'
30
+ FACTERVERSION = '1.5.3'
31
31
  # = Facter
32
32
  # Functions as a hash of 'facts' you might care about about your
33
33
  # system, such as mac address, IP address, Video card, etc.
@@ -153,7 +153,7 @@ module Facter
153
153
  case bit
154
154
  when TrueClass: @@debug = 1
155
155
  when FalseClass: @@debug = 0
156
- when Fixnum:
156
+ when Fixnum:
157
157
  if bit > 0
158
158
  @@debug = 1
159
159
  else
@@ -22,7 +22,7 @@ Facter.add(:Cfkey) do
22
22
  "/var/cfengine/ppkeys/localhost.pub",
23
23
  "/var/lib/cfengine/ppkeys/localhost.pub",
24
24
  "/var/lib/cfengine2/ppkeys/localhost.pub"
25
- ].each { |file|
25
+ ].each do |file|
26
26
  if FileTest.file?(file)
27
27
  File.open(file) { |openfile|
28
28
  value = openfile.readlines.reject { |line|
@@ -35,7 +35,7 @@ Facter.add(:Cfkey) do
35
35
  if value
36
36
  break
37
37
  end
38
- }
38
+ end
39
39
 
40
40
  value
41
41
  end
@@ -1,67 +1,36 @@
1
1
  Facter.add(:domain) do
2
2
  setcode do
3
- # First force the hostname to be checked
3
+ # Get the domain from various sources; the order of these
4
+ # steps is important
5
+
4
6
  Facter.value(:hostname)
7
+ next $domain if defined? $domain and ! $domain.nil?
8
+
9
+ domain = Facter::Util::Resolution.exec('dnsdomainname')
10
+ next domain if domain =~ /.+\..+/
11
+
12
+ domain = Facter::Util::Resolution.exec('domainname')
13
+ next domain if domain =~ /.+\..+/
5
14
 
6
- # Now check to see if it set the domain
7
- if defined? $domain and ! $domain.nil?
8
- $domain
9
- else
10
- nil
11
- end
12
- end
13
- end
14
- # Look for the DNS domain name command first.
15
- Facter.add(:domain) do
16
- setcode do
17
- domain = Facter::Util::Resolution.exec('dnsdomainname') or nil
18
- # make sure it's a real domain
19
- if domain and domain =~ /.+\..+/
20
- domain
21
- else
22
- nil
23
- end
24
- end
25
- end
26
- Facter.add(:domain) do
27
- setcode do
28
- domain = Facter::Util::Resolution.exec('domainname') or nil
29
- # make sure it's a real domain
30
- if domain and domain =~ /.+\..+/
31
- domain
32
- else
33
- nil
34
- end
35
- end
36
- end
37
- Facter.add(:domain) do
38
- setcode do
39
- value = nil
40
15
  if FileTest.exists?("/etc/resolv.conf")
16
+ domain = nil
17
+ search = nil
41
18
  File.open("/etc/resolv.conf") { |file|
42
- # is the domain set?
43
19
  file.each { |line|
44
20
  if line =~ /domain\s+(\S+)/
45
- value = $1
46
- break
21
+ domain = $1
22
+ elsif line =~ /search\s+(\S+)/
23
+ search = $1
47
24
  end
48
25
  }
49
26
  }
50
- ! value and File.open("/etc/resolv.conf") { |file|
51
- # is the search path set?
52
- file.each { |line|
53
- if line =~ /search\s+(\S+)/
54
- value = $1
55
- break
56
- end
57
- }
58
- }
59
- value
60
- else
61
- nil
27
+ next domain if domain
28
+ next search if search
62
29
  end
30
+ nil
63
31
  end
64
32
  end
33
+
65
34
  Facter.add(:domain) do
66
35
  confine :kernel => :windows
67
36
  setcode do
@@ -69,9 +38,9 @@ Facter.add(:domain) do
69
38
  domain = ""
70
39
  wmi = WIN32OLE.connect("winmgmts://")
71
40
  query = "select DNSDomain from Win32_NetworkAdapterConfiguration where IPEnabled = True"
72
- wmi.ExecQuery(query).each { |nic|
41
+ wmi.ExecQuery(query).each { |nic|
73
42
  domain = nic.DNSDomain
74
- break
43
+ break
75
44
  }
76
45
  domain
77
46
  end
@@ -1,4 +1,5 @@
1
- Facter.add(:fqdn) do setcode do
1
+ Facter.add(:fqdn) do
2
+ setcode do
2
3
  host = Facter.value(:hostname)
3
4
  domain = Facter.value(:domain)
4
5
  if host and domain
@@ -1,4 +1,4 @@
1
1
  Facter.add(:hardwareisa) do
2
2
  setcode 'uname -p', '/bin/sh'
3
- confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE Debian Gentoo FreeBSD OpenBSD NetBSD}
3
+ confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo FreeBSD OpenBSD NetBSD}
4
4
  end
@@ -1,4 +1,15 @@
1
1
  Facter.add(:id) do
2
- confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS SuSE Debian Gentoo AIX}
2
+ confine :operatingsystem => %w{Linux Fedora RedHat CentOS SuSE SLES Debian Ubuntu Gentoo AIX}
3
3
  setcode "whoami"
4
4
  end
5
+
6
+ Facter.add(:id) do
7
+ confine :operatingsystem => %w{Solaris}
8
+ setcode do
9
+ if %x{id} =~ /^uid=\d+\((\S+)\)/
10
+ $1
11
+ else
12
+ nil
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,32 @@
1
+ # interfaces.rb
2
+ # Try to get additional Facts about the machine's network interfaces
3
+ #
4
+ # Original concept Copyright (C) 2007 psychedelys <psychedelys@gmail.com>
5
+ # Update and *BSD support (C) 2007 James Turnbull <james@lovedthanlost.net>
6
+ #
7
+
8
+ require 'facter/util/ip'
9
+
10
+ # Note that most of this only works on a fixed list of platforms; notably, Darwin
11
+ # is missing.
12
+
13
+ Facter.add(:interfaces) do
14
+ confine :kernel => Facter::Util::IP.supported_platforms
15
+ setcode do
16
+ Facter::Util::IP.get_interfaces.collect { |iface| Facter::Util::IP.alphafy(iface) }.join(",")
17
+ end
18
+ end
19
+
20
+ Facter::Util::IP.get_interfaces.each do |interface|
21
+
22
+ # Make a fact for each detail of each interface. Yay.
23
+ # There's no point in confining these facts, since we wouldn't be able to create
24
+ # them if we weren't running on a supported platform.
25
+ %w{ipaddress macaddress netmask}.each do |label|
26
+ Facter.add(label + "_" + Facter::Util::IP.alphafy(interface)) do
27
+ setcode do
28
+ Facter::Util::IP.get_interface_value(interface, label)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -25,7 +25,7 @@ Facter.add(:ipaddress, :timeout => 2) do
25
25
  # we need Hostname to exist for this to work
26
26
  host = nil
27
27
  if host = Facter::Util::Resolution.exec("host #{hostname}")
28
- host = host.chomp.split(/\s/)
28
+ list = host.chomp.split(/\s/)
29
29
  if defined? list[-1] and
30
30
  list[-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/
31
31
  list[-1]
@@ -14,10 +14,10 @@ Facter.add(:kernelrelease) do
14
14
  version = ""
15
15
  connection_string = "winmgmts://./root/cimv2"
16
16
  wmi = WIN32OLE.connect(connection_string)
17
- wmi.ExecQuery("SELECT Version from Win32_OperatingSystem").each { |ole|
17
+ wmi.ExecQuery("SELECT Version from Win32_OperatingSystem").each do |ole|
18
18
  version = "#{ole.Version}"
19
19
  break
20
- }
20
+ end
21
21
  version
22
22
  end
23
23
  end