-
-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support puppetdb token authentication #73
Conversation
615aeab
to
5ea2333
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with PE and their tokens, but this is a general Ruby thing.
lib/puppet-ghostbuster/puppetdb.rb
Outdated
options = { | ||
server: ENV['PUPPETDB_URL'] || @@puppetdb, | ||
} | ||
|
||
if ENV['PE_TOKEN'] | ||
options[:token] = ENV['PE_TOKEN'] | ||
options[:cacert] = ENV['PUPPETDB_CACERT_FILE'] || Puppet[:localcacert] | ||
else | ||
options[:pem] = { | ||
'key' => ENV['PUPPETDB_KEY_FILE'] || Puppet[:hostprivkey], | ||
'cert' => ENV['PUPPETDB_CERT_FILE'] || Puppet[:hostcert], | ||
'ca_file' => ENV['PUPPETDB_CACERT_FILE'] || Puppet[:localcacert], | ||
} | ||
end | ||
|
||
@@client ||= ::PuppetDB::Client.new(options, 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should use a block to cache. The diff may be hard to read, but it's essentially
@@client ||= begin
# ...
end
options = { | |
server: ENV['PUPPETDB_URL'] || @@puppetdb, | |
} | |
if ENV['PE_TOKEN'] | |
options[:token] = ENV['PE_TOKEN'] | |
options[:cacert] = ENV['PUPPETDB_CACERT_FILE'] || Puppet[:localcacert] | |
else | |
options[:pem] = { | |
'key' => ENV['PUPPETDB_KEY_FILE'] || Puppet[:hostprivkey], | |
'cert' => ENV['PUPPETDB_CERT_FILE'] || Puppet[:hostcert], | |
'ca_file' => ENV['PUPPETDB_CACERT_FILE'] || Puppet[:localcacert], | |
} | |
end | |
@@client ||= ::PuppetDB::Client.new(options, 4) | |
@@client ||= begin | |
options = { | |
server: ENV['PUPPETDB_URL'] || @@puppetdb, | |
} | |
if ENV['PE_TOKEN'] | |
options[:token] = ENV['PE_TOKEN'] | |
options[:cacert] = ENV['PUPPETDB_CACERT_FILE'] || Puppet[:localcacert] | |
else | |
options[:pem] = { | |
'key' => ENV['PUPPETDB_KEY_FILE'] || Puppet[:hostprivkey], | |
'cert' => ENV['PUPPETDB_CERT_FILE'] || Puppet[:hostcert], | |
'ca_file' => ENV['PUPPETDB_CACERT_FILE'] || Puppet[:localcacert], | |
} | |
end | |
::PuppetDB::Client.new(options, 4) | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers. Fixed.
34fc27f
to
e7757b3
Compare
No description provided.