Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ Once the `datadog_agent` module is installed on your `puppetserver`/`puppetmaste

```conf
class { 'datadog_agent':
api_key => "<YOUR_DD_API_KEY>",
api_key => Sensitive("<YOUR_DD_API_KEY>"),
}
```

If using a Datadog site other than the default 'datadoghq.com', set it here as well:

```conf
class { 'datadog_agent':
api_key => "<YOUR_DD_API_KEY>",
api_key => Sensitive("<YOUR_DD_API_KEY>"),
datadog_site => "datadoghq.eu",
}
```
Expand All @@ -63,7 +63,7 @@ Once the `datadog_agent` module is installed on your `puppetserver`/`puppetmaste

```conf
class { 'datadog_agent':
api_key => "<YOUR_DD_API_KEY>",
api_key => Sensitive("<YOUR_DD_API_KEY>"),
service_provider => 'upstart'
}
```
Expand All @@ -84,7 +84,7 @@ Once the `datadog_agent` module is installed on your `puppetserver`/`puppetmaste

```conf
class { 'datadog_agent':
api_key => "<YOUR_DD_API_KEY>",
api_key => Sensitive("<YOUR_DD_API_KEY>"),
integrations => {
"ntp" => {
init_config => {},
Expand Down Expand Up @@ -128,7 +128,7 @@ To enable reporting of Puppet runs to your Datadog timeline, enable the report p

```ruby
class { 'datadog-agent':
api_key => '<YOUR_DD_API_KEY>',
api_key => Sensitive('<YOUR_DD_API_KEY>'),
puppet_run_reports => true
# ...
}
Expand Down Expand Up @@ -265,7 +265,7 @@ If you don't see any reports coming in, check your Puppet server logs.
2. Add this to each node's `site.pp` file:
```conf
class { "datadog_agent":
api_key => "<YOUR_DD_API_KEY>",
api_key => Sensitive("<YOUR_DD_API_KEY>"),
puppet_run_reports => true
}
```
Expand All @@ -288,7 +288,7 @@ To generate tags from custom facts classify your nodes with Puppet facts as an a

```conf
class { "datadog_agent":
api_key => "<YOUR_DD_API_KEY>",
api_key => Sensitive("<YOUR_DD_API_KEY>"),
facts_to_tags => ["os.family","networking.domain","my_custom_fact"],
}
```
Expand Down
2 changes: 1 addition & 1 deletion environments/etc/installer-manifests/site.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node default {
class { 'datadog_agent':
api_key => 'somenonnullapikeythats32charlong',
api_key => Sensitive('somenonnullapikeythats32charlong'),
manage_install => false,
datadog_installer_enabled => true,
apm_instrumentation_enabled => 'host',
Expand Down
2 changes: 1 addition & 1 deletion environments/etc/manifests/site.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
node default {
class { 'datadog_agent':
api_key => 'somenonnullapikeythats32charlong',
api_key => Sensitive('somenonnullapikeythats32charlong'),
agent_extra_options => {
use_http => true,
},
Expand Down
6 changes: 3 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
# OR
#
# class { 'datadog_agent':
# api_key => 'your key',
# api_key => Sensitive('your key'),
# tags => ['env:production', 'linux'],
# puppet_run_reports => false,
# puppetmaster_user => puppet,
Expand All @@ -261,7 +261,7 @@
String $dd_url = '',
String $datadog_site = $datadog_agent::params::datadog_site,
String $host = '',
String $api_key = 'your_API_key',
Sensitive[String] $api_key = Sensitive('your_API_key'),
Enum['datadog-agent', 'Datadog Agent', 'datadog-iot-agent'] $agent_flavor = $datadog_agent::params::package_name,
Boolean $collect_ec2_tags = false,
Boolean $collect_gce_tags = false,
Expand Down Expand Up @@ -762,7 +762,7 @@
$_trusted_facts_tags = datadog_agent::tag6($trusted_facts_to_tags, true, $trusted)

$_agent_config = {
'api_key' => $api_key,
'api_key' => $api_key.unwrap,
'dd_url' => $dd_url,
'site' => $datadog_site,
'cmd_port' => $cmd_port,
Expand Down
4 changes: 2 additions & 2 deletions manifests/installer_telemetry.pp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# This class handles the installation telemetry for the Datadog installer.
#
# @param api_key String:Your DataDog API Key.
# @param api_key Sensitive[String]:Your DataDog API Key.
# @param datadog_site String: The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com'.
# @param packages_to_install String: The packages to be installed by the Datadog installer.
#
class datadog_agent::installer_telemetry (
String $api_key = 'your_API_key',
Sensitive[String] $api_key = Sensitive('your_API_key'),
String $datadog_site = 'datadoghq.com',
String $packages_to_install = 'datadog-agent',
) {
Expand Down
4 changes: 2 additions & 2 deletions manifests/redhat_installer.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Class: datadog_agent::redhat_installer
# This class installs and configures the Datadog agent on RedHat-based systems.
#
# @param api_key String:Your DataDog API Key.
# @param api_key Sensitive[String]:Your DataDog API Key.
# @param datadog_site String: The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com'.
# @param agent_major_version Integer: The major version of the Datadog agent to install. Defaults to 7.
# @param agent_minor_version Optional[String]: The minor version of the Datadog agent to install.
Expand All @@ -13,7 +13,7 @@
# @param remote_policies Boolean: Whether to enable Agent remote policies. Default: false.
#
class datadog_agent::redhat_installer (
String $api_key = 'your_API_key',
Sensitive[String] $api_key = Sensitive('your_API_key'),
String $datadog_site = $datadog_agent::params::datadog_site,
Integer $agent_major_version = $datadog_agent::params::default_agent_major_version,
Optional[String] $agent_minor_version = undef,
Expand Down
5 changes: 2 additions & 3 deletions manifests/reports.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# the datadog service.
#
# Parameters:
# $api_key:
# Your DataDog API Key. Please replace with your key value
# @param api_key Sensitive[String]:Your DataDog API Key.
# $datadog_site:
# URL to use to talk to the Datadog API
#
Expand All @@ -16,7 +15,7 @@
# Sample Usage:
#
class datadog_agent::reports (
String $api_key,
Sensitive[String] $api_key,
String $puppetmaster_user,
String $dogapi_version,
Boolean $manage_dogapi_gem = true,
Expand Down
4 changes: 2 additions & 2 deletions manifests/suse_installer.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Class: datadog_agent::suse_installer
# This class installs and configures the Datadog agent on RedHat-based systems.
#
# @param api_key String:Your DataDog API Key.
# @param api_key Sensitive[String]:Your DataDog API Key.
# @param datadog_site String: The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com'.
# @param agent_major_version Integer: The major version of the Datadog agent to install. Defaults to 7.
# @param agent_minor_version Optional[String]: The minor version of the Datadog agent to install.
Expand All @@ -13,7 +13,7 @@
# @param remote_policies Boolean: Whether to enable Agent remote policies. Default: false.
#
class datadog_agent::suse_installer (
String $api_key = 'your_API_key',
Sensitive[String] $api_key = Sensitive('your_API_key'),
String $datadog_site = $datadog_agent::params::datadog_site,
Integer $agent_major_version = $datadog_agent::params::default_agent_major_version,
Optional[String] $agent_minor_version = undef,
Expand Down
4 changes: 2 additions & 2 deletions manifests/ubuntu_installer.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Class: datadog_agent::ubuntu_installer
# This class installs and configures the Datadog agent on Debian distributions.
#
# @param api_key String:Your DataDog API Key.
# @param api_key Sensitive[String]:Your DataDog API Key.
# @param datadog_site String: The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com'.
# @param agent_major_version Integer: The major version of the Datadog agent to install. Defaults to 7.
# @param agent_minor_version Optional[String]: The minor version of the Datadog agent to install.
Expand All @@ -18,7 +18,7 @@
# @param remote_policies Boolean: Whether to enable Agent remote policies. Default: false.
#
class datadog_agent::ubuntu_installer (
String $api_key = 'your_API_key',
Sensitive[String] $api_key = Sensitive('your_API_key'),
String $datadog_site = $datadog_agent::params::datadog_site,
Integer $agent_major_version = $datadog_agent::params::default_agent_major_version,
Optional[String] $agent_minor_version = undef,
Expand Down
2 changes: 1 addition & 1 deletion manifests/windows.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
String $agent_version = $datadog_agent::params::agent_version,
Optional[String] $agent_repo_uri = undef,
String $msi_location = 'C:/Windows/temp',
String $api_key = $datadog_agent::api_key,
Sensitive[String] $api_key = $datadog_agent::api_key,
String $hostname = $datadog_agent::host,
Array $tags = $datadog_agent::tags,
String $tags_join = join($tags,','),
Expand Down
10 changes: 5 additions & 5 deletions spec/classes/datadog_agent_reports_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
context 'all supported operating systems' do
let(:params) do
{
api_key: 'notanapikey',
api_key: Sensitive('notanapikey'),
puppetmaster_user: 'puppet',
dogapi_version: 'installed',
}
Expand Down Expand Up @@ -79,7 +79,7 @@
context 'specific dogapi version' do
let(:params) do
{
api_key: 'notanapikey',
api_key: Sensitive('notanapikey'),
puppetmaster_user: 'puppet',
dogapi_version: '1.2.2',
}
Expand Down Expand Up @@ -131,7 +131,7 @@
context 'specific gem provider' do
let(:params) do
{
api_key: 'notanapikey',
api_key: Sensitive('notanapikey'),
puppetmaster_user: 'puppet',
dogapi_version: '1.2.2',
puppet_gem_provider: 'gem',
Expand Down Expand Up @@ -177,7 +177,7 @@
context 'EU site in report' do
let(:params) do
{
api_key: 'notanapikey',
api_key: Sensitive('notanapikey'),
puppetmaster_user: 'puppet',
dogapi_version: 'installed',
datadog_site: 'https://api.datadoghq.eu',
Expand Down Expand Up @@ -226,7 +226,7 @@
context 'disabled ruby-manage' do
let(:params) do
{
api_key: 'notanapikey',
api_key: Sensitive('notanapikey'),
hostname_extraction_regex: nil,
dogapi_version: 'installed',
puppetmaster_user: 'puppet',
Expand Down
8 changes: 4 additions & 4 deletions spec/classes/datadog_agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@
{
agent_major_version: 7,
windows_npm_install: true,
api_key: 'notakey',
api_key: Sensitive('notakey'),
host: 'notahost',
}
end

it do
is_expected.to contain_package('Datadog Agent').with(
ensure: 'installed',
install_options: ['/norestart', { 'APIKEY' => 'notakey', 'HOSTNAME' => 'notahost', 'TAGS' => '""', 'ADDLOCAL' => 'MainApplication,NPM' }],
install_options: ['/norestart', { 'APIKEY' => Sensitive('notakey'), 'HOSTNAME' => 'notahost', 'TAGS' => '""', 'ADDLOCAL' => 'MainApplication,NPM' }],
)
end
end
Expand All @@ -304,15 +304,15 @@
let(:params) do
{
agent_major_version: 7,
api_key: 'notakey',
api_key: Sensitive('notakey'),
host: 'notahost',
}
end

it do
is_expected.to contain_package('Datadog Agent').with(
ensure: 'installed',
install_options: ['/norestart', { 'APIKEY' => 'notakey', 'HOSTNAME' => 'notahost', 'TAGS' => '""' }],
install_options: ['/norestart', { 'APIKEY' => Sensitive('notakey'), 'HOSTNAME' => 'notahost', 'TAGS' => '""' }],
)
end
end
Expand Down
5 changes: 5 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,9 @@ def ensure_module_defined(module_name)
end
end

# Ensures that Puppet Sensitive is defined
def Sensitive(value)
Puppet::Pops::Types::PSensitiveType::Sensitive.new(value)
end

# 'spec_overrides' from sync.yml will appear below this line
2 changes: 1 addition & 1 deletion templates/datadog-reports.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### MANAGED BY PUPPET

---
:datadog_api_key: '<%= @api_key %>'
:datadog_api_key: '<%= @api_key.unwrap %>'
:api_url: <%= @datadog_site %>
<% if @hostname_extraction_regex -%>
:hostname_extraction_regex: '<%= @hostname_extraction_regex %>'
Expand Down
2 changes: 1 addition & 1 deletion templates/datadog_header.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ skip_ssl_validation: <%= @skip_ssl_validation %>
# The Datadog api key to associate your Agent's data with your organization.
# Can be found here:
# https://app.datadoghq.com/account/settings
api_key: <%= @api_key %>
api_key: <%= @api_key.unwrap %>

# Force the hostname to whatever you want.
<% if @host.empty? -%>
Expand Down
2 changes: 1 addition & 1 deletion templates/installer/telemetry/send_telemetry.sh.epp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ send_payload() {
local file=$1
curl -f -sSL --retry 5 -o /dev/null -X POST \
-H 'Content-Type: application/json' \
-H 'DD-API-KEY: <%= $api_key %>' \
-H 'DD-API-KEY: <%= $api_key.unwrap %>' \
-d "@$file" \
"$TELEMETRY_URL"
}
Expand Down