Class: Puppet::Application::Cert

Inherits:
Puppet::Application show all
Defined in:
lib/puppet/application/cert.rb

Constant Summary

Constants inherited from Puppet::Application

DOCPATTERN

Instance Attribute Summary collapse

Attributes inherited from Puppet::Application

#command_line, #options

Instance Method Summary collapse

Methods inherited from Puppet::Application

[], banner, clear!, clear?, controlled_run, exit, find, #handlearg, #help, #initialize, interrupted?, #name, option, option_parser_commands, #preinit, restart!, restart_requested?, #run, #run_command, run_mode, #set_run_mode, should_not_parse_config, should_parse_config, #should_parse_config?, should_parse_config?, stop!, stop_requested?

Methods included from Util

activerecord_version, benchmark, chuser, classproxy, #execfail, #execpipe, execute, logmethods, memory, proxy, recmkdir, secure_open, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, which, withumask

Methods included from Util::POSIX

#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid

Constructor Details

This class inherits a constructor from Puppet::Application

Instance Attribute Details

#allObject

Returns the value of attribute all.



8
9
10
# File 'lib/puppet/application/cert.rb', line 8

def all
  @all
end

#caObject

Returns the value of attribute ca.



8
9
10
# File 'lib/puppet/application/cert.rb', line 8

def ca
  @ca
end

#digestObject

Returns the value of attribute digest.



8
9
10
# File 'lib/puppet/application/cert.rb', line 8

def digest
  @digest
end

#signedObject

Returns the value of attribute signed.



8
9
10
# File 'lib/puppet/application/cert.rb', line 8

def signed
  @signed
end

Instance Method Details

#mainObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/puppet/application/cert.rb', line 50

def main
  if @all
    hosts = :all
  elsif @signed
    hosts = :signed
  else
    hosts = command_line.args.collect { |h| h.downcase }
  end
  begin
    @ca.apply(:revoke, :to => hosts) if subcommand == :destroy
    @ca.apply(subcommand, :to => hosts, :digest => @digest)
  rescue => detail
    puts detail.backtrace if Puppet[:trace]
    puts detail.to_s
    exit(24)
  end
end

#parse_optionsObject



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/puppet/application/cert.rb', line 89

def parse_options
  # handle the bareword subcommand pattern.
  result = super
  unless self.subcommand then
    if sub = self.command_line.args.shift then
      self.subcommand = sub
    else
      help
    end
  end
  result
end

#setupObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/puppet/application/cert.rb', line 68

def setup
  require 'puppet/ssl/certificate_authority'
  exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?

  Puppet::Util::Log.newdestination :console

  if [:generate, :destroy].include? subcommand
    Puppet::SSL::Host.ca_location = :local
  else
    Puppet::SSL::Host.ca_location = :only
  end

  begin
    @ca = Puppet::SSL::CertificateAuthority.new
  rescue => detail
    puts detail.backtrace if Puppet[:trace]
    puts detail.to_s
    exit(23)
  end
end

#subcommandObject



10
11
12
# File 'lib/puppet/application/cert.rb', line 10

def subcommand
  @subcommand
end

#subcommand=(name) ⇒ Object



13
14
15
16
17
# File 'lib/puppet/application/cert.rb', line 13

def subcommand=(name)
  # Handle the nasty, legacy mapping of "clean" to "destroy".
  sub = name.to_sym
  @subcommand = (sub == :clean ? :destroy : sub)
end