File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313# The postgres port number
1414# $username
1515# The username for the datadog user
16+ # $use_psycopg2
17+ # Boolean to flag connecting to postgres with psycopg2 instead of pg8000.
18+ # Warning, psycopg2 doesn't support ssl mode.
1619# $tags
1720# Optional array of tags
1821# $tables
5457 $dbname = ' postgres' ,
5558 $port = ' 5432' ,
5659 $username = ' datadog' ,
60+ $use_psycopg2 = false ,
5761 $tags = [],
5862 $tables = [],
5963 $custom_metrics = {},
6266
6367 validate_array($tags )
6468 validate_array($tables )
69+ validate_bool($use_psycopg2 )
6570
6671 file { "${datadog_agent::params::conf_dir}/postgres.yaml" :
6772 ensure => file ,
Original file line number Diff line number Diff line change 3535 it { should contain_file ( conf_file ) . with_content ( %r{dbname: postgres} ) }
3636 it { should contain_file ( conf_file ) . with_content ( %r{port: 5432} ) }
3737 it { should contain_file ( conf_file ) . with_content ( %r{username: datadog} ) }
38+ it { should contain_file ( conf_file ) . without_content ( %r{^\s *use_psycopg2: } ) }
3839 it { should contain_file ( conf_file ) . without_content ( %r{tags: } ) }
3940 it { should contain_file ( conf_file ) . without_content ( %r{^[^#]*relations: } ) }
4041 end
4142
43+ context 'with use_psycopg2 enabled' do
44+ let ( :params ) { {
45+ use_psycopg2 : true ,
46+ password : 'abc123' ,
47+ } }
48+ it { should contain_file ( conf_file ) . with_content ( %r{use_psycopg2: true} ) }
49+ end
50+
4251 context 'with parameters set' do
4352 let ( :params ) { {
4453 host : 'postgres1' ,
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ instances:
66# username: my_username
77# password: my_password
88# dbname: db_name
9+ # use_psycopg2: false # Force using psycogp2 instead of pg8000 to connect. WARNING: psycopg2 doesn't support ssl mode.
910# tags:
1011# - optional_tag1
1112# - optional_tag2
@@ -15,6 +16,9 @@ instances:
1516 username: <%= @username %>
1617 password: <%= @password %>
1718 dbname: <%= @dbname %>
19+ <% if @use_psycopg2 == true -%>
20+ use_psycopg2: true
21+ <% end -%>
1822<% if @tags and ! @tags.empty? -%>
1923 tags:
2024 <%- Array(@tags).each do |tag| -%>
You can’t perform that action at this time.
0 commit comments