blob: e7fce66b1181eba383ecec0106e2df483bfd86fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
require 'puppet/application'
require 'puppet/face'
class Puppet::Application::Faces < Puppet::Application
should_parse_config
run_mode :agent
option("--debug", "-d") do |arg|
Puppet::Util::Log.level = :debug
end
option("--verbose", "-v") do
Puppet::Util::Log.level = :info
end
def help
<<-HELP
puppet-faces(8) -- List available Faces and actions
========
SYNOPSIS
--------
Lists the available subcommands (with applicable terminuses and/or actions)
provided by the Puppet Faces API. This information is automatically read
from the Puppet code present on the system. By default, the output includes
all terminuses and actions.
USAGE
-----
puppet faces [-d|--debug] [-v|--verbose] [actions|terminuses]
OPTIONS
-------
Note that any configuration option valid in the configuration file is also
a valid long argument. See the configuration file documentation at
http://docs.puppetlabs.com/references/stable/configuration.html for the
full list of acceptable parameters. A commented list of all
configuration options can also be generated by running puppet agent with
'--genconfig'.
* --verbose:
Sets the log level to "info." This option has no tangible effect at the time
of this writing.
* --debug:
Sets the log level to "debug." This option has no tangible effect at the time
of this writing.
AUTHOR
------
Puppet Labs
COPYRIGHT
---------
Copyright (c) 2011 Puppet Labs, LLC Licensed under the Apache 2.0 License
HELP
end
def list(*arguments)
if arguments.empty?
arguments = %w{terminuses actions}
end
faces.each do |name|
str = "#{name}:\n"
if arguments.include?("terminuses")
begin
terms = terminus_classes(name.to_sym)
str << "\tTerminuses: #{terms.join(", ")}\n"
rescue => detail
puts detail.backtrace if Puppet[:trace]
$stderr.puts "Could not load terminuses for #{name}: #{detail}"
end
end
if arguments.include?("actions")
begin
actions = actions(name.to_sym)
str << "\tActions: #{actions.join(", ")}\n"
rescue => detail
puts detail.backtrace if Puppet[:trace]
$stderr.puts "Could not load actions for #{name}: #{detail}"
end
end
print str
end
end
attr_accessor :name, :arguments
def main
list(*arguments)
end
def setup
Puppet::Util::Log.newdestination :console
load_applications # Call this to load all of the apps
@arguments = command_line.args
@arguments ||= []
end
def faces
Puppet::Face.faces
end
def terminus_classes(indirection)
Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort
end
def actions(indirection)
return [] unless face = Puppet::Face[indirection, '0.0.1']
face.load_actions
return face.actions.sort { |a, b| a.to_s <=> b.to_s }
end
def load_applications
command_line.available_subcommands.each do |app|
command_line.require_application app
end
end
end
|