jamtur01-facter 1.5.4
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.
- data/bin/facter +152 -0
- metadata +53 -0
data/bin/facter
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# = Synopsis
|
4
|
+
#
|
5
|
+
# Collect and display facts about the system.
|
6
|
+
#
|
7
|
+
# = Usage
|
8
|
+
#
|
9
|
+
# facter [-d|--debug] [-h|--help] [-p|--puppet] [-v|--version] [-y|--yaml] [fact] [fact] [...]
|
10
|
+
#
|
11
|
+
# = Description
|
12
|
+
#
|
13
|
+
# Collect and display facts about the current system. The library behind
|
14
|
+
# Facter is easy to expand, making Facter an easy way to collect information
|
15
|
+
# about a system from within the shell or within Ruby.
|
16
|
+
#
|
17
|
+
# If no facts are specifically asked for, then all facts will be returned.
|
18
|
+
#
|
19
|
+
# = Options
|
20
|
+
#
|
21
|
+
# debug::
|
22
|
+
# Enable debugging.
|
23
|
+
#
|
24
|
+
# help::
|
25
|
+
# Print this help message
|
26
|
+
#
|
27
|
+
# puppet::
|
28
|
+
# Load the Puppet libraries, thus allowing Facter to load Puppet-specific facts.
|
29
|
+
#
|
30
|
+
# version::
|
31
|
+
# Print the version and exit.
|
32
|
+
#
|
33
|
+
# yaml::
|
34
|
+
# Emit facts in YAML format.
|
35
|
+
#
|
36
|
+
# = Example
|
37
|
+
#
|
38
|
+
# facter kernel
|
39
|
+
#
|
40
|
+
# = Author
|
41
|
+
#
|
42
|
+
# Luke Kanies
|
43
|
+
#
|
44
|
+
# = Copyright
|
45
|
+
#
|
46
|
+
# Copyright (c) 2006 Reductive Labs, LLC
|
47
|
+
# Licensed under the GNU Public License
|
48
|
+
|
49
|
+
require 'getoptlong'
|
50
|
+
require 'facter'
|
51
|
+
|
52
|
+
$haveusage = true
|
53
|
+
|
54
|
+
begin
|
55
|
+
require 'rdoc/ri/ri_paths'
|
56
|
+
require 'rdoc/usage'
|
57
|
+
rescue Exception
|
58
|
+
$haveusage = false
|
59
|
+
end
|
60
|
+
|
61
|
+
$debug = 0
|
62
|
+
|
63
|
+
config = nil
|
64
|
+
|
65
|
+
result = GetoptLong.new(
|
66
|
+
[ "--version", "-v", GetoptLong::NO_ARGUMENT ],
|
67
|
+
[ "--help", "-h", GetoptLong::NO_ARGUMENT ],
|
68
|
+
[ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
|
69
|
+
[ "--yaml", "-y", GetoptLong::NO_ARGUMENT ],
|
70
|
+
[ "--config", "-c", GetoptLong::REQUIRED_ARGUMENT ],
|
71
|
+
[ "--puppet", "-p", GetoptLong::NO_ARGUMENT ]
|
72
|
+
)
|
73
|
+
|
74
|
+
options = {
|
75
|
+
:yaml => false
|
76
|
+
}
|
77
|
+
|
78
|
+
begin
|
79
|
+
result.each { |opt,arg|
|
80
|
+
case opt
|
81
|
+
when "--version"
|
82
|
+
puts "%s" % Facter.version
|
83
|
+
exit
|
84
|
+
when "--puppet"
|
85
|
+
begin
|
86
|
+
require 'puppet'
|
87
|
+
rescue LoadError => detail
|
88
|
+
$stderr.puts "Could not load Puppet: %s" % detail
|
89
|
+
end
|
90
|
+
when "--yaml"
|
91
|
+
options[:yaml] = true
|
92
|
+
when "--debug"
|
93
|
+
Facter.debugging(1)
|
94
|
+
when "--help"
|
95
|
+
if $haveusage
|
96
|
+
RDoc::usage && exit
|
97
|
+
else
|
98
|
+
puts "No help available unless you have RDoc::usage installed"
|
99
|
+
exit
|
100
|
+
end
|
101
|
+
else
|
102
|
+
$stderr.puts "Invalid option '#{opt}'"
|
103
|
+
exit(12)
|
104
|
+
end
|
105
|
+
}
|
106
|
+
rescue
|
107
|
+
exit(12)
|
108
|
+
end
|
109
|
+
|
110
|
+
names = []
|
111
|
+
|
112
|
+
unless config.nil?
|
113
|
+
File.open(config) { |file|
|
114
|
+
names = file.readlines.collect { |line|
|
115
|
+
line.chomp
|
116
|
+
}
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
ARGV.each { |item|
|
121
|
+
names.push item
|
122
|
+
}
|
123
|
+
|
124
|
+
if names.empty?
|
125
|
+
facts = Facter.to_hash
|
126
|
+
else
|
127
|
+
facts = {}
|
128
|
+
names.each { |name|
|
129
|
+
begin
|
130
|
+
facts[name] = Facter.value(name)
|
131
|
+
rescue => error
|
132
|
+
STDERR.puts "Could not retrieve %s: #{error}" % name
|
133
|
+
exit 10
|
134
|
+
end
|
135
|
+
}
|
136
|
+
end
|
137
|
+
|
138
|
+
if options[:yaml]
|
139
|
+
require 'yaml'
|
140
|
+
puts YAML.dump(facts)
|
141
|
+
exit(0)
|
142
|
+
end
|
143
|
+
|
144
|
+
facts.sort { |a, b| a[0].to_s <=> b[0].to_s }.each { |name,value|
|
145
|
+
if facts.length == 1
|
146
|
+
unless value.nil?
|
147
|
+
puts value
|
148
|
+
end
|
149
|
+
else
|
150
|
+
puts "%s => %s" % [name,value]
|
151
|
+
end
|
152
|
+
}
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jamtur01-facter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.5.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Luke Kanies
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-03 00:00:00 -08:00
|
13
|
+
default_executable: facter
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Facter -- a cross-platform Ruby library for retrieving facts from operating systems.
|
17
|
+
email: info@reductivelabs.com
|
18
|
+
executables:
|
19
|
+
- facter
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files: []
|
25
|
+
|
26
|
+
has_rdoc: false
|
27
|
+
homepage: http://reductivelabs.com/projects/facter/
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: "0"
|
38
|
+
version:
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
requirements: []
|
46
|
+
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 1.2.0
|
49
|
+
signing_key:
|
50
|
+
specification_version: 2
|
51
|
+
summary: A operating system fact library.
|
52
|
+
test_files: []
|
53
|
+
|