facter 1.5 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


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

Files changed (41) hide show
  1. data/CHANGELOG +51 -1
  2. data/Rakefile +10 -1
  3. data/conf/osx/PackageInfo.plist +36 -0
  4. data/conf/osx/createpackage.sh +167 -0
  5. data/conf/osx/preflight +11 -0
  6. data/conf/redhat/facter.spec +120 -0
  7. data/conf/solaris/pkginfo +7 -0
  8. data/documentation/custom.page +22 -0
  9. data/documentation/index.page +19 -0
  10. data/install.rb +227 -92
  11. data/lib/facter.rb +1 -1
  12. data/lib/facter/domain.rb +14 -0
  13. data/lib/facter/hardwaremodel.rb +8 -0
  14. data/lib/facter/ipaddress.rb +21 -2
  15. data/lib/facter/ipmess.rb +8 -37
  16. data/lib/facter/kernel.rb +7 -1
  17. data/lib/facter/kernelrelease.rb +16 -1
  18. data/lib/facter/kernelversion.rb +5 -0
  19. data/lib/facter/lsb.rb +1 -0
  20. data/lib/facter/macaddress.rb +15 -1
  21. data/lib/facter/operatingsystem.rb +6 -1
  22. data/lib/facter/operatingsystemrelease.rb +34 -7
  23. data/lib/facter/puppetversion.rb +1 -1
  24. data/lib/facter/util/ip.rb +37 -47
  25. data/lib/facter/util/manufacturer.rb +2 -2
  26. data/lib/facter/util/resolution.rb +13 -3
  27. data/lib/facter/virtual.rb +62 -0
  28. data/spec/Rakefile +18 -0
  29. data/spec/integration/facter.rb +27 -0
  30. data/spec/spec.opts +3 -0
  31. data/spec/spec_helper.rb +25 -0
  32. data/spec/unit/data/linux_ifconfig_all_with_single_interface +18 -0
  33. data/spec/unit/data/solaris_ifconfig_single_interface +3 -0
  34. data/spec/unit/facter.rb +134 -0
  35. data/spec/unit/util/collection.rb +255 -0
  36. data/spec/unit/util/confine.rb +75 -0
  37. data/spec/unit/util/fact.rb +129 -0
  38. data/spec/unit/util/ip.rb +40 -0
  39. data/spec/unit/util/loader.rb +219 -0
  40. data/spec/unit/util/resolution.rb +209 -0
  41. metadata +31 -2
data/CHANGELOG CHANGED
@@ -1,4 +1,54 @@
1
- 1.5:
1
+ 1.5.2:
2
+ Fixed #1562 - Removed facter from PREREQS
3
+
4
+ Fixed #1558 - Updated virtual fact for xenu and xen0
5
+
6
+ Fixed #1555 - Ddded operatingsystemrelease for Solaris
7
+
8
+ Fixed #1559 - Update to dmidecode fact
9
+
10
+ 1.5.1:
11
+ Added a Process.waitall thread when there's a timeout, to avoid zombies.
12
+
13
+ Set the timeout the host-based and resolve-based resolutions to 2.
14
+
15
+ Fixed #1495 - CentOS version detection is now better.
16
+
17
+ Fixed #1422 - Facter now defaults to 0 timeout.
18
+
19
+ Fixes #1492 - added kernelversion fact
20
+
21
+ Added virtual fact
22
+
23
+ Modified the operatingsystem fact for Debian so it looks in
24
+ /etc/debian_version instead of /proc/version.
25
+
26
+ Fixes #1467 - macaddress not set on Ubuntu
27
+
28
+ Adding a rake task for creating an archive.
29
+
30
+ Adding better SuSE detection for both operatingsystem and release.
31
+
32
+ Add sample test and strawman solution for IP parsing code
33
+
34
+ Add module level tests for Facter::IPAddress
35
+
36
+ Fixed #1425 - Solaris
37
+
38
+ Feature #1487: Package creation scripts for Mac OS X
39
+
40
+ Feature #1478: Allow specification of --bindir --sbindir --sitelibdir --mandir
41
+
42
+ Feature #1475: CONFIG['bindir'] CONFIG['sbindir'] have undesirable defaults on
43
+
44
+ Fixes #1467 - macaddress not set on Ubuntu
45
+
46
+ Enabled a number of Windows facts - operating system, domain, ipaddress, macaddress,
47
+ kernel, ipconfig and others
48
+
49
+ 1.5.0:
50
+ Fixed Rakefile to include additional files including tests et al
51
+
2
52
  Fixed #1400 - OperatingSystemRelease should now work on CentOS
