File tree Expand file tree Collapse file tree 5 files changed +41
-0
lines changed
templates/server/puppetserver/conf.d Expand file tree Collapse file tree 5 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 538538# invokes when on static_file_content requests.
539539# Defaults to undef
540540#
541+ # $server_jolokia_metrics_whitelist:: The whitelist of clients that
542+ # can query the jolokia /metrics/v2 endpoint
543+ #
541544# === Usage:
542545#
543546# * Simple usage:
733736 Optional[Integer[1]] $server_max_open_files = $puppet::params::server_max_open_files ,
734737 Optional[Stdlib::Absolutepath] $server_versioned_code_id = undef ,
735738 Optional[Stdlib::Absolutepath] $server_versioned_code_content = undef ,
739+ Array[String[1]] $server_jolokia_metrics_whitelist = [],
736740) inherits puppet::params {
737741 contain puppet::config
738742
Original file line number Diff line number Diff line change 331331# $versioned_code_content:: Contains the path to an executable script that Puppet Server invokes when an agent makes
332332# a static_file_content API request for the contents of a file resource that
333333# has a source attribute with a puppet:/// URI value.
334+ #
335+ # $jolokia_metrics_whitelist:: The whitelist of clients that
336+ # can query the jolokia /metrics/v2 endpoint
334337class puppet::server (
335338 Variant[Boolean, Stdlib::Absolutepath] $autosign = $puppet::autosign,
336339 Array[String] $autosign_entries = $puppet::autosign_entries,
449452 Optional[Integer[1]] $max_open_files = $puppet::server_max_open_files ,
450453 Optional[Stdlib::Absolutepath] $versioned_code_id = $puppet::server_versioned_code_id ,
451454 Optional[Stdlib::Absolutepath] $versioned_code_content = $puppet::server_versioned_code_content ,
455+ Array[String[1]] $jolokia_metrics_whitelist = $puppet::server_jolokia_metrics_whitelist ,
452456) {
453457 # For Puppetserver, certain configuration parameters are version specific. We
454458 # assume a particular version here.
Original file line number Diff line number Diff line change 144144 $versioned_code_id = $puppet::server::versioned_code_id,
145145 $versioned_code_content = $puppet::server::versioned_code_content,
146146 $disable_fips = $facts[' os' ][' family' ] == ' RedHat' and $facts[' os' ][' release' ][' major' ] == ' 8' ,
147+ $jolokia_metrics_whitelist = $puppet::server::jolokia_metrics_whitelist,
147148) {
148149 include puppet::server
149150
Original file line number Diff line number Diff line change 572572 }
573573 end
574574 end
575+
576+ describe 'jolokia_metrics_whitelist' do
577+ let ( :content ) { catalogue . resource ( 'file' , auth_conf ) . send ( :parameters ) [ :content ] }
578+ let ( :rules ) { Hocon . parse ( content ) [ 'authorization' ] [ 'rules' ] }
579+ let ( :rule ) { rules . find { |rule | rule [ 'name' ] == 'jolokia metrics' } }
580+
581+ context 'by default' do
582+ it { expect ( rule ) . to be_nil }
583+ end
584+
585+ context 'when set' do
586+ let ( :params ) { super ( ) . merge ( server_jolokia_metrics_whitelist : [ 'localhost' , 'host.example.com' ] ) }
587+
588+ it { expect ( rule [ 'match-request' ] [ 'path' ] ) . to eq ( '/metrics/v2' ) }
589+ it { expect ( rule [ 'allow' ] ) . to eq ( [ 'localhost' , 'host.example.com' ] ) }
590+ end
591+ end
575592 end
576593 end
577594end
Original file line number Diff line number Diff line change @@ -356,6 +356,21 @@ authorization: {
356356 sort-order: 500
357357 name: "puppetlabs experimental"
358358 },
359+ <%- end -%>
360+ <%- unless @jolokia_metrics_whitelist.empty? -%>
361+ {
362+ match-request: {
363+ path: "/metrics/v2"
364+ type: path
365+ }
366+ allow: [
367+ <%- @jolokia_metrics_whitelist.each do |client| -%>
368+ "<%= client %> ",
369+ <%- end -%>
370+ ]
371+ sort-order: 500
372+ name: "jolokia metrics"
373+ },
359374<%- end -%>
360375 {
361376 # Deny everything else. This ACL is not strictly
You can’t perform that action at this time.
0 commit comments