Class: Puppetfactory::Plugins::Certificates

Inherits:
Puppetfactory::Plugins show all
Defined in:
lib/puppetfactory/plugins/certificates.rb

Instance Attribute Summary

Attributes inherited from Puppetfactory::Plugins

#weight

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Certificates

Returns a new instance of Certificates.



4
5
6
7
8
9
# File 'lib/puppetfactory/plugins/certificates.rb', line 4

def initialize(options)
  super(options)

  @puppet = options[:puppet]
  @suffix = options[:usersuffix]
end

Instance Method Details

#delete(username) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/puppetfactory/plugins/certificates.rb', line 11

def delete(username)
  certname = "#{username}.#{@suffix}"

  output, status = Open3.capture2e('puppet', 'cert', 'clean', certname)
  unless status.success?
    $logger.warn "Error cleaning certificate #{certname}: #{output}"
    return false
  end

  $logger.info "Certificate #{certname} removed"
  true
end

#repair(username) ⇒ Object



24
25
26
# File 'lib/puppetfactory/plugins/certificates.rb', line 24

def repair(username)
  delete(username)
end