3
53
 
4
54
  Changed 'timeout' option to 'limit' to avoid scope issue
data/Rakefile CHANGED
@@ -18,9 +18,12 @@ project = Rake::RedLabProject.new("facter") do |p|
18
18
  'install.rb',
19
19
  '[A-Z]*',
20
20
  'bin/**/*',
21
+ 'lib/facter.rb',
21
22
  'lib/**/*.rb',
22
23
  'test/**/*.rb',
23
- 'doc/**/*',
24
+ 'spec/**/*',
25
+ 'conf/**/*',
26
+ 'documentation/**/*',
24
27
  'etc/*'
25
28
  ]
26
29
 
@@ -45,3 +48,9 @@ if project.has?(:epm)
45
48
  task.rubylibs = FileList.new('lib/**/*')
46
49
  end
47
50
  end
51
+
52
+ task :archive do
53
+ raise ArgumentError, "You must specify the archive name by setting ARCHIVE; e.g., ARCHIVE=1.5.1rc1" unless archive = ENV["ARCHIVE"]
54
+
55
+ sh "git archive --format=tar --prefix=facter-#{archive}/ HEAD | gzip -c > facter-#{archive}.tgz"
56
+ end
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleIdentifier</key>
6
+ <string>com.reductivelabs.facter</string>
7
+ <key>CFBundleShortVersionString</key>
8
+ <string>{SHORTVERSION}</string>
9
+ <key>IFMajorVersion</key>
10
+ <integer>{MAJORVERSION}</integer>
11
+ <key>IFMinorVersion</key>
12
+ <integer>{MINORVERSION}</integer>
13
+ <key>IFPkgFlagAllowBackRev</key>
14
+ <false/>
15
+ <key>IFPkgFlagAuthorizationAction</key>
16
+ <string>RootAuthorization</string>
17
+ <key>IFPkgFlagDefaultLocation</key>
18
+ <string>/</string>
19
+ <key>IFPkgFlagFollowLinks</key>
20
+ <true/>
21
+ <key>IFPkgFlagInstallFat</key>
22
+ <false/>
23
+ <key>IFPkgFlagIsRequired</key>
24
+ <false/>
25
+ <key>IFPkgFlagOverwritePermissions</key>
26
+ <false/>
27
+ <key>IFPkgFlagRelocatable</key>
28
+ <false/>
29
+ <key>IFPkgFlagRestartAction</key>
30
+ <string>None</string>
31
+ <key>IFPkgFlagRootVolumeOnly</key>
32
+ <true/>
33
+ <key>IFPkgFlagUpdateInstalledLanguages</key>
34
+ <false/>
35
+ </dict>
36
+ </plist>
@@ -0,0 +1,167 @@
1
+ #!/bin/bash
2
+ #
3
+ # Script to build an "old style" not flat pkg out of the facter repository.
4
+ #
5
+ # Author: Nigel Kersten (nigelk@google.com)
6
+ #
7
+ # Last Updated: 2008-07-31
8
+ #
9
+ # Copyright 2008 Google Inc.
10
+ #
11
+ # Licensed under the Apache License, Version 2.0 (the "License");
12
+ # you may not use this file except in compliance with the License.
13
+ # You may obtain a copy of the License at
14
+ #
15
+ # http://www.apache.org/licenses/LICENSE-2.0
16
+ #
17
+ # Unless required by applicable law or agreed to in writing, software
18
+ # distributed under the License is distributed on an "AS IS" BASIS,
19
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ # See the License for the specific language governing permissions and
21
+ # limitations under the License
22
+
23
+
24
+ INSTALLRB="install.rb"
25
+ BINDIR="/usr/bin"
26
+ SITELIBDIR="/usr/lib/ruby/site_ruby/1.8"
27
+ PACKAGEMAKER="/Developer/usr/bin/packagemaker"
28
+ PROTO_PLIST="PackageInfo.plist"
29
+ PREFLIGHT="preflight"
30
+
31
+
32
+ function find_installer() {
33
+ # we walk up three directories to make this executable from the root,
34
+ # root/conf or root/conf/osx
35
+ if [ -f "./${INSTALLRB}" ]; then
36
+ installer="$(pwd)/${INSTALLRB}"
37
+ elif [ -f "../${INSTALLRB}" ]; then
38
+ installer="$(pwd)/../${INSTALLRB}"
39
+ elif [ -f "../../${INSTALLRB}" ]; then
40
+ installer="$(pwd)/../${INSTALLRB}"
41
+ else
42
+ installer=""
43
+ fi
44
+ }
45
+
46
+ function find_facter_root() {
47
+ facter_root=$(dirname "${installer}")
48
+ }
49
+
50
+ function install_facter() {
51
+ echo "Installing Facter to ${pkgroot}"
52
+ "${installer}" --destdir="${pkgroot}" --bindir="${BINDIR}" --sitelibdir="${SITELIBDIR}" &> /dev/null
53
+ chown -R root:admin "${pkgroot}"
54
+ }
55
+
56
+ function get_facter_version() {
57
+ facter_version=$(RUBYLIB="${pkgroot}/${SITELIBDIR}:${RUBYLIB}" ruby -e "require 'facter'; puts Facter.version")
58
+ }
59
+
60
+ function prepare_package() {
61
+ # As we can't specify to follow symlinks from the command line, we have
62
+ # to go through the hassle of creating an Info.plist file for packagemaker
63
+ # to look at for package creation and substitue the version strings out.
64
+ # Major/Minor versions can only be integers, so we have "1" and "50" for
65
+ # facter version 1.5
66
+ # Note too that for 10.5 compatibility this Info.plist *must* be set to
67
+ # follow symlinks.
68
+ VER1=$(echo ${facter_version} | awk -F "." '{print $1}')
69
+ VER2=$(echo ${facter_version} | awk -F "." '{print $2}')
70
+ VER3=$(echo ${facter_version} | awk -F "." '{print $3}')
71
+ major_version="${VER1}"
72
+ minor_version="${VER2}${VER3}"
73
+ cp "${facter_root}/conf/osx/${PROTO_PLIST}" "${pkgtemp}"
74
+ sed -i '' "s/{SHORTVERSION}/${facter_version}/g" "${pkgtemp}/${PROTO_PLIST}"
75
+ sed -i '' "s/{MAJORVERSION}/${major_version}/g" "${pkgtemp}/${PROTO_PLIST}"
76
+ sed -i '' "s/{MINORVERSION}/${minor_version}/g" "${pkgtemp}/${PROTO_PLIST}"
77
+
78
+ # We need to create a preflight script to remove traces of previous
79
+ # facter installs due to limitations in Apple's pkg format.
80
+ mkdir "${pkgtemp}/scripts"
81
+ cp "${facter_root}/conf/osx/${PREFLIGHT}" "${pkgtemp}/scripts"
82
+
83
+ # substitute in the sitelibdir specified above on the assumption that this
84
+ # is where any previous facter install exists that should be cleaned out.
85
+ sed -i '' "s|{SITELIBDIR}|${SITELIBDIR}|g" "${pkgtemp}/scripts/${PREFLIGHT}"
86
+ chmod 0755 "${pkgtemp}/scripts/${PREFLIGHT}"
87
+ }
88
+
89
+ function create_package() {
90
+ rm -fr "$(pwd)/facter-${facter_version}.pkg"
91
+ echo "Building package"
92
+ echo "Note that packagemaker is reknowned for spurious errors. Don't panic."
93
+ "${PACKAGEMAKER}" --root "${pkgroot}" \
94
+ --info "${pkgtemp}/${PROTO_PLIST}" \
95
+ --scripts ${pkgtemp}/scripts \
96
+ --out "$(pwd)/facter-${facter_version}.pkg"
97
+ if [ $? -ne 0 ]; then
98
+ echo "There was a problem building the package."
99
+ cleanup_and_exit 1
100
+ exit 1
101
+ else
102
+ echo "The package has been built at:"
103
+ echo "$(pwd)/facter-${facter_version}.pkg"
104
+ fi
105
+ }
106
+
107
+ function cleanup_and_exit() {
108
+ if [ -d "${pkgroot}" ]; then
109
+ rm -fr "${pkgroot}"
110
+ fi
111
+ if [ -d "${pkgtemp}" ]; then
112
+ rm -fr "${pkgtemp}"
113
+ fi
114
+ exit $1
115
+ }
116
+
117
+ # Program entry point
118
+ function main() {
119
+
120
+ if [ $(whoami) != "root" ]; then
121
+ echo "This script needs to be run as root via su or sudo."
122
+ cleanup_and_exit 1
123
+ fi
124
+
125
+ find_installer
126
+
127
+ if [ ! "${installer}" ]; then
128
+ echo "Unable to find ${INSTALLRB}"
129
+ cleanup_and_exit 1
130
+ fi
131
+
132
+ find_facter_root
133
+
134
+ if [ ! "${facter_root}" ]; then
135
+ echo "Unable to find facter repository root."
136
+ cleanup_and_exit 1
137
+ fi
138
+
139
+ pkgroot=$(mktemp -d -t facterpkg)
140
+
141
+ if [ ! "${pkgroot}" ]; then
142
+ echo "Unable to create temporary package root."
143
+ cleanup_and_exit 1
144
+ fi
145
+
146
+ pkgtemp=$(mktemp -d -t factertmp)
147
+
148
+ if [ ! "${pkgtemp}" ]; then
149
+ echo "Unable to create temporary package root."
150
+ cleanup_and_exit 1
151
+ fi
152
+
153
+ install_facter
154
+ get_facter_version
155
+
156
+ if [ ! "${facter_version}" ]; then
157
+ echo "Unable to retrieve facter version"
158
+ cleanup_and_exit 1
159
+ fi
160
+
161
+ prepare_package
162
+ create_package
163
+
164
+ cleanup_and_exit 0
165
+ }
166
+
167
+ main "$@"
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+ #
3
+ # Make sure that old facter cruft is removed
4
+ # This also allows us to downgrade facter as
5
+ # it's more likely that installing old versions
6
+ # over new will cause issues.
7
+ #
8
+ # ${3} is the destination volume so that this works correctly
9
+ # when being installed to volumes other than the current OS.
10
+
11
+ rm -Rf "${3}{SITELIBDIR}/facter*"
@@ -0,0 +1,120 @@
1
+ %{!?ruby_sitelibdir: %define ruby_sitelibdir %(ruby -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')}
2
+
3
+ %define has_ruby_abi 0%{?fedora:%fedora} >= 5 || 0%{?rhel:%rhel} >= 5
4
+ %define has_ruby_noarch %has_ruby_abi
5
+
6
+ Summary: Ruby module for collecting simple facts about a host operating system
7
+ Name: facter
8
+ Version: 1.5.2
9
+ Release: 1%{?dist}
10
+ License: GPL
11
+ Group: System Environment/Base
12
+ URL: http://reductivelabs.com/projects/facter
13
+ Source0: http://reductivelabs.com/downloads/facter/%{name}-%{version}.tgz
14
+ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
15
+ %if %has_ruby_noarch
16
+ BuildArchitectures: noarch
17
+ %endif
18
+
19
+ Requires: ruby >= 1.8.1
20
+ Requires: which
21
+ %if %has_ruby_abi
22
+ Requires: ruby(abi) = 1.8
23
+ %endif
24
+ BuildRequires: ruby >= 1.8.1
25
+
26
+ %description
27
+ Ruby module for collecting simple facts about a host Operating
28
+ system. Some of the facts are preconfigured, such as the hostname and the
29
+ operating system. Additional facts can be added through simple Ruby scripts
30
+
31
+ %prep
32
+ %setup -q
33
+
34
+ %build
35
+ sed -i -e 's@^#!.*$@#! /usr/bin/ruby@' bin/facter
36
+
37
+ %install
38
+ rm -rf %{buildroot}
39
+ mkdir %{buildroot}
40
+
41
+ %{__install} -d -m0755 %{buildroot}%{ruby_sitelibdir}
42
+ %{__install} -d -m0755 %{buildroot}%{ruby_sitelibdir}/facter
43
+ %{__install} -d -m0755 %{buildroot}%{ruby_sitelibdir}/facter/util
44
+ %{__install} -d -m0755 %{buildroot}%{ruby_sitelibdir}/facter/util/plist
45
+ %{__install} -d -m0755 %{buildroot}%{_bindir}
46
+ %{__install} -d -m0755 %{buildroot}%{_docdir}/%{name}-%{version}
47
+
48
+ %{__install} -p -m0644 lib/*.rb %{buildroot}%{ruby_sitelibdir}
49
+ %{__install} -p -m0644 lib/facter/*.rb %{buildroot}%{ruby_sitelibdir}/facter
50
+ %{__install} -p -m0644 lib/facter/util/*.rb %{buildroot}%{ruby_sitelibdir}/facter/util
51
+ %{__install} -p -m0644 lib/facter/util/plist/*.rb %{buildroot}%{ruby_sitelibdir}/facter/util/plist
52
+ %{__install} -p -m0755 bin/facter %{buildroot}%{_bindir}
53
+
54
+ %clean
55
+ rm -rf %{buildroot}
56
+
57
+
58
+ %files
59
+ %defattr(-,root,root,-)
60
+ %{_bindir}/facter
61
+ %{ruby_sitelibdir}/facter.rb
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
+ %doc CHANGELOG COPYING INSTALL LICENSE README
68
+
69
+
70
+ %changelog
71
+ * Mon May 19 2008 James Turnbull <james@lovedthanlosty.net> - 1.5.0-1
72
+ - New version
73
+ - Added util and plist files
74
+
75
+ * Fri Jan 19 2007 David Lutterkort <dlutter@redhat.com> - 1.3.6-1
76
+ - New version
77
+
78
+ * Thu Jan 18 2007 David Lutterkort <dlutter@redhat.com> - 1.3.5-3
79
+ - require which; facter is very unhappy without it
80
+
81
+ * Mon Nov 20 2006 David Lutterkort <dlutter@redhat.com> - 1.3.5-2
82
+ - Make require ruby(abi) and buildarch: noarch conditional for fedora 5 or
83
+ later to allow building on older fedora releases
84
+
85
+ * Tue Oct 10 2006 David Lutterkort <dlutter@redhat.com> - 1.3.5-1
86
+ - New version
87
+
88
+ * Tue Sep 26 2006 David Lutterkort <dlutter@redhat.com> - 1.3.4-1
89
+ - New version
90
+
91
+ * Wed Sep 13 2006 David Lutterkort <dlutter@redhat.com> - 1.3.3-2
92
+ - Rebuilt for FC6
93
+
94
+ * Wed Jun 28 2006 David Lutterkort <dlutter@redhat.com> - 1.3.3-1
95
+ - Rebuilt
96
+
97
+ * Fri Jun 19 2006 Luke Kanies <luke@madstop.com> - 1.3.0-1
98
+ - Fixed spec file to work again with the extra memory and processor files.
99
+ - Require ruby(abi). Build as noarch
100
+
101
+ * Fri Jun 9 2006 Luke Kanies <luke@madstop.com> - 1.3.0-1
102
+ - Added memory.rb and processor.rb
103
+
104
+ * Mon Apr 17 2006 David Lutterkort <dlutter@redhat.com> - 1.1.4-4
105
+ - Rebuilt with changed upstream tarball
106
+
107
+ * Tue Mar 21 2006 David Lutterkort <dlutter@redhat.com> - 1.1.4-3
108
+ - Do not rely on install.rb, it will be deleted upstream
109
+
110
+ * Mon Mar 13 2006 David Lutterkort <dlutter@redhat.com> - 1.1.4-2
111
+ - Commented out noarch; requires fix for bz184199
112
+
113
+ * Mon Mar 6 2006 David Lutterkort <dlutter@redhat.com> - 1.1.4-1
114
+ - Removed unused macros
115
+
116
+ * Mon Feb 6 2006 David Lutterkort <dlutter@redhat.com> - 1.1.1-2
117
+ - Fix BuildRoot. Add dist to release tag
118
+
119
+ * Wed Jan 11 2006 David Lutterkort <dlutter@redhat.com> - 1.1.1-1
120
+ - Initial build.
@@ -0,0 +1,7 @@
1
+ PKG=CSWfacter
2
+ NAME=facter - System Fact Gatherer
3
+ VERSION=1.3.5
4
+ CATEGORY=application
5
+ VENDOR=http://reductivelabs.com/projects/facter
6
+ HOTLINE=http://reductivelabs.com/cgi-bin/facter.cgi
7
+ EMAIL=luke@madstop.com
@@ -0,0 +1,22 @@
1
+ ---
2
+ inMenu: true
3
+ directoryName: Custom Facts
4
+ ---
5
+
6
+ Facter does everything it can to make adding custom facts easy. It will
7
+ autoload any files it finds in a ``facter/`` directory in its search
8
+ path, so you don't need to modify the package files. Also, Facter will
9
+ search through your environment for any variables whose names start with
10
+ 'FACTER_' (case insensitive) and automatically add those facts.
11
+
12
+ As a simple example, here is how I publish my home directory to Puppet:
13
+
14
+ Facter.add("home") do
15
+ setcode do
16
+ ENV['HOME']
17
+ end
18
+ end
19
+
20
+ I have ~/lib/ruby in my $RUBYLIB environment variable, so I just created
21
+ ~/lib/ruby/facter and dropped the above code into a ``home.rb`` file
22
+ within that directory.