File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Class: datadog_agent::integrations::kong
2+ #
3+ # This class will install the necessary configuration for the Kong integration
4+ #
5+ # Note: if you're Cassandra data-store is large in size the `/status` page may
6+ # take a long time to return.
7+ # <https://github.com/Mashape/kong/issues/1323>
8+ #
9+ # Parameters:
10+ # $instances:
11+ # Array of hashes for all Kong instances and associated tags. See example
12+ #
13+ # Sample Usage:
14+ #
15+ # class { 'datadog_agent::integrations::kong':
16+ # instances => [
17+ # {
18+ # 'status_url' => http://localhost:8001/status/',
19+ # },
20+ # {
21+ # 'status_url' => 'http://localhost:8001/status/',
22+ # 'tags' => ['instance:foo'],
23+ # },
24+ # ],
25+ # }
26+ #
27+ class datadog_agent::integrations::kong (
28+ $instances = [
29+ {
30+ ' status_url' => ' http://localhost:8001/status/' ,
31+ ' tags' => []
32+ }
33+ ]
34+ ) inherits datadog_agent::params {
35+ include datadog_agent
36+
37+ file { "${datadog_agent::params::conf_dir}/kong.yaml" :
38+ ensure => file ,
39+ owner => $datadog_agent::params::dd_user ,
40+ group => $datadog_agent::params::dd_group ,
41+ mode => ' 0644' ,
42+ content => template (' datadog_agent/agent-conf.d/kong.yaml.erb' ),
43+ require => Package[$datadog_agent::params::package_name ],
44+ notify => Service[$datadog_agent::params::service_name ]
45+ }
46+ }
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe 'datadog_agent::integrations::kong' do
4+ let ( :facts ) { {
5+ operatingsystem : 'Ubuntu' ,
6+ } }
7+ let ( :conf_dir ) { '/etc/dd-agent/conf.d' }
8+ let ( :dd_user ) { 'dd-agent' }
9+ let ( :dd_group ) { 'root' }
10+ let ( :dd_package ) { 'datadog-agent' }
11+ let ( :dd_service ) { 'datadog-agent' }
12+ let ( :conf_file ) { "#{ conf_dir } /kong.yaml" }
13+
14+ it { should compile . with_all_deps }
15+ it { should contain_file ( conf_file ) . with (
16+ owner : dd_user ,
17+ group : dd_group ,
18+ mode : '0644' ,
19+ ) }
20+ it { should contain_file ( conf_file ) . that_requires ( "Package[#{ dd_package } ]" ) }
21+ it { should contain_file ( conf_file ) . that_notifies ( "Service[#{ dd_service } ]" ) }
22+
23+ context 'with default parameters' do
24+ it { should contain_file ( conf_file ) . with_content ( %r{kong_status_url: http://localhost:8001/status/} ) }
25+ end
26+
27+ context 'with params set' do
28+ let ( :params ) { {
29+ instances : [
30+ {
31+ 'status_url' => 'http://foo.bar:8080/status/' ,
32+ 'tags' => [ 'baz' ]
33+ }
34+ ]
35+ } }
36+
37+ it { should contain_file ( conf_file ) . with_content ( %r{tags:\n .*- baz} ) }
38+ it { should contain_file ( conf_file ) . with_content ( %r{kong_status_url: http://foo.bar:8080/status/} ) }
39+ end
40+ end
Original file line number Diff line number Diff line change 1+ #
2+ # MANAGED BY PUPPET
3+ #
4+
5+ init_config:
6+
7+ instances:
8+ <% @instances.each do |instance| -%>
9+ - kong_status_url: <%= instance["status_url"] %>
10+ <%- if instance.key?("tags") and not instance["tags"].empty? -%>
11+ tags:
12+ <%- instance["tags"].each do |tag| -%>
13+ - <%= tag %>
14+ <%- end -%>
15+ <%- end -%>
16+ <% end -%>
You can’t perform that action at this time.
0 commit comments