diff --git a/.circleci/config.yml b/.circleci/config.yml index 9f4280c6a..db011ec38 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,392 +1,239 @@ version: 2.1 orbs: - win: circleci/windows@2.2.0 + win: circleci/windows@5.0.0 jobs: - specs-ruby21-puppet46: &specs + specs-ruby26-puppet734: &ubuntu2004-specs machine: image: ubuntu-2004:2024.08.1 environment: STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.1.9' - PUPPET_VERSION: '4.6.2' + RUBY_VERSION: '2.6.3' + PUPPET_VERSION: '7.34.0' steps: - # See https://github.blog/2021-09-01-improving-git-protocol-security-github/ - - run: - name: Fix git clones - command: echo -e '[url "https://github.com/"]\n insteadOf = "git://github.com/"' >> ~/.gitconfig - - checkout - - run: - name: Install RVM - command: | - gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB - \curl -sSL https://get.rvm.io | bash -s stable - - run: - name: Install old libssl1.0-dev - command: | - ruby_major=$(echo $RUBY_VERSION | awk -F. '{ print $1 }') - ruby_minor=$(echo $RUBY_VERSION | awk -F. '{ print $2 }') - # We need libssl1.0-dev to even compile Ruby <= 2.3 with RVM; - if [ $ruby_major -eq "2" ] && [ $ruby_minor -le "3" ]; then - sudo bash -c "echo deb http://security.ubuntu.com/ubuntu bionic-security main >> /etc/apt/sources.list" - sudo apt update && apt-cache policy libssl1.0-dev - sudo apt install -y libssl1.0-dev - fi - - run: - name: Install Ruby version - command: rvm install $RUBY_VERSION - - run: - name: Install bundler - command: rvm $RUBY_VERSION --verbose do gem install bundler:1.17.3 - - run: - name: Install gem dependencies - command: rm Gemfile.lock && rvm $RUBY_VERSION --verbose do bundle install --path .bundle - - run: - name: Run tests - command: rvm $RUBY_VERSION --verbose do bundle exec rake test - - specs-ruby21-puppet410: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.1.9' - PUPPET_VERSION: '4.10.9' - - specs-ruby21-puppet50: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.1.9' - PUPPET_VERSION: '5.0.1' - - specs-ruby21-puppet53: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.1.9' - PUPPET_VERSION: '5.3.3' - - # Puppet 6 depends on ruby >= 2.3 - #specs-ruby21-puppet60 - #specs-ruby21-puppet65 + - checkout + - run: + name: Setup + command: | + # Needed to bundle install a puppet_litmus gem dependency + sudo apt update -y + sudo apt install -y libcurl4 curl libcurl4-openssl-dev + - run: + name: Install RVM + command: | + gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB + \curl -sSL https://get.rvm.io | bash -s stable + - run: + name: Install Ruby version + command: rvm install $RUBY_VERSION + - run: + name: Install bundler + command: | + rm Gemfile.lock && rvm $RUBY_VERSION --verbose do bundle config set path '.bundle' + rvm $RUBY_VERSION --verbose do gem install bundler:2.4.13 + - run: + name: Install gem dependencies + command: rvm $RUBY_VERSION --verbose do bundle install + - run: + name: Run tests + command: rvm $RUBY_VERSION --verbose do bundle exec rake test - specs-ruby22-puppet46: - <<: *specs + specs-ruby27-puppet734: + <<: *ubuntu2004-specs environment: STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.2.3' - PUPPET_VERSION: '4.6.2' + RUBY_VERSION: '2.7.5' + PUPPET_VERSION: '7.34.0' - specs-ruby22-puppet410: - <<: *specs + specs-ruby31-puppet734: + <<: *ubuntu2004-specs environment: STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.2.3' - PUPPET_VERSION: '4.10.9' + RUBY_VERSION: '3.1.6' + PUPPET_VERSION: '7.34.0' - specs-ruby22-puppet50: - <<: *specs + specs-ruby32-puppet734: + <<: *ubuntu2004-specs environment: STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.2.3' - PUPPET_VERSION: '5.0.1' + RUBY_VERSION: '3.2.7' + PUPPET_VERSION: '7.34.0' - specs-ruby22-puppet53: - <<: *specs + specs-ruby33-puppet734: + <<: *ubuntu2004-specs environment: STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.2.3' - PUPPET_VERSION: '5.3.3' + RUBY_VERSION: '3.3.7' + PUPPET_VERSION: '7.34.0' - # Puppet 6 depends on ruby >= 2.3 - #specs-ruby22-puppet60 - #specs-ruby22-puppet65 - - specs-ruby23-puppet46: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.3.6' - PUPPET_VERSION: '4.6.2' - - specs-ruby23-puppet410: - <<: *specs + specs-ruby34-puppet734: + <<: *ubuntu2004-specs environment: STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.3.6' - PUPPET_VERSION: '4.10.9' + RUBY_VERSION: '3.4.1' + PUPPET_VERSION: '7.34.0' - specs-ruby23-puppet50: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.3.6' - PUPPET_VERSION: '5.0.1' - - specs-ruby23-puppet53: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.3.6' - PUPPET_VERSION: '5.3.3' - - specs-ruby23-puppet60: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.3.6' - PUPPET_VERSION: '6.0.0' - - specs-ruby23-puppet65: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.3.6' - PUPPET_VERSION: '6.5.0' - - # Puppet < 5 doesn't work with Ruby when it's compiled with libssl > 1.0 - see - # https://bugzilla.redhat.com/show_bug.cgi?id=1440710 for details - but RVM - # refuses to compile with older libssl. We could use --autolibs=0 RVM option, - # but then we'd have to manually install all deps ourselves and maintain that - # solution... So we just disable specs-ruby24-puppet46 and specs-ruby25-puppet46. - # specs-ruby24-puppet46: - # <<: *specs - # environment: - # STRICT_VARIABLES: 'yes' - # RUBY_VERSION: '2.4.3' - # PUPPET_VERSION: '4.6.2' - - specs-ruby24-puppet410: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.4.3' - PUPPET_VERSION: '4.10.9' - - specs-ruby24-puppet50: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.4.3' - PUPPET_VERSION: '5.0.1' - - specs-ruby24-puppet53: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.4.3' - PUPPET_VERSION: '5.3.3' - - specs-ruby24-puppet60: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.4.3' - PUPPET_VERSION: '6.0.0' - - specs-ruby24-puppet65: - <<: *specs + specs-ruby31-puppet810: &ubuntu2404-specs + machine: + image: ubuntu-2404:2024.08.1 environment: STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.4.3' - PUPPET_VERSION: '6.5.0' - - # specs-ruby25-puppet46: - # <<: *specs + RUBY_VERSION: '3.1.6' + PUPPET_VERSION: '8.10.0' + steps: + - checkout + - run: + name: Setup + command: | + # Needed to bundle install a puppet_litmus gem dependency + sudo apt update -y + sudo apt install -y libcurl4 curl libcurl4-openssl-dev + - run: + name: Install RVM + command: | + gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB + \curl -sSL https://get.rvm.io | bash -s stable + - run: + name: Install Ruby version + command: rvm install $RUBY_VERSION + - run: + name: Install bundler + command: | + rm Gemfile.lock && rvm $RUBY_VERSION --verbose do bundle config set path '.bundle' + rvm $RUBY_VERSION --verbose do gem install bundler:2.4.13 + - run: + name: Install gem dependencies + command: rvm $RUBY_VERSION --verbose do bundle install + - run: + name: Run tests + command: rvm $RUBY_VERSION --verbose do bundle exec rake test + + specs-ruby32-puppet810: + <<: *ubuntu2404-specs + environment: + STRICT_VARIABLES: 'yes' + RUBY_VERSION: '3.2.7' + PUPPET_VERSION: '8.10.0' + + specs-ruby33-puppet810: + <<: *ubuntu2404-specs + environment: + STRICT_VARIABLES: 'yes' + RUBY_VERSION: '3.3.7' + PUPPET_VERSION: '8.10.0' + + specs-ruby34-puppet810: + <<: *ubuntu2404-specs + environment: + STRICT_VARIABLES: 'yes' + RUBY_VERSION: '3.4.1' + PUPPET_VERSION: '8.10.0' + + # specs-ruby27-puppet79-windows: + # # &windows-specs + # executor: + # name: win/default + # shell: bash.exe + # steps: + # - checkout + # - run: + # name: Run tests + # command: | + # set -e + # choco install ruby --allow-downgrade -y --version=2.7.5.1 # Keep version in sync with next command! + # export PATH=/c/tools/ruby27/bin:$PATH # Make Ruby 2.7 take precedence over the pre-installed version + # ruby --version + # choco install msys2 -y + # ridk.cmd exec pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain + # gem install bundler -v 2.4.13 + # rm Gemfile.lock && bundle install --path .bundle + # bundle exec rake test # environment: # STRICT_VARIABLES: 'yes' - # RUBY_VERSION: '2.5.3' - # PUPPET_VERSION: '4.6.2' - - specs-ruby25-puppet410: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.5.3' - PUPPET_VERSION: '4.10.9' - - specs-ruby25-puppet50: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.5.3' - PUPPET_VERSION: '5.0.1' - - specs-ruby25-puppet53: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.5.3' - PUPPET_VERSION: '5.3.3' - - specs-ruby25-puppet60: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.5.3' - PUPPET_VERSION: '6.0.0' - - specs-ruby25-puppet65: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.5.3' - PUPPET_VERSION: '6.5.0' - - specs-ruby26-puppet60: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.6.3' - PUPPET_VERSION: '6.0.0' - - specs-ruby26-puppet65: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.6.3' - PUPPET_VERSION: '6.5.0' - specs-ruby26-puppet79: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.6.3' - PUPPET_VERSION: '7.9.0' - - specs-ruby26-puppet714: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.6.3' - PUPPET_VERSION: '7.14.0' - - specs-ruby26-puppet725: - <<: *specs - environment: - STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.6.3' - PUPPET_VERSION: '7.25.0' - - specs-ruby25-puppet65-windows: &windows-specs - executor: - name: win/default # Comes with ruby 2.6, which is not supported on Windows as of puppet 6.10.1 - shell: bash.exe - steps: - # See https://github.blog/2021-09-01-improving-git-protocol-security-github/ - - run: - name: Fix git clones - command: echo -e '[url "https://github.com/"]\n insteadOf = "git://github.com/"' >> ~/.gitconfig - - checkout - - run: - name: Run tests - command: | - set -e - choco install ruby --allow-downgrade -y --version 2.5.3.101 # Keep version in sync with next command! - export PATH=/c/tools/ruby25/bin:$PATH # Make Ruby 2.5 take precedence over the pre-installed 2.6 - ruby --version - choco install msys2 --allow-downgrade -y --version 20210604.0.0 - ridk.cmd exec pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain - gem install bundler -v 1.17.3 - rm Gemfile.lock && bundle install --path .bundle - bundle exec rake test - environment: - STRICT_VARIABLES: 'yes' - #RUBY_VERSION hardcoded in install script - PUPPET_VERSION: '6.5.0' + # #RUBY_VERSION hardcoded in install script + # PUPPET_VERSION: '7.9.0' verify-gemfile-lock-dependencies: machine: - image: ubuntu-2004:2024.08.1 + image: ubuntu-2404:2024.08.1 environment: STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.5.3' + RUBY_VERSION: '3.3.7' steps: - # See https://github.blog/2021-09-01-improving-git-protocol-security-github/ - - run: - name: Fix git clones - command: echo -e '[url "https://github.com/"]\n insteadOf = "git://github.com/"' >> ~/.gitconfig - - checkout - - run: - name: Install RVM - command: | - gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB - \curl -sSL https://get.rvm.io | bash -s stable - - run: - name: Install Ruby versions - command: rvm install $RUBY_VERSION - - run: - name: Install bundler - command: rvm $RUBY_VERSION --verbose do gem install bundler:1.17.3 - - run: - name: Install gem dependencies - command: rvm $RUBY_VERSION --verbose do bundle install --path .bundle - - run: - name: Run tests - command: rvm $RUBY_VERSION --verbose do bundle exec rake test + - checkout + - run: + name: Setup + command: | + # Needed to bundle install a puppet_litmus gem dependency + sudo apt update -y + sudo apt install -y libcurl4 curl libcurl4-openssl-dev + - run: + name: Install RVM + command: | + gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB + \curl -sSL https://get.rvm.io | bash -s stable + - run: + name: Install Ruby versions + command: rvm install $RUBY_VERSION + - run: + name: Install bundler + command: | + rvm $RUBY_VERSION --verbose do bundle config set path '.bundle' + rvm $RUBY_VERSION --verbose do gem install bundler:2.4.13 + - run: + name: Install gem dependencies + command: rvm $RUBY_VERSION --verbose do bundle install + - run: + name: Run tests + command: rvm $RUBY_VERSION --verbose do bundle exec rake test kitchen-tests: machine: - image: ubuntu-2004:2024.08.1 + image: ubuntu-2204:2024.08.1 environment: STRICT_VARIABLES: 'yes' - RUBY_VERSION: '2.5.3' + RUBY_VERSION: '3.4.1' steps: - # See https://github.blog/2021-09-01-improving-git-protocol-security-github/ - - run: - name: Fix git clones - command: echo -e '[url "https://github.com/"]\n insteadOf = "git://github.com/"' >> ~/.gitconfig - - checkout - - run: - name: Install RVM - command: | - gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB - \curl -sSL https://get.rvm.io | bash -s stable - - run: - name: Install Ruby versions - command: rvm install $RUBY_VERSION - - run: - name: Install bundler - command: rvm $RUBY_VERSION --verbose do gem install bundler:1.17.3 - - run: - name: Install gem dependencies - command: rvm $RUBY_VERSION --verbose do bundle install --path .bundle - - run: - name: Execute Kitchen tests - command: rvm $RUBY_VERSION --verbose do bundle exec rake circle - no_output_timeout: 900 + - checkout + - run: + name: Setup + command: | + # Needed to bundle install a puppet_litmus gem dependency + sudo apt update -y + sudo apt install -y libcurl4 curl libcurl4-openssl-dev + - run: + name: Install RVM + command: | + gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB + \curl -sSL https://get.rvm.io | bash -s stable + - run: + name: Install Ruby versions + command: rvm install $RUBY_VERSION + - run: + name: Install bundler + command: | + rvm $RUBY_VERSION --verbose do bundle config set path '.bundle' + rvm $RUBY_VERSION --verbose do gem install bundler:2.4.13 + - run: + name: Install gem dependencies + command: rvm $RUBY_VERSION --verbose do bundle install + - run: + name: Execute Kitchen tests + command: rvm $RUBY_VERSION --verbose do bundle exec rake circle + no_output_timeout: "900s" workflows: - version: 2 build_and_test: jobs: - - specs-ruby21-puppet46 - - specs-ruby21-puppet410 - - specs-ruby21-puppet50 - - specs-ruby21-puppet53 - - specs-ruby22-puppet46 - - specs-ruby22-puppet410 - - specs-ruby22-puppet50 - - specs-ruby22-puppet53 - - specs-ruby23-puppet46 - - specs-ruby23-puppet410 - - specs-ruby23-puppet50 - - specs-ruby23-puppet53 - - specs-ruby23-puppet60 - - specs-ruby23-puppet65 - - specs-ruby24-puppet410 - - specs-ruby24-puppet50 - - specs-ruby24-puppet53 - - specs-ruby24-puppet60 - - specs-ruby24-puppet65 - - specs-ruby25-puppet410 - - specs-ruby25-puppet50 - - specs-ruby25-puppet53 - - specs-ruby25-puppet60 - - specs-ruby25-puppet65 - - specs-ruby25-puppet65-windows - - specs-ruby26-puppet60 - - specs-ruby26-puppet65 - - specs-ruby26-puppet79 - - specs-ruby26-puppet714 - - specs-ruby26-puppet725 - - verify-gemfile-lock-dependencies - - kitchen-tests + - specs-ruby26-puppet734 + # - specs-ruby27-puppet79-windows # puppet_litmus requires a dependency "patron", which doesn't run on windows + - specs-ruby27-puppet734 + - specs-ruby31-puppet734 + - specs-ruby32-puppet734 + - specs-ruby33-puppet734 + # - specs-ruby34-puppet734 # ruby v3.4 specs fail with `Puppet::Error: Cannot determine basic system flavour (Puppet::Error)` + - specs-ruby31-puppet810 + - specs-ruby32-puppet810 + - specs-ruby33-puppet810 + # - specs-ruby34-puppet810 + - verify-gemfile-lock-dependencies + - kitchen-tests diff --git a/.fixtures.yml b/.fixtures.yml index e8d3a33ff..7269a844e 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,27 +1,24 @@ fixtures: repositories: stdlib: - repo: "git://github.com/puppetlabs/puppetlabs-stdlib.git" - ref: "4.25.0" + repo: "https://github.com/puppetlabs/puppetlabs-stdlib.git" + ref: "v9.7.0" # Puppet >= 7.0.0 < 9.0.0 concat: - repo: "git://github.com/puppetlabs/puppetlabs-concat.git" - ref: "4.1.1" + repo: "https://github.com/puppetlabs/puppetlabs-concat.git" + ref: "v9.1.0" # Puppet >= 7.0.0 < 9.0.0 apt: - repo: "git://github.com/puppetlabs/puppetlabs-apt.git" - ref: "4.5.0" - puppetserver_gem: - repo: "git://github.com/puppetlabs/puppetlabs-puppetserver_gem.git" - ref: "1.0.0" + repo: "https://github.com/puppetlabs/puppetlabs-apt.git" + ref: "v10.0.1" # Puppet >= 7.0.0 < 9.0.0 forge_modules: yumrepo_core: repo: "puppetlabs/yumrepo_core" - ref: "1.2.0" + ref: "2.1.0" powershell: repo: "puppetlabs/powershell" - ref: "4.1.0" + ref: "6.0.2" zypprepo: repo: "puppet/zypprepo" - ref: "3.1.0" + ref: "5.0.0" symlinks: custom_datadog: "#{source_dir}/spec/custom_fixtures/custom_datadog" datadog_agent: "#{source_dir}" diff --git a/.gitignore b/.gitignore index d67bb69cf..40fdc6aa1 100644 --- a/.gitignore +++ b/.gitignore @@ -14,8 +14,11 @@ /junit/ /log/ /pkg/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt spec/fixtures @@ -32,4 +35,11 @@ environments/**/.vagrant /inventory.yaml .kitchen -.vscode + +/spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log diff --git a/.pdkignore b/.pdkignore index 12313396a..21e52a2a1 100644 --- a/.pdkignore +++ b/.pdkignore @@ -16,30 +16,42 @@ /log/ /pkg/ /spec/fixtures/manifests/ -/spec/fixtures/modules/ +/spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store .project .envrc /inventory.yaml -/appveyor.yml +/spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log /.fixtures.yml /Gemfile /.gitattributes +/.github/ /.gitignore /.gitlab-ci.yml + /.pdkignore +/.puppet-lint.rc /Rakefile /rakelib/ /.rspec /.rubocop.yml /.travis.yml +/..yml /.yardopts /spec/ -/.vscode/ +/.sync.yml +/.devcontainer/ /.github/ /.circleci/ /.pre-commit-config.yaml diff --git a/.puppet-lint.rc b/.puppet-lint.rc index 6856ecf37..8b43cfb03 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1,3 +1,13 @@ +--fail-on-warnings --relative +--no-80chars-check --no-140chars-check ---fail-on-warnings +--no-class_inherits_from_params_class-check +--no-autoloader_layout-check +--no-parameter_documentation-check +--no-single_quote_string_with_variables-check +--no-params_empty_string_assignment-check +--no-lookup_in_parameter-check +--no-version_comparison-check +--no-top_scope_facts-check +--ignore-paths=.vendor/**/*.pp,.bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp,tests/**/*.pp,types/**/*.pp,vendor/**/*.pp diff --git a/.rspec b/.rspec new file mode 100644 index 000000000..16f9cdb01 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--format documentation diff --git a/.rubocop b/.rubocop new file mode 100644 index 000000000..fc40e8e2e --- /dev/null +++ b/.rubocop @@ -0,0 +1 @@ +--ignore-unrecognized-cops diff --git a/.rubocop.yml b/.rubocop.yml index c2c01dd62..056c84ef3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,12 +1,13 @@ --- require: +- rubocop-performance - rubocop-rspec -- rubocop-i18n AllCops: + NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.1' + TargetRubyVersion: '3.2' Include: - - "./**/*.rb" + - "**/*.rb" Exclude: - bin/* - ".vendor/**/*" @@ -18,27 +19,21 @@ AllCops: - "**/Puppetfile" - "**/Vagrantfile" - "**/Guardfile" -Metrics/LineLength: +Layout/LineLength: Description: People have wide screens, use them. Max: 200 -GetText: - Enabled: false -GetText/DecorateString: - Description: We don't want to decorate test output. - Exclude: - - spec/**/* - Enabled: false RSpec/BeforeAfterAll: - Description: Beware of using after(:all) as it may cause state to leak between tests. - A necessary evil in acceptance testing. + Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. Exclude: - spec/acceptance/**/*.rb RSpec/HookArgument: Description: Prefer explicit :each argument, matching existing module's style EnforcedStyle: each +RSpec/DescribeSymbol: + Exclude: + - spec/unit/facter/**/*.rb Style/BlockDelimiters: - Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to - be consistent then. + Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to be consistent then. EnforcedStyle: braces_for_chaining Style/ClassAndModuleChildren: Description: Compact style reduces the required amount of indentation. @@ -50,8 +45,7 @@ Style/FormatString: Description: Following the main puppet project's style, prefer the % format format. EnforcedStyle: percent Style/FormatStringToken: - Description: Following the main puppet project's style, prefer the simpler template - tokens over annotated ones. + Description: Following the main puppet project's style, prefer the simpler template tokens over annotated ones. EnforcedStyle: template Style/Lambda: Description: Prefer the keyword for easier discoverability. @@ -60,17 +54,13 @@ Style/RegexpLiteral: Description: Community preference. See https://github.com/voxpupuli/modulesync_config/issues/168 EnforcedStyle: percent_r Style/TernaryParentheses: - Description: Checks for use of parentheses around ternary conditions. Enforce parentheses - on complex expressions for better readability, but seriously consider breaking - it up. + Description: Checks for use of parentheses around ternary conditions. Enforce parentheses on complex expressions for better readability, but seriously consider breaking it up. EnforcedStyle: require_parentheses_when_complex Style/TrailingCommaInArguments: - Description: Prefer always trailing comma on multiline argument lists. This makes - diffs, and re-ordering nicer. + Description: Prefer always trailing comma on multiline argument lists. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma -Style/TrailingCommaInLiteral: - Description: Prefer always trailing comma on multiline literals. This makes diffs, - and re-ordering nicer. +Style/TrailingCommaInArrayLiteral: + Description: Prefer always trailing comma on multiline literals. This makes diffs, and re-ordering nicer. EnforcedStyleForMultiline: comma Style/SymbolArray: Description: Using percent style obscures symbolic intent of array's contents. @@ -83,26 +73,176 @@ Style/Documentation: - spec/**/* Style/WordArray: EnforcedStyle: brackets +Performance/AncestorsInclude: + Enabled: true +Performance/BigDecimalWithNumericArgument: + Enabled: true +Performance/BlockGivenWithExplicitBlock: + Enabled: true +Performance/CaseWhenSplat: + Enabled: true +Performance/ConstantRegexp: + Enabled: true +Performance/MethodObjectAsBlock: + Enabled: true +Performance/RedundantSortBlock: + Enabled: true +Performance/RedundantStringChars: + Enabled: true +Performance/ReverseFirst: + Enabled: true +Performance/SortReverse: + Enabled: true +Performance/Squeeze: + Enabled: true +Performance/StringInclude: + Enabled: true +Performance/Sum: + Enabled: true Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: Enabled: true Style/StringMethods: Enabled: true -GetText/DecorateFunctionMessage: +Bundler/GemFilename: + Enabled: false +Bundler/InsecureProtocolSource: + Enabled: false +Capybara/CurrentPathExpectation: Enabled: false -GetText/DecorateStringFormattingUsingInterpolation: +Capybara/VisibilityMatcher: Enabled: false -GetText/DecorateStringFormattingUsingPercent: +Gemspec/DuplicatedAssignment: + Enabled: false +Gemspec/OrderedDependencies: + Enabled: false +Gemspec/RequiredRubyVersion: + Enabled: false +Gemspec/RubyVersionGlobalsUsage: + Enabled: false +Layout/ArgumentAlignment: + Enabled: false +Layout/BeginEndAlignment: + Enabled: false +Layout/ClosingHeredocIndentation: + Enabled: false +Layout/EmptyComment: + Enabled: false +Layout/EmptyLineAfterGuardClause: + Enabled: false +Layout/EmptyLinesAroundArguments: + Enabled: false +Layout/EmptyLinesAroundAttributeAccessor: Enabled: false Layout/EndOfLine: Enabled: false -Layout/IndentHeredoc: +Layout/FirstArgumentIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Layout/LeadingEmptyLines: + Enabled: false +Layout/SpaceAroundMethodCallOperator: + Enabled: false +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: false +Layout/SpaceInsideReferenceBrackets: + Enabled: false +Lint/BigDecimalNew: + Enabled: false +Lint/BooleanSymbol: + Enabled: false +Lint/ConstantDefinitionInBlock: + Enabled: false +Lint/DeprecatedOpenSSLConstant: + Enabled: false +Lint/DisjunctiveAssignmentInConstructor: + Enabled: false +Lint/DuplicateElsifCondition: + Enabled: false +Lint/DuplicateRequire: + Enabled: false +Lint/DuplicateRescueException: + Enabled: false +Lint/EmptyConditionalBody: + Enabled: false +Lint/EmptyFile: + Enabled: false +Lint/ErbNewArguments: + Enabled: false +Lint/FloatComparison: + Enabled: false +Lint/HashCompareByIdentity: + Enabled: false +Lint/IdentityComparison: + Enabled: false +Lint/InterpolationCheck: + Enabled: false +Lint/MissingCopEnableDirective: + Enabled: false +Lint/MixedRegexpCaptureTypes: + Enabled: false +Lint/NestedPercentLiteral: + Enabled: false +Lint/NonDeterministicRequireOrder: + Enabled: false +Lint/OrderedMagicComments: + Enabled: false +Lint/OutOfRangeRegexpRef: + Enabled: false +Lint/RaiseException: + Enabled: false +Lint/RedundantCopEnableDirective: + Enabled: false +Lint/RedundantRequireStatement: + Enabled: false +Lint/RedundantSafeNavigation: + Enabled: false +Lint/RedundantWithIndex: + Enabled: false +Lint/RedundantWithObject: + Enabled: false +Lint/RegexpAsCondition: + Enabled: false +Lint/ReturnInVoidContext: + Enabled: false +Lint/SafeNavigationConsistency: + Enabled: false +Lint/SafeNavigationWithEmpty: + Enabled: false +Lint/SelfAssignment: + Enabled: false +Lint/SendWithMixinArgument: + Enabled: false +Lint/ShadowedArgument: + Enabled: false +Lint/StructNewOverride: + Enabled: false +Lint/ToJSON: + Enabled: false +Lint/TopLevelReturnWithArgument: + Enabled: false +Lint/TrailingCommaInAttributeDeclaration: + Enabled: false +Lint/UnreachableLoop: + Enabled: false +Lint/UriEscapeUnescape: + Enabled: false +Lint/UriRegexp: + Enabled: false +Lint/UselessMethodDefinition: + Enabled: false +Lint/UselessTimes: Enabled: false Metrics/AbcSize: Enabled: false Metrics/BlockLength: Enabled: false +Metrics/BlockNesting: + Enabled: false Metrics/ClassLength: Enabled: false Metrics/CyclomaticComplexity: @@ -115,25 +255,469 @@ Metrics/ParameterLists: Enabled: false Metrics/PerceivedComplexity: Enabled: false +Migration/DepartmentName: + Enabled: false +Naming/AccessorMethodName: + Enabled: false +Naming/BlockParameterName: + Enabled: false +Naming/HeredocDelimiterCase: + Enabled: false +Naming/HeredocDelimiterNaming: + Enabled: false +Naming/MemoizedInstanceVariableName: + Enabled: false +Naming/MethodParameterName: + Enabled: false +Naming/RescuedExceptionsVariableName: + Enabled: false +Naming/VariableNumber: + Enabled: false +Performance/BindCall: + Enabled: false +Performance/DeletePrefix: + Enabled: false +Performance/DeleteSuffix: + Enabled: false +Performance/InefficientHashSearch: + Enabled: false +Performance/UnfreezeString: + Enabled: false +Performance/UriDefaultParser: + Enabled: false +RSpec/Be: + Enabled: false +RSpec/Capybara/FeatureMethods: + Enabled: false +RSpec/ContainExactly: + Enabled: false +RSpec/ContextMethod: + Enabled: false +RSpec/ContextWording: + Enabled: false RSpec/DescribeClass: Enabled: false +RSpec/EmptyHook: + Enabled: false +RSpec/EmptyLineAfterExample: + Enabled: false +RSpec/EmptyLineAfterExampleGroup: + Enabled: false +RSpec/EmptyLineAfterHook: + Enabled: false RSpec/ExampleLength: Enabled: false -RSpec/MessageExpectation: +RSpec/ExampleWithoutDescription: + Enabled: false +RSpec/ExpectChange: + Enabled: false +RSpec/ExpectInHook: + Enabled: false +RSpec/FactoryBot/AttributeDefinedStatically: + Enabled: false +RSpec/FactoryBot/CreateList: + Enabled: false +RSpec/FactoryBot/FactoryClassName: + Enabled: false +RSpec/HooksBeforeExamples: + Enabled: false +RSpec/ImplicitBlockExpectation: + Enabled: false +RSpec/ImplicitSubject: + Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false +RSpec/LetBeforeExamples: + Enabled: false +RSpec/MatchArray: + Enabled: false +RSpec/MissingExampleGroupArgument: Enabled: false RSpec/MultipleExpectations: Enabled: false +RSpec/MultipleMemoizedHelpers: + Enabled: false +RSpec/MultipleSubjects: + Enabled: false RSpec/NestedGroups: Enabled: false -Style/AsciiComments: +RSpec/PredicateMatcher: + Enabled: false +RSpec/ReceiveCounts: + Enabled: false +RSpec/ReceiveNever: + Enabled: false +RSpec/RepeatedExampleGroupBody: + Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false +RSpec/RepeatedIncludeExample: + Enabled: false +RSpec/ReturnFromStub: + Enabled: false +RSpec/SharedExamples: + Enabled: false +RSpec/StubbedMock: + Enabled: false +RSpec/UnspecifiedException: + Enabled: false +RSpec/VariableDefinition: + Enabled: false +RSpec/VoidExpect: + Enabled: false +RSpec/Yield: + Enabled: false +Security/Open: + Enabled: false +Style/AccessModifierDeclarations: + Enabled: false +Style/AccessorGrouping: + Enabled: false +Style/BisectedAttrAccessor: + Enabled: false +Style/CaseLikeIf: + Enabled: false +Style/ClassEqualityComparison: + Enabled: false +Style/ColonMethodDefinition: + Enabled: false +Style/CombinableLoops: + Enabled: false +Style/CommentedKeyword: + Enabled: false +Style/Dir: + Enabled: false +Style/DoubleCopDisableDirective: + Enabled: false +Style/EmptyBlockParameter: + Enabled: false +Style/EmptyLambdaParameter: + Enabled: false +Style/Encoding: + Enabled: false +Style/EvalWithLocation: + Enabled: false +Style/ExpandPathArguments: + Enabled: false +Style/ExplicitBlockArgument: + Enabled: false +Style/ExponentialNotation: + Enabled: false +Style/FloatDivision: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false +Style/GlobalStdStream: + Enabled: false +Style/HashAsLastArrayItem: + Enabled: false +Style/HashLikeCase: + Enabled: false +Style/HashTransformKeys: + Enabled: false +Style/HashTransformValues: Enabled: false Style/IfUnlessModifier: Enabled: false -Style/SymbolProc: +Style/KeywordParametersOrder: + Enabled: false +Style/MinMax: + Enabled: false +Style/MixinUsage: + Enabled: false +Style/MultilineWhenThen: + Enabled: false +Style/NegatedUnless: Enabled: false Style/NumericPredicate: Enabled: false -Layout/FirstHashElementLineBreak: - Enabled: true -Style/EmptyLiteral: +Style/OptionalBooleanParameter: + Enabled: false +Style/OrAssignment: + Enabled: false +Style/RandomWithOffset: + Enabled: false +Style/RedundantAssignment: + Enabled: false +Style/RedundantCondition: + Enabled: false +Style/RedundantConditional: + Enabled: false +Style/RedundantFetchBlock: + Enabled: false +Style/RedundantFileExtensionInRequire: + Enabled: false +Style/RedundantRegexpCharacterClass: + Enabled: false +Style/RedundantRegexpEscape: + Enabled: false +Style/RedundantSelfAssignment: + Enabled: false +Style/RedundantSort: + Enabled: false +Style/RescueStandardError: + Enabled: false +Style/SingleArgumentDig: + Enabled: false +Style/SlicingWithRange: + Enabled: false +Style/SoleNestedConditional: + Enabled: false +Style/StderrPuts: + Enabled: false +Style/StringConcatenation: + Enabled: false +Style/Strip: + Enabled: false +Style/SymbolProc: + Enabled: false +Style/TrailingBodyOnClass: + Enabled: false +Style/TrailingBodyOnMethodDefinition: + Enabled: false +Style/TrailingBodyOnModule: + Enabled: false +Style/TrailingCommaInHashLiteral: + Enabled: false +Style/TrailingMethodEndStatement: + Enabled: false +Style/UnpackFirst: + Enabled: false +Capybara/MatchStyle: + Enabled: false +Capybara/NegationMatcher: + Enabled: false +Capybara/SpecificActions: + Enabled: false +Capybara/SpecificFinders: + Enabled: false +Capybara/SpecificMatcher: + Enabled: false +Gemspec/DeprecatedAttributeAssignment: + Enabled: false +Gemspec/DevelopmentDependencies: + Enabled: false +Gemspec/RequireMFA: + Enabled: false +Layout/LineContinuationLeadingSpace: + Enabled: false +Layout/LineContinuationSpacing: + Enabled: false +Layout/LineEndStringConcatenationIndentation: + Enabled: false +Layout/SpaceBeforeBrackets: + Enabled: false +Lint/AmbiguousAssignment: + Enabled: false +Lint/AmbiguousOperatorPrecedence: + Enabled: false +Lint/AmbiguousRange: + Enabled: false +Lint/ConstantOverwrittenInRescue: + Enabled: false +Lint/DeprecatedConstants: + Enabled: false +Lint/DuplicateBranch: + Enabled: false +Lint/DuplicateMagicComment: + Enabled: false +Lint/DuplicateMatchPattern: + Enabled: false +Lint/DuplicateRegexpCharacterClassElement: + Enabled: false +Lint/EmptyBlock: + Enabled: false +Lint/EmptyClass: + Enabled: false +Lint/EmptyInPattern: + Enabled: false +Lint/IncompatibleIoSelectWithFiberScheduler: + Enabled: false +Lint/LambdaWithoutLiteralBlock: + Enabled: false +Lint/NoReturnInBeginEndBlocks: + Enabled: false +Lint/NonAtomicFileOperation: + Enabled: false +Lint/NumberedParameterAssignment: + Enabled: false +Lint/OrAssignmentToConstant: + Enabled: false +Lint/RedundantDirGlobSort: + Enabled: false +Lint/RefinementImportMethods: + Enabled: false +Lint/RequireRangeParentheses: + Enabled: false +Lint/RequireRelativeSelfPath: + Enabled: false +Lint/SymbolConversion: + Enabled: false +Lint/ToEnumArguments: + Enabled: false +Lint/TripleQuotes: + Enabled: false +Lint/UnexpectedBlockArity: + Enabled: false +Lint/UnmodifiedReduceAccumulator: + Enabled: false +Lint/UselessRescue: + Enabled: false +Lint/UselessRuby2Keywords: + Enabled: false +Metrics/CollectionLiteralLength: + Enabled: false +Naming/BlockForwarding: + Enabled: false +Performance/CollectionLiteralInLoop: + Enabled: false +Performance/ConcurrentMonotonicTime: + Enabled: false +Performance/MapCompact: + Enabled: false +Performance/RedundantEqualityComparisonBlock: + Enabled: false +Performance/RedundantSplitRegexpArgument: + Enabled: false +Performance/StringIdentifierArgument: + Enabled: false +RSpec/BeEq: + Enabled: false +RSpec/BeNil: + Enabled: false +RSpec/ChangeByZero: + Enabled: false +RSpec/ClassCheck: + Enabled: false +RSpec/DuplicatedMetadata: + Enabled: false +RSpec/ExcessiveDocstringSpacing: + Enabled: false +RSpec/FactoryBot/ConsistentParenthesesStyle: + Enabled: false +RSpec/FactoryBot/FactoryNameStyle: + Enabled: false +RSpec/FactoryBot/SyntaxMethods: + Enabled: false +RSpec/IdenticalEqualityAssertion: + Enabled: false +RSpec/NoExpectationExample: + Enabled: false +RSpec/PendingWithoutReason: + Enabled: false +RSpec/Rails/AvoidSetupHook: + Enabled: false +RSpec/Rails/HaveHttpStatus: + Enabled: false +RSpec/Rails/InferredSpecType: + Enabled: false +RSpec/Rails/MinitestAssertions: + Enabled: false +RSpec/Rails/TravelAround: + Enabled: false +RSpec/RedundantAround: + Enabled: false +RSpec/SkipBlockInsideExample: + Enabled: false +RSpec/SortMetadata: + Enabled: false +RSpec/SubjectDeclaration: + Enabled: false +RSpec/VerifiedDoubleReference: + Enabled: false +Security/CompoundHash: + Enabled: false +Security/IoMethods: + Enabled: false +Style/ArgumentsForwarding: + Enabled: false +Style/ArrayIntersect: + Enabled: false +Style/CollectionCompact: + Enabled: false +Style/ComparableClamp: + Enabled: false +Style/ConcatArrayLiterals: + Enabled: false +Style/DataInheritance: + Enabled: false +Style/DirEmpty: + Enabled: false +Style/DocumentDynamicEvalDefinition: + Enabled: false +Style/EmptyHeredoc: + Enabled: false +Style/EndlessMethod: + Enabled: false +Style/EnvHome: + Enabled: false +Style/FetchEnvVar: + Enabled: false +Style/FileEmpty: + Enabled: false +Style/FileRead: + Enabled: false +Style/FileWrite: + Enabled: false +Style/HashConversion: + Enabled: false +Style/HashExcept: + Enabled: false +Style/IfWithBooleanLiteralBranches: + Enabled: false +Style/InPatternThen: + Enabled: false +Style/MagicCommentFormat: + Enabled: false +Style/MapCompactWithConditionalBlock: + Enabled: false +Style/MapToHash: + Enabled: false +Style/MapToSet: + Enabled: false +Style/MinMaxComparison: + Enabled: false +Style/MultilineInPatternThen: + Enabled: false +Style/NegatedIfElseCondition: + Enabled: false +Style/NestedFileDirname: + Enabled: false +Style/NilLambda: + Enabled: false +Style/NumberedParameters: + Enabled: false +Style/NumberedParametersLimit: + Enabled: false +Style/ObjectThen: + Enabled: false +Style/OpenStructUse: + Enabled: false +Style/OperatorMethodCall: + Enabled: false +Style/QuotedSymbols: + Enabled: false +Style/RedundantArgument: + Enabled: false +Style/RedundantConstantBase: + Enabled: false +Style/RedundantDoubleSplatHashBraces: + Enabled: false +Style/RedundantEach: + Enabled: false +Style/RedundantHeredocDelimiterQuotes: + Enabled: false +Style/RedundantInitialize: + Enabled: false +Style/RedundantLineContinuation: + Enabled: false +Style/RedundantSelfAssignmentBranch: + Enabled: false +Style/RedundantStringEscape: + Enabled: false +Style/SelectByRegexp: + Enabled: false +Style/StringChars: + Enabled: false +Style/SwapValues: Enabled: false diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..fa8d5056e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "puppet.puppet-vscode", + "Shopify.ruby-lsp" + ] + } diff --git a/.yardopts b/.yardopts new file mode 100644 index 000000000..29c933bcf --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +--markup markdown diff --git a/CHANGELOG.md b/CHANGELOG.md index 898552257..435f05530 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,33 @@ Changes ======= + + + + + +# 4.0.0 / 2025-03-10 + +This release has multiple breaking changes. You may need to update your module integration. Note that module +dependencies have been updated. + +This release adds support for Puppet 8, updating all classes to use defined class parameters types. Be aware that this change +may break existing implementations. + +* [FEATURE] Add Support for Puppet 8 ([#823])(thanks [@xenon8], [@nielstholenaar]). + * [FEATURE] Update Module Dependencies including updates for StdLib, migrating to newer functions where appropriate. + * [FEATURE] Class definitions updated with references to Datadog examples. + * [FEATURE] Update to CI Builds to work with Ruby 3. + * [BUGFIX] Fix issue where MSI path was not correctly parsed. + * [BUGFIX] BREAKING - `datadog_agent::integrations::disk` now expects booleans for `use_mount`, `all_partitions`, and `tag_by_filesystem`. + * [BUGFIX] Fix `supress_errors` typo in the ActiveMQ_xml check. `supress_errors` is preserved for backwards compatibility, but new `suppress_errors` should be used instead. + * [DEPRECATE] Drop support for Puppet 6 and below. + * [DEPRECATE] Drop support for Datadog Agent version 5, including removal of unit tests. + * [DEPRECATE] Remove `ganglia`, `graphite`, `dogstreams`, `custom_emitters`, and `use_curl_http_client` legacy configuration options, which are no longer supported since Datadog Agent v6+ + * [DEPRECATE] Remove support for supplying a string to the `ssl_verify` option on the elasticsearch integration. We now use `tls_verify` which matches core Datadog code. + * [DEPRECATE] Remove legacy Jenkins integration. + * [DEPRECATE] `skip_event` setting on TCP Check class has been removed from the Datadog integration (removed since Datadog Agent v6.4+). + * [DEPRECATE] Remove support for supplying a String to the `ssl_verify` option on the elasticsearch integration. Add updated `tls_*` options to match core Datadog code. +* [FEATURE] Update mongo configuration template with `dbm`, `database_autodiscovery`, `reported_database_hostname`, and `hosts` parameters. ([#838]) (thanks [@lu-zhengda]). # 3.24.0 / 2025-02-25 @@ -23,6 +51,7 @@ Changes # 3.21.0 / 2023-07-03 * [FEATURE] Trust new APT and RPM keys. ([#782]) + # 3.20.0 / 2023-01-12 * [DEPRECATE] Remove the old RPM GPG key 4172A230 from hosts that still trust it, and stop trusting it. ([#770][]) @@ -68,7 +97,7 @@ Changes * [BUGFIX] Do not add process integration configuration file if not configured ([#703][]) (Thanks [@yanjunding][]) * [FEATURE] add support for `min_collection_interval` for HTTP check ([#699][]) (Thanks [@yanjunding][]) * [FEATURE] Improvements for APT keys management ([#698][], [#700][], [#701][] and [#714][]) -* [FEATURE] Include 'datadog_agent' class in the catalog when using the generic integration ([#697][]) (Thanks [@stantona][]) +* [FEATURE] Include 'datadog_agent' class in the catalog when using the generic integration ([#697][]) (Thanks [@stantona][]) * [BUGFIX] Update `excluded_interface_re` type to String ([#696][]) (Thanks [@florusboth][]) # 3.12.0 / 2021-05-06 @@ -167,9 +196,9 @@ then it is safe to upgrade. ### Notes * [MAJOR] Agent 7 support. See [#588][]. - * Introduces `agent_major_version` parameter that replaces `agent5_enable`. - * Removes `agent6`/`agent5` prefixes in argument names. - * Unifies config for Agent 5/6 repos and removes the use of facter. + * Introduces `agent_major_version` parameter that replaces `agent5_enable`. + * Removes `agent6`/`agent5` prefixes in argument names. + * Unifies config for Agent 5/6 repos and removes the use of facter. * [IMPROVEMENT] Removes uses of `validate_legacy`. * [IMPROVEMENT] Keeps the group ownership of config files as `dd-agent`. * [IMPROVEMENT] Removes `service_name` and `package_name` parameters. @@ -339,6 +368,7 @@ then it is safe to upgrade. # 2.0.0 / 2018-02-27 ### Overview + This release is a major release, there are a some breaking changes. We have tried to keep the interface as similar as possible to what the community was already used to, but have had to make some changes and cleaned up some @@ -447,7 +477,6 @@ Please read the [docs]() for more details. * [DOCUMENTATION] Cleanup EC2-related parameter docs. See [#252][] (Thanks [@jdavisp3][]) * [DOCUMENTATION] Zookeeper: fix comment to match reality. See [#297][] (Thanks [@generica][]) - # 1.9.0 / 2016-12-20 ### Notes @@ -477,8 +506,6 @@ Please read the [docs]() for more details. * [CI] Multiple fixes related to the spec tests on older puppets. * [CI] Consul: adding spec tests. See [#264][]. (Thanks [@flyinprogrammer][]). - - # 1.8.1 / 2016-08-15 ### Notes @@ -628,6 +655,7 @@ Please read the [docs]() for more details. * [FEATURE] Add `use_mount` option in the base datadog_agent class * [FEATURE] Add proxy options in the base datadog_agent class * [BUGFIX] Use correct JMX-styled tags in JMX integrations + > Careful this means that you probably have to update a buggy array of tags (that gives you nothing in the agent) to a hash of tags. * [BUGFIX] Fix ordering in YAML templates using `to_yaml` broken because of ruby 1.8 @@ -670,7 +698,6 @@ Please read the [docs]() for more details. [#164]: https://github.com/DataDog/puppet-datadog-agent/issues/164 [#168]: https://github.com/DataDog/puppet-datadog-agent/issues/168 [#169]: https://github.com/DataDog/puppet-datadog-agent/issues/169 -[#171]: https://github.com/DataDog/puppet-datadog-agent/issues/171 [#173]: https://github.com/DataDog/puppet-datadog-agent/issues/173 [#174]: https://github.com/DataDog/puppet-datadog-agent/issues/174 [#175]: https://github.com/DataDog/puppet-datadog-agent/issues/175 @@ -934,13 +961,16 @@ Please read the [docs]() for more details. [#756]: https://github.com/DataDog/puppet-datadog-agent/issues/756 [#761]: https://github.com/DataDog/puppet-datadog-agent/issues/761 [#770]: https://github.com/DataDog/puppet-datadog-agent/issues/770 +[#779]: https://github.com/DataDog/puppet-datadog-agent/issues/779 [#782]: https://github.com/DataDog/puppet-datadog-agent/issues/782 [#785]: https://github.com/DataDog/puppet-datadog-agent/issues/785 [#789]: https://github.com/DataDog/puppet-datadog-agent/issues/789 [#790]: https://github.com/DataDog/puppet-datadog-agent/issues/790 [#798]: https://github.com/DataDog/puppet-datadog-agent/issues/798 [#799]: https://github.com/DataDog/puppet-datadog-agent/issues/799 +[#800]: https://github.com/DataDog/puppet-datadog-agent/issues/800 [#806]: https://github.com/DataDog/puppet-datadog-agent/issues/806 +[#814]: https://github.com/DataDog/puppet-datadog-agent/issues/814 [#820]: https://github.com/DataDog/puppet-datadog-agent/issues/820 [#821]: https://github.com/DataDog/puppet-datadog-agent/issues/821 [#824]: https://github.com/DataDog/puppet-datadog-agent/issues/824 @@ -1026,12 +1056,14 @@ Please read the [docs]() for more details. [@kevin-bowers]: https://github.com/kevin-bowers [@kitchen]: https://github.com/kitchen [@lowkeyshift]: https://github.com/lowkeyshift +[@lu-zhengda]: https://github.com/lu-zhengda [@mcasper]: https://github.com/mcasper [@milescrabill]: https://github.com/milescrabill [@mraylu]: https://github.com/mraylu [@mrunkel-ut]: https://github.com/mrunkel-ut [@mtougeron]: https://github.com/mtougeron [@murdok5]: https://github.com/murdok5 +[@nielstholenaar]: https://github.com/nielstholenaar [@npaufler]: https://github.com/npaufler [@o0oxid]: https://github.com/o0oxid [@obi11235]: https://github.com/obi11235 @@ -1065,8 +1097,9 @@ Please read the [docs]() for more details. [@turnopil]: https://github.com/turnopil [@tuxinaut]: https://github.com/tuxinaut [@vaisingh]: https://github.com/vaisingh +[@xenon8]: https://github.com/xenon8 [@yanjunding]: https://github.com/yanjunding [@yrcjaya]: https://github.com/yrcjaya [@zabacad]: https://github.com/zabacad [@zickzackv]: https://github.com/zickzackv -[@zoom-kris-anderson]: https://github.com/zoom-kris-anderson \ No newline at end of file +[@zoom-kris-anderson]: https://github.com/zoom-kris-anderson diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 057fd29ae..14230bbbb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,8 +18,9 @@ cd puppet-datadog-agent First, to install the Ruby dependencies run: ```bash -gem install bundler:1.17.3 -bundle install --path .bundle +gem install bundler:2.4.13 +bundle config set --local path '.bundle' +bundle install ``` Afterwards, on the first run of the tests, further dependencies will be installed. diff --git a/Gemfile b/Gemfile index d803173f9..09077c191 100644 --- a/Gemfile +++ b/Gemfile @@ -1,58 +1,115 @@ -source "https://rubygems.org" +source ENV['GEM_SOURCE'] || 'https://rubygems.org' ruby_version = Gem::Version.new(RUBY_VERSION.dup) -# Each version of Puppet recommends a specific version of Ruby. Try to fetch the Puppet version that -# matches our Ruby (unless PUPPET_VERSION is defined). -matching_puppet_version = ruby_version > Gem::Version.new('2.5') ? (ruby_version > Gem::Version.new('2.7') ? '7.0.0' : '6.0.1') : '4.10.2' -puppet_version = ENV.fetch('PUPPET_VERSION', matching_puppet_version) -gem "puppet", "~> #{puppet_version}" +def location_for(place_or_version, fake_version = nil) + git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} + file_url_regex = %r{\Afile:\/\/(?.*)} -ruby_version_segments = ruby_version.segments -minor_version = ruby_version_segments[0..1].join('.') + if place_or_version && (git_url = place_or_version.match(git_url_regex)) + [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact + elsif place_or_version && (file_url = place_or_version.match(file_url_regex)) + ['>= 0', { path: File.expand_path(file_url[:path]), require: false }] + else + [place_or_version, { require: false }] + end +end group :development do - gem "rake", "~> 12.3.3" if ruby_version < Gem::Version.new('2.6.0') # last version for ruby < 2.6 - gem "semantic_puppet", '= 1.0.4' - gem "xmlrpc" if ruby_version >= Gem::Version.new('2.3') - gem "concurrent-ruby", '= 1.1.10' if Gem::Requirement.create([' >= 6.9.0', '<7.25.0']).satisfied_by?(Gem::Version.new(puppet_version)) # Add this beucause until Puppet 7.25 concurrent-ruby 1.22 break puppet - gem "ruby-pwsh", '~> 0.3.0', platforms: [:mswin, :mingw, :x64_mingw] - gem "fast_gettext", '1.1.0', require: false if ruby_version < Gem::Version.new('2.1.0') - gem "fast_gettext", require: false if ruby_version >= Gem::Version.new('2.1.0') - gem "json_pure", '<= 2.0.1', require: false if ruby_version < Gem::Version.new('2.0.0') - gem "json", '= 1.8.1', require: false if ruby_version == Gem::Version.new('2.1.9') - gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(ruby_version) - gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(ruby_version) - gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "librarian-puppet", '<= 4.0.1' + gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "deep_merge", '~> 1.2.2', require: false + gem "parallel_tests", '= 3.12.1', require: false + gem "pry", '~> 0.10', require: false + gem "simplecov-console", '~> 0.9', require: false + gem "puppet-debugger", '~> 1.0', require: false + gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "bcrypt_pbkdf", '= 1.0.1', require: false gem "kitchen-puppet" - gem "kitchen-docker" + gem "kitchen-docker", '~> 3.0.0', require: false gem "kitchen-verifier-serverspec" - gem "mixlib-shellout", "~> 2.2.7", platforms: [:ruby] - gem "rubocop-i18n", "~> 1.2.0" - gem "rubocop-rspec", "~> 1.16.0" - - # https://github.com/ffi/ffi/issues/1103 (pin only for Ruby >= 2.5 as this version is not compatible below. ffi 1.17 is not compatible with Ruby 2.5: https://github.com/ffi/ffi/issues/1103) - if ruby_version >= Gem::Version.new('2.5') - gem "ffi", "= 1.16.3", platforms: [:ruby] + gem "rexml", '~> 3.4.0', require: false + gem "mixlib-shellout", "~> 2.2.7", platforms: [:ruby] + if ruby_version >= Gem::Version.new('2.5') && ruby_version < Gem::Version.new('3.1') + gem "test-kitchen", '= 3.0.0', platforms: [:ruby] + gem "rubocop", '~> 1.30', require: false + gem "rubocop-rspec", '= 2.10.0', require: false + gem "facterdb", '~> 1.21', require: false + gem "rspec-puppet-facts", '~> 1.10.0', require: false + gem "rubocop-performance", '~> 1.11', require: false + gem "librarian-puppet", '= 4.0.1' + gem "io-console", '= 0.5.9', require: false + gem "metadata-json-lint", '~> 3.0.3', require: false + gem "voxpupuli-puppet-lint-plugins", '~> 4.0', require: false + gem "dependency_checker", '= 0.3.0', require: false + gem 'puppet-lint', '~> 3.4.0', require: false else - gem "ffi", require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "facterdb", '~> 3.4.0', require: false + gem "test-kitchen", '~> 3.7.0' + gem "rubocop", '~> 1.50.0', require: false + gem "rubocop-rspec", '= 2.19.0', require: false + gem "rspec-puppet-facts", '~> 5.2.0', require: false + gem "rubocop-performance", '= 1.16.0', require: false + gem "librarian-puppet", '~> 5.0' + gem "io-console", '= 0.7.2', require: false + gem "metadata-json-lint", '~> 4.0', require: false + gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false + gem "dependency_checker", '~> 1.0.0', require: false + gem 'puppet-lint', '~> 4.3.0', require: false end - - if ruby_version >= Gem::Version.new('2.3') - gem "test-kitchen", '~> 2.5.4' - gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] - gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] +end +group :development, :release_prep do + if ruby_version >= Gem::Version.new('2.5') && ruby_version < Gem::Version.new('3.1') + gem "puppetlabs_spec_helper", '~> 5.0.3', require: false + gem "puppet-blacksmith", '= 6.1.1', require: false + gem "puppet-strings", '= 2.9.0', require: false else - gem "test-kitchen", '~> 1.16.0' - gem "puppetlabs_spec_helper", "~> 2.14.1" - gem "puppet-lint", "~> 2.4.2" - gem "metadata-json-lint", "~> 1.2.2" - gem "puppet-syntax", "~> 2.5.0" - gem "rspec-puppet", "~> 2.6.9" - gem "rubocop", "~> 0.49.1" - gem "artifactory", "~> 2.8.2" + gem "puppetlabs_spec_helper", '~> 8.0', require: false + gem "puppet-blacksmith", '~> 7.0', require: false + gem "puppet-strings", '~> 4.0', require: false + end +end +group :system_tests do + if ruby_version >= Gem::Version.new('2.5') && ruby_version < Gem::Version.new('3.0') + gem "puppet_litmus", '= 0.0.1', require: false, platforms: [:ruby, :x64_mingw] + else + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + end + gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "serverspec", '~> 2.41', require: false +end + +puppet_version = ENV['PUPPET_GEM_VERSION'] +facter_version = ENV['FACTER_GEM_VERSION'] +hiera_version = ENV['HIERA_GEM_VERSION'] + +gems = {} + +gems['puppet'] = location_for(puppet_version) + +# If facter or hiera versions have been specified via the environment +# variables + +gems['facter'] = location_for(facter_version) if facter_version +gems['hiera'] = location_for(hiera_version) if hiera_version + +gems.each do |gem_name, gem_params| + gem gem_name, *gem_params +end + +# Evaluate Gemfile.local and ~/.gemfile if they exist +extra_gemfiles = [ + "#{__FILE__}.local", + File.join(Dir.home, '.gemfile'), +] + +extra_gemfiles.each do |gemfile| + if File.file?(gemfile) && File.readable?(gemfile) + eval(File.read(gemfile), binding) end end +# vim: syntax=ruby diff --git a/Gemfile.lock b/Gemfile.lock index 07fddbc5e..7ea5c941c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,34 +1,33 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.3.6) - activesupport (6.1.6.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + CFPropertyList (3.0.6) + rexml + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) ansi (1.5.0) ast (2.4.2) awesome_print (1.9.2) - aws-eventstream (1.2.0) - aws-partitions (1.609.0) - aws-sdk-core (3.131.3) - aws-eventstream (~> 1, >= 1.0.2) - aws-partitions (~> 1, >= 1.525.0) - aws-sigv4 (~> 1.1) + aws-eventstream (1.3.1) + aws-partitions (1.1054.0) + aws-sdk-core (3.219.0) + aws-eventstream (~> 1, >= 1.3.0) + aws-partitions (~> 1, >= 1.992.0) + aws-sigv4 (~> 1.9) + base64 jmespath (~> 1, >= 1.6.1) - aws-sdk-ec2 (1.323.0) - aws-sdk-core (~> 3, >= 3.127.0) - aws-sigv4 (~> 1.1) - aws-sigv4 (1.5.1) + aws-sdk-ec2 (1.506.0) + aws-sdk-core (~> 3, >= 3.216.0) + aws-sigv4 (~> 1.5) + aws-sigv4 (1.11.0) aws-eventstream (~> 1, >= 1.0.2) - bcrypt_pbkdf (1.1.0) - bindata (2.4.10) - bolt (3.24.0) - CFPropertyList (~> 2.2) + base64 (0.2.0) + bcrypt_pbkdf (1.0.1) + bcrypt_pbkdf (1.0.1-x64-mingw32) + bigdecimal (3.1.9) + bindata (2.5.0) + bolt (4.0.0) + CFPropertyList (>= 2.2) addressable (~> 2.5) aws-sdk-ec2 (~> 1) concurrent-ruby (~> 1.0) @@ -37,433 +36,461 @@ GEM jwt (~> 2.2) logging (~> 2.2) minitar (~> 0.6) - net-scp (~> 1.2) - net-ssh (>= 4.0, < 7.0) + net-scp (>= 1.2, < 5.0) + net-ssh (>= 4.0, < 8.0) net-ssh-krb (~> 0.5) - orchestrator_client (~> 0.5) + orchestrator_client (~> 0.7) puppet (>= 6.18.0) puppet-resource_api (>= 1.8.1) - puppet-strings (~> 2.3) - puppetfile-resolver (~> 0.5) - r10k (~> 3.10) + puppet-strings (>= 2.3.0, < 5.0) + puppetfile-resolver (>= 0.6.2, < 1.0) + r10k (>= 3.10, < 5) ruby_smb (~> 1.0) terminal-table (~> 3.0) winrm (~> 2.0) winrm-fs (~> 1.3) - builder (3.2.4) - codecov (0.2.5) - colorize - json - simplecov + builder (3.3.0) + chef-utils (18.6.2) + concurrent-ruby coderay (1.1.3) colored2 (3.1.2) - colorize (0.8.1) - concurrent-ruby (1.1.10) - connection_pool (2.2.5) - cri (2.15.11) + concurrent-ruby (1.3.5) + connection_pool (2.5.0) + cri (2.15.12) deep_merge (1.2.2) - dependency_checker (0.2.0) + dependency_checker (1.0.1) parallel - puppet_forge (~> 2.2) - rake (~> 12.3) + puppet_forge (>= 2.2, < 6.0) + rake (~> 13.0) semantic_puppet (~> 1.0) - diff-lcs (1.5.0) - docile (1.4.0) - docker-api (2.2.0) - excon (>= 0.47.0) + diff-lcs (1.6.0) + docile (1.4.1) + docker-api (2.4.0) + excon (>= 0.64.0) multi_json - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) - ed25519 (1.2.4) - equatable (0.7.0) - erubi (1.10.0) - excon (0.92.4) - facter (4.2.10) + domain_name (0.6.20240107) + ed25519 (1.3.0) + erubi (1.13.1) + excon (1.2.3) + facter (4.10.0) hocon (~> 1.3) - thor (>= 1.0.1, < 2.0) - facterdb (1.19.0) + thor (>= 1.0.1, < 1.3) + facterdb (3.4.0) facter (< 5.0.0) - jgrep - faraday (0.17.4) - multipart-post (>= 1.2, < 3) - faraday_middleware (0.14.0) - faraday (>= 0.7.4, < 1.0) - fast_gettext (1.1.2) - ffi (1.16.3) - ffi-compiler (1.0.1) - ffi (>= 1.0.0) - rake - gettext (3.2.9) + jgrep (~> 1.5, >= 1.5.4) + faraday (2.12.2) + faraday-net_http (>= 2.0, < 3.5) + json + logger + faraday-follow_redirects (0.3.0) + faraday (>= 1, < 3) + faraday-net_http (3.4.0) + net-http (>= 0.5.0) + faraday-net_http_persistent (2.3.0) + faraday (~> 2.5) + net-http-persistent (>= 4.0.4, < 5) + fast_gettext (2.4.0) + prime + ffi (1.17.1) + forwardable (1.3.3) + getoptlong (0.2.1) + gettext (3.5.1) + erubi locale (>= 2.0.5) + prime + racc text (>= 1.3.0) - gettext-setup (0.34) - fast_gettext (~> 1.1.0) - gettext (>= 3.0.2, < 3.3.0) + gettext-setup (1.1.0) + fast_gettext (~> 2.1) + gettext (~> 3.4) locale gssapi (1.3.1) ffi (>= 1.0.1) - gyoku (1.3.1) + gyoku (1.4.0) builder (>= 2.1.2) - hiera (3.9.0) - hiera-eyaml (3.3.0) + rexml (~> 3.0) + hiera-eyaml (3.4.0) highline optimist - highline (2.0.3) - hirb (0.7.3) - hocon (1.3.1) - honeycomb-beeline (2.11.0) - libhoney (>= 1.14.2) - http (4.4.1) - addressable (~> 2.3) - http-cookie (~> 1.0) - http-form_data (~> 2.2) - http-parser (~> 1.2.0) + highline (3.1.2) + reline + hocon (1.4.0) http-accept (1.7.0) - http-cookie (1.0.5) + http-cookie (1.0.8) domain_name (~> 0.5) - http-form_data (2.3.0) - http-parser (1.2.3) - ffi-compiler (>= 1.0, < 2.0) httpclient (2.8.3) - i18n (1.12.0) - concurrent-ruby (~> 1.0) + io-console (0.7.2) jgrep (1.5.4) - jmespath (1.6.1) - json (2.6.2) - json-schema (2.8.1) - addressable (>= 2.4) - jwt (2.2.3) - kitchen-docker (2.11.0) + jmespath (1.6.2) + json (2.6.3) + json-schema (5.1.1) + addressable (~> 2.8) + bigdecimal (~> 3.1) + jwt (2.10.1) + base64 + kitchen-docker (3.0.0) test-kitchen (>= 1.0.0) - kitchen-puppet (3.5.2) + kitchen-puppet (3.7.0) librarian-puppet (>= 3.0) net-ssh (>= 3) test-kitchen (>= 1.4) - kitchen-verifier-serverspec (0.7.1) + kitchen-verifier-serverspec (0.7.2) net-ssh (>= 3) test-kitchen (>= 1.4) - libhoney (2.2.0) - addressable (~> 2.0) - excon - http (>= 2.0, < 6.0) - librarian-puppet (3.0.1) + librarian-puppet (5.0.0) librarianp (>= 0.6.3) - puppet_forge (~> 2.1) + puppet_forge (>= 2.1, < 5) rsync - librarianp (1.1.1) + librarianp (1.1.2) thor (~> 1.0) - license-acceptance (1.0.19) + license-acceptance (2.1.13) pastel (~> 0.7) - tomlrb (~> 1.2) - tty-box (~> 0.3) - tty-prompt (~> 0.18) + tomlrb (>= 1.2, < 3.0) + tty-box (~> 0.6) + tty-prompt (~> 0.20) little-plugger (1.1.4) - locale (2.1.3) + locale (2.1.4) log4r (1.1.10) - logging (2.3.0) + logger (1.6.6) + logging (2.4.0) little-plugger (~> 1.1) multi_json (~> 1.14) - metaclass (0.0.4) - metadata-json-lint (2.4.0) - json-schema (~> 2.8) + metadata-json-lint (4.2.0) + json-schema (>= 2.8, < 6.0) + semantic_puppet (~> 1.0) spdx-licenses (~> 1.0) - method_source (0.8.2) - mime-types (3.4.1) + method_source (1.1.0) + mime-types (3.6.0) + logger mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) - minitar (0.9) - minitest (5.16.2) - mixlib-install (3.12.16) + mime-types-data (3.2025.0220) + minitar (0.12.1) + mixlib-install (3.12.30) mixlib-shellout mixlib-versioning thor mixlib-shellout (2.2.7) mixlib-versioning (1.2.12) - mocha (1.1.0) - metaclass (~> 0.0.1) + mocha (2.7.1) + ruby2_keywords (>= 0.0.5) molinillo (0.8.0) multi_json (1.15.0) - multipart-post (2.1.1) - necromancer (0.5.1) - net-http-persistent (4.0.1) + net-http (0.6.0) + uri + net-http-persistent (4.0.5) connection_pool (~> 2.2) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (6.1.0) + net-scp (4.1.0) + net-ssh (>= 2.6.5, < 8.0.0) + net-ssh (7.3.0) net-ssh-gateway (2.0.0) net-ssh (>= 4.0.0) net-ssh-krb (0.5.1) gssapi (~> 1.3.0) net-ssh (>= 2.0) - net-telnet (0.1.1) + net-telnet (0.2.0) netrc (0.11.0) - nori (2.6.0) - optimist (3.0.1) - orchestrator_client (0.5.4) - faraday (~> 0.17.4) - net-http-persistent - parallel (1.20.1) - parallel_tests (2.14.2) + nori (2.7.1) + bigdecimal + optimist (3.2.0) + orchestrator_client (0.7.1) + faraday (>= 1.4, < 3.0) + faraday-net_http_persistent (>= 1.0, < 3.0) + parallel (1.26.3) + parallel_tests (3.12.1) parallel - parser (2.7.2.0) + parser (3.3.7.1) ast (~> 2.4.1) - pastel (0.7.4) - equatable (~> 0.6) + racc + pastel (0.8.0) tty-color (~> 0.5) - pathspec (1.0.0) + pathspec (2.1.0) pluginator (1.5.0) - powerpack (0.1.3) - pry (0.10.4) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - public_suffix (4.0.7) - puppet (7.0.0) + prime (0.1.3) + forwardable + singleton + pry (0.15.2) + coderay (~> 1.1) + method_source (~> 1.0) + public_suffix (6.0.1) + puppet (8.10.0) concurrent-ruby (~> 1.0) deep_merge (~> 1.0) - facter (> 2.0.1, < 5) - fast_gettext (~> 1.1) - hiera (>= 3.2.1, < 4) + facter (>= 4.3.0, < 5) + fast_gettext (>= 2.1, < 4) + getoptlong (~> 0.2.0) locale (~> 2.1) - multi_json (~> 1.10) + multi_json (~> 1.13) puppet-resource_api (~> 1.5) + scanf (~> 1.0) semantic_puppet (~> 1.0) - puppet-blacksmith (6.1.1) - puppet-modulebuilder (~> 0.2) + puppet-blacksmith (7.1.0) + puppet-modulebuilder (~> 1.0) rest-client (~> 2.0) - puppet-debugger (1.2.0) + puppet-debugger (1.4.0) awesome_print (~> 1.7) bundler facterdb (>= 0.4.0) pluginator (~> 1.5.0) - puppet (>= 5.5) + puppet (>= 6) rb-readline (>= 0.5.5) table_print (>= 1.0.0) - tty-pager (~> 0.13.0) - puppet-lint (2.5.2) - puppet-module-posix-default-r2.7 (1.1.1) - puppet-module-posix-dev-r2.7 (0.5.3) - activesupport (~> 6.0) - bcrypt_pbkdf (~> 1.0) - codecov (>= 0.2, < 0.2.6) - concurrent-ruby (!= 1.1.6) - dependency_checker (~> 0.2) - ed25519 (~> 1.2) - facterdb (>= 0.8.1, < 2.0.0) - gettext-setup (~> 0.26) - metadata-json-lint (>= 2.0.2, < 3.0.0) - mocha (>= 1.0.0, < 1.2.0) - parallel_tests (>= 2.14.1, < 2.14.3) - pry (~> 0.10.4) - puppet-blacksmith (~> 6.0) - puppet-debugger (~> 1.0) - puppet-lint (>= 2.3.0, < 3.0.0) - puppet-resource_api (~> 1.8) - puppet-strings (~> 2.0) - puppet-syntax (>= 2.4.1, < 3.0.0) - puppet_litmus (>= 0.4.0, < 1.0.0) - puppet_pot_generator (~> 1.0) - puppetlabs_spec_helper (>= 2.9.0, < 3.0.0) - rainbow (~> 2.0) - rspec-puppet (>= 2.3.2, < 3.0.0) - rspec-puppet-facts (>= 1.10.0, < 3) - rspec_junit_formatter (~> 0.2) - rubocop (~> 0.49.0) - rubocop-i18n (~> 1.2.0) - rubocop-rspec (~> 1.16.0) - serverspec (~> 2.41) - simplecov (< 0.19.0) - simplecov-console (~> 0.4.2) - specinfra (= 2.82.2) - puppet-modulebuilder (0.3.0) + tty-pager (~> 0.14) + puppet-lint (4.3.0) + puppet-lint-absolute_classname-check (4.0.0) + puppet-lint (>= 3.0, < 5) + puppet-lint-anchor-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-file_ensure-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-leading_zero-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-lookup_in_parameter-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-manifest_whitespace-check (0.3.0) + puppet-lint (>= 1.0, < 5) + puppet-lint-optional_default-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-param-docs (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-param-types (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-params_empty_string-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-resource_reference_syntax (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-strict_indent-check (3.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-topscope-variable-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-trailing_comma-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-unquoted_string-check (3.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-variable_contains_upcase (2.0.0) + puppet-lint (>= 3, < 5) + puppet-lint-version_comparison-check (2.0.0) + puppet-lint (>= 3, < 5) + puppet-modulebuilder (1.1.0) minitar (~> 0.9) - pathspec (>= 0.2.1, < 2.0.0) - puppet-resource_api (1.8.14) + pathspec (>= 0.2.1, < 3.0.0) + puppet-resource_api (1.9.0) hocon (>= 1.0) - puppet-strings (2.9.0) - rgen - yard (~> 0.9.5) - puppet-syntax (2.6.1) - puppet (>= 5) - rake - puppet_forge (2.3.4) - faraday (>= 0.9.0, < 0.18.0, != 0.13.1) - faraday_middleware (>= 0.9.0, < 0.15.0) - gettext-setup (~> 0.11) + puppet-strings (4.1.3) + rgen (~> 0.9) + yard (~> 0.9, < 0.9.37) + puppet-syntax (4.1.1) + puppet (>= 7, < 9) + rake (~> 13.1) + puppet_forge (4.1.0) + faraday (~> 2.0) + faraday-follow_redirects (~> 0.3.0) minitar semantic_puppet (~> 1.0) - puppet_litmus (0.34.0) - bolt (>= 2.0.1, < 4.0.0) + puppet_litmus (1.6.1) + bolt (~> 4.0) docker-api (>= 1.34, < 3.0.0) - honeycomb-beeline parallel - puppet-modulebuilder (>= 0.2.1, < 1.0.0) + puppet-modulebuilder (>= 0.3.0) retryable (~> 3.0) rspec - rspec_honeycomb_formatter tty-spinner (>= 0.5.0, < 1.0.0) - puppet_pot_generator (1.0.1) - puppet - puppetfile-resolver (0.6.2) + puppetfile-resolver (0.6.3) molinillo (~> 0.6) semantic_puppet (~> 1.0) - puppetlabs_spec_helper (2.16.0) - mocha (~> 1.0) - pathspec (>= 0.2.1, < 1.1.0) - puppet-lint (~> 2.0) - puppet-syntax (>= 2.0, < 4) - rspec-puppet (~> 2.0) - r10k (3.15.0) + puppetlabs_spec_helper (8.0.0) + mocha (>= 1.0, < 3) + pathspec (>= 0.2, < 3) + puppet-lint (~> 4.0) + puppet-syntax (~> 4.1, >= 4.1.1) + rspec-github (~> 2.0) + rspec-puppet (~> 5.0) + r10k (4.1.0) colored2 (= 3.1.2) cri (>= 2.15.10) - fast_gettext (>= 1.1.0, < 3.0.0) - gettext (>= 3.0.2, < 4.0.0) - gettext-setup (~> 0.24) - jwt (~> 2.2.3) + gettext-setup (>= 0.24, < 2.0) + jwt (>= 2.2.3, < 3) log4r (= 1.1.10) minitar (~> 0.9) multi_json (~> 1.10) - puppet_forge (>= 2.3.0) - rainbow (2.2.2) - rake - rake (12.3.3) + puppet_forge (>= 4.1, < 6) + racc (1.8.1) + rainbow (3.1.1) + rake (13.2.1) rb-readline (0.5.5) + regexp_parser (2.10.0) + reline (0.6.0) + io-console (~> 0.5) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) + rest-client (2.1.0-x64-mingw32) + ffi (~> 1.9) + http-accept (>= 1.7.0, < 2.0) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) retryable (3.0.5) - rgen (0.9.0) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rexml (3.4.1) + rgen (0.10.2) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.3) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-its (1.3.0) - rspec-core (>= 3.0.0) - rspec-expectations (>= 3.0.0) - rspec-mocks (3.11.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-puppet (2.12.0) - rspec - rspec-puppet-facts (2.0.5) - facter - facterdb (>= 0.5.0) - puppet - rspec-support (3.11.0) - rspec_honeycomb_formatter (0.2.1) - honeycomb-beeline + rspec-support (~> 3.13.0) + rspec-github (2.4.0) rspec-core (~> 3.0) - rspec_junit_formatter (0.5.1) - rspec-core (>= 2, < 4, != 2.12.0) + rspec-its (2.0.0) + rspec-core (>= 3.13.0) + rspec-expectations (>= 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-puppet (5.0.0) + rspec (~> 3.0) + rspec-puppet-facts (5.2.0) + deep_merge (~> 1.2) + facter (< 5) + facterdb (~> 3.1) + puppet (>= 7, < 9) + rspec-support (3.13.2) rsync (1.0.9) - rubocop (0.49.1) + rubocop (1.50.2) + json (~> 2.3) parallel (~> 1.10) - parser (>= 2.3.3.1, < 3.0) - powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + parser (>= 3.2.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - rubocop-i18n (1.2.0) - rubocop (~> 0.49.0) - rubocop-rspec (1.16.0) - rubocop (>= 0.49.0) - ruby-progressbar (1.11.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.38.0) + parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) + rubocop (~> 1.41) + rubocop-performance (1.16.0) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rspec (2.19.0) + rubocop (~> 1.33) + rubocop-capybara (~> 2.17) + ruby-progressbar (1.13.0) + ruby2_keywords (0.0.5) ruby_smb (1.1.0) bindata rubyntlm windows_error - rubyntlm (0.6.3) - rubyzip (2.3.2) - semantic_puppet (1.0.4) - serverspec (2.42.0) + rubyntlm (0.6.5) + base64 + rubyzip (2.4.1) + scanf (1.0.0) + semantic_puppet (1.1.1) + serverspec (2.42.3) multi_json rspec (~> 3.0) rspec-its specinfra (~> 2.72) sfl (2.3) - simplecov (0.18.5) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) - simplecov-console (0.4.2) + simplecov_json_formatter (~> 0.1) + simplecov-console (0.9.3) ansi - hirb simplecov - simplecov-html (0.12.3) - slop (3.6.0) + terminal-table + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) + singleton (0.3.0) spdx-licenses (1.3.0) - specinfra (2.82.2) + specinfra (2.91.0) + base64 net-scp net-ssh (>= 2.7) - net-telnet (= 0.1.1) + net-telnet sfl - strings (0.1.8) - strings-ansi (~> 0.1) - unicode-display_width (~> 1.5) + strings (0.2.1) + strings-ansi (~> 0.2) + unicode-display_width (>= 1.5, < 3.0) unicode_utils (~> 1.4) strings-ansi (0.2.0) table_print (1.5.7) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - test-kitchen (2.5.4) + test-kitchen (3.7.0) bcrypt_pbkdf (~> 1.0) + chef-utils (>= 16.4.35) ed25519 (~> 1.2) - license-acceptance (~> 1.0, >= 1.0.11) + license-acceptance (>= 1.0.11, < 3.0) mixlib-install (~> 3.6) mixlib-shellout (>= 1.2, < 4.0) - net-scp (>= 1.1, < 4.0) - net-ssh (>= 2.9, < 7.0) + net-scp (>= 1.1, < 5.0) + net-ssh (>= 2.9, < 8.0) net-ssh-gateway (>= 1.2, < 3.0) thor (>= 0.19, < 2.0) winrm (~> 2.0) winrm-elevated (~> 1.0) winrm-fs (~> 1.1) text (1.3.1) - thor (1.1.0) - tomlrb (1.3.0) - tty-box (0.5.0) - pastel (~> 0.7.2) - strings (~> 0.1.6) + thor (1.2.2) + tomlrb (2.0.3) + tty-box (0.7.0) + pastel (~> 0.8) + strings (~> 0.2.0) tty-cursor (~> 0.7) tty-color (0.6.0) tty-cursor (0.7.1) - tty-pager (0.13.0) - strings (~> 0.1.8) + tty-pager (0.14.0) + strings (~> 0.2.0) tty-screen (~> 0.8) - tty-prompt (0.21.0) - necromancer (~> 0.5.0) - pastel (~> 0.7.0) - tty-reader (~> 0.7.0) - tty-reader (0.7.0) + tty-prompt (0.23.1) + pastel (~> 0.8) + tty-reader (~> 0.8) + tty-reader (0.9.0) tty-cursor (~> 0.7) - tty-screen (~> 0.7) - wisper (~> 2.0.0) - tty-screen (0.8.1) + tty-screen (~> 0.8) + wisper (~> 2.0) + tty-screen (0.8.2) tty-spinner (0.9.3) tty-cursor (~> 0.7) - tzinfo (2.0.5) - concurrent-ruby (~> 1.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.8.2) - unicode-display_width (1.7.0) + unicode-display_width (2.6.0) unicode_utils (1.4.0) - webrick (1.7.0) - windows_error (0.1.4) - winrm (2.3.6) + uri (1.0.2) + voxpupuli-puppet-lint-plugins (5.0.0) + puppet-lint (~> 4.0) + puppet-lint-absolute_classname-check (~> 4.0) + puppet-lint-anchor-check (~> 2.0) + puppet-lint-file_ensure-check (~> 2.0) + puppet-lint-leading_zero-check (~> 2.0) + puppet-lint-lookup_in_parameter-check (~> 2.0) + puppet-lint-manifest_whitespace-check (~> 0.3, < 1.0.0) + puppet-lint-optional_default-check (~> 2.0) + puppet-lint-param-docs (~> 2.0) + puppet-lint-param-types (~> 2.0) + puppet-lint-params_empty_string-check (~> 2.0) + puppet-lint-resource_reference_syntax (~> 2.0) + puppet-lint-strict_indent-check (~> 3.0) + puppet-lint-topscope-variable-check (~> 2.0) + puppet-lint-trailing_comma-check (~> 2.0) + puppet-lint-unquoted_string-check (~> 3.0) + puppet-lint-variable_contains_upcase (~> 2.0) + puppet-lint-version_comparison-check (~> 2.0) + windows_error (0.1.5) + winrm (2.3.9) builder (>= 2.1.2) erubi (~> 1.8) gssapi (~> 1.2) gyoku (~> 1.0) httpclient (~> 2.2, >= 2.2.0.2) logging (>= 1.6.1, < 3.0) - nori (~> 2.0) + nori (~> 2.0, >= 2.7.1) + rexml (~> 3.0) rubyntlm (~> 0.6.0, >= 0.6.3) winrm-elevated (1.2.3) erubi (~> 1.8) @@ -475,36 +502,46 @@ GEM rubyzip (~> 2.0) winrm (~> 2.0) wisper (2.0.1) - xmlrpc (0.3.2) - webrick - yard (0.9.28) - webrick (~> 1.7.0) - zeitwerk (2.6.0) + yard (0.9.36) PLATFORMS - ruby + arm64-darwin-22 + arm64-darwin-24 + x64-mingw32 DEPENDENCIES - concurrent-ruby (= 1.1.10) - fast_gettext - ffi (= 1.16.3) - kitchen-docker + CFPropertyList (< 3.0.7) + bcrypt_pbkdf (= 1.0.1) + deep_merge (~> 1.2.2) + dependency_checker (~> 1.0.0) + facterdb (~> 3.4.0) + io-console (= 0.7.2) + json (= 2.6.3) + kitchen-docker (~> 3.0.0) kitchen-puppet kitchen-verifier-serverspec - librarian-puppet (<= 4.0.1) + librarian-puppet (~> 5.0) + metadata-json-lint (~> 4.0) mixlib-shellout (~> 2.2.7) - puppet (~> 7.0.0) - puppet-module-posix-default-r2.7 - puppet-module-posix-dev-r2.7 - puppet-module-win-default-r2.7 - puppet-module-win-dev-r2.7 + parallel_tests (= 3.12.1) + pry (~> 0.10) + puppet + puppet-blacksmith (~> 7.0) + puppet-debugger (~> 1.0) + puppet-lint (~> 4.3.0) + puppet-strings (~> 4.0) + puppet_litmus (~> 1.0) + puppetlabs_spec_helper (~> 8.0) rb-readline (= 0.5.5) - rubocop-i18n (~> 1.2.0) - rubocop-rspec (~> 1.16.0) - ruby-pwsh (~> 0.3.0) - semantic_puppet (= 1.0.4) - test-kitchen (~> 2.5.4) - xmlrpc + rexml (~> 3.4.0) + rspec-puppet-facts (~> 5.2.0) + rubocop (~> 1.50.0) + rubocop-performance (= 1.16.0) + rubocop-rspec (= 2.19.0) + serverspec (~> 2.41) + simplecov-console (~> 0.9) + test-kitchen (~> 3.7.0) + voxpupuli-puppet-lint-plugins (~> 5.0) BUNDLED WITH - 1.17.3 + 2.4.13 diff --git a/README.md b/README.md index 86fe3d249..5a2fdf375 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ This module installs the Datadog Agent and sends Puppet reports to Datadog. ### Requirements -The Datadog Puppet module supports Linux and Windows and is compatible with Puppet >= 4.6.x or Puppet Enterprise version >= 2016.4. For detailed information on compatibility, check the [module page on Puppet Forge][1]. +The Datadog Puppet module supports Linux and Windows and is compatible with Puppet >= 7.34.x or Puppet Enterprise +version >= 2021.7.x. For detailed information on compatibility, check the [module page on Puppet Forge][1]. ### Installation @@ -16,13 +17,25 @@ puppet module install datadog-datadog_agent #### Upgrading -- By default Datadog Agent v7.x is installed. To use an earlier Agent version, change the setting `agent_major_version`. -- `agent5_enable` is no longer used, as it has been replaced by `agent_major_version`. -- `agent6_extra_options` has been renamed to `agent_extra_options` since it applies to both Agent v6 and v7. -- `agent6_log_file` has been renamed to `agent_log_file` since it applies to both Agent v6 and v7. -- `agent5_repo_uri` and `agent6_repo_uri` become `agent_repo_uri` for all Agent versions. -- `conf_dir` and `conf6_dir` become `conf_dir` for all Agent versions. -- The repository file created on Linux is named `datadog` for all Agent versions instead of `datadog5`/`datadog6`. +> [!IMPORTANT] +> The Datadog Puppet Module v4.x drops support for Puppet <= 6 and Datadog Agent v5. To upgrade or install the Datadog +> Agent v5+ on Puppet <= 6, use module v3.x. + +- By default, Datadog Agent v7.x is installed. To use Agent version 6, change the setting `agent_major_version`. +- Agent v5-specific legacy options have been removed. Refer to the CHANGELOG.md for more details and the datadog_agent class comments for all available options. + +> [!IMPORTANT] +> Updates and breaking changes have been made in the below agent integrations: + + - ActiveMQ_XML + - `suppress_errors` config should now be used instead of `supress_errors` (backward-compatible) + - ElasticSearch **[BREAKING CHANGES]** + - `ssl_verify` accepts only Boolean values + - `tls_verify` options have been added + - Disk Check **[BREAKING CHANGES]** + - `use_mount`, `all_partitions`, and `tag_by_filesystem` accept only Boolean values + - TCP Check + - `skip_event` option has been removed sinced Datadog Agent v6.4+ ### Configuration @@ -291,15 +304,15 @@ These variables can be set in the `datadog_agent` class to control settings in t | variable name | description | |-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `agent_major_version` | The version of the Agent to install: either 5, 6 or 7 (default: 7). | +| `agent_major_version` | The version of the Agent to install: either 6 or 7 (default: 7). | | `agent_version` | Lets you pin a specific minor version of the Agent to install, for example: `1:7.16.0-1`. Leave empty to install the latest version. | | `collect_ec2_tags` | Collect an instance's custom EC2 tags as Agent tags by using `true`. | | `collect_instance_metadata` | Collect an instance's EC2 metadata as Agent tags by using `true`. | -| `datadog_site` | The Datadog site to report to (Agent v6 and v7 only). Defaults to `datadoghq.com`, eg: `datadoghq.eu` or `us3.datadoghq.com`. | +| `datadog_site` | The Datadog site to report to. Defaults to `datadoghq.com`, eg: `datadoghq.eu` or `us3.datadoghq.com`. | | `dd_url` | The Datadog intake server URL. You are unlikely to need to change this. Overrides `datadog_site` | | `host` | Overrides the node's host name. | | `local_tags` | An array of `` strings that are set as tags for the node. | -| `non_local_traffic` | Allow other nodes to relay their traffic through this node. | +| `non_local_traffic` | Allow other nodes to relay their DogstatsD traffic through this node. | | `apm_enabled` | A boolean to enable the APM Agent (defaults to false). | | `process_enabled` | A boolean to enable the process Agent (defaults to false). | | `scrub_args` | A boolean to enable the process cmdline scrubbing (defaults to true). | diff --git a/Rakefile b/Rakefile index 7c1fd16db..130ff70ec 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,10 @@ +# frozen_string_literal: true + +require 'bundler' +require 'puppet_litmus/rake_tasks' if Gem.loaded_specs.key? 'puppet_litmus' require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' +require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? require 'puppet-lint/tasks/puppet-lint' require 'rubocop/rake_task' @@ -13,6 +18,16 @@ exclude_paths = [ PuppetLint.configuration.ignore_paths = exclude_paths PuppetSyntax.exclude_paths = exclude_paths +PuppetLint.configuration.send('disable_relative') +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_140chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_autoloader_layout') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.fail_on_warnings = true +PuppetLint.configuration.ignore_paths = [".vendor/**/*.pp", ".bundle/**/*.pp", "pkg/**/*.pp", "spec/**/*.pp", "tests/**/*.pp", "types/**/*.pp", "vendor/**/*.pp"] + desc "Run syntax, lint, and spec tests." task :test => [ 'syntax', diff --git a/environments/etc/Gemfile b/environments/etc/Gemfile index 83a6715d7..2c67d16f7 100644 --- a/environments/etc/Gemfile +++ b/environments/etc/Gemfile @@ -1,4 +1,11 @@ source 'https://rubygems.org' -gem 'semantic_puppet', '1.0.4' -gem 'multipart-post', '2.1.1' -gem 'r10k', '2.6.7' \ No newline at end of file +gem 'semantic_puppet', '1.1.1' +gem 'multipart-post', '2.4.1' +gem 'r10k', '4.1.0' +gem 'json', '2.6.3' +gem 'racc', '~> 1.4.0' +gem 'net-ssh', '~> 7.3' +gem "facterdb", '~> 3.4.0' +gem "rspec-puppet-facts", '~> 5.2.0' +gem "facter", '~> 4.10.0' +gem "kitchen-puppet", '~> 3.7.0' \ No newline at end of file diff --git a/environments/etc/Puppetfile b/environments/etc/Puppetfile index d5db04514..e1cc4edd2 100644 --- a/environments/etc/Puppetfile +++ b/environments/etc/Puppetfile @@ -1,9 +1,8 @@ # Track control branch and fall-back to master if no matching branch. mod 'datadog_agent', :local => true -mod 'puppetlabs-apt', '2.4.0' -mod 'puppetlabs-concat', '4.0.0' -mod 'puppetlabs-puppetserver_gem', '1.0.0' -mod 'puppetlabs-stdlib', '4.25.0' -mod 'puppetlabs-powershell', '2.3.0' -mod 'puppetlabs-yumrepo_core', '1.0.3' -mod 'puppet-zypprepo', '3.1.0' +mod 'puppetlabs-apt', '10.0.1' +mod 'puppetlabs-concat', '9.1.0' +mod 'puppetlabs-stdlib', '9.7.0' +mod 'puppetlabs-powershell', '6.0.2' +mod 'puppetlabs-yumrepo_core', '2.1.0' +mod 'puppet-zypprepo', '5.0.0' diff --git a/environments/etc/manifests/site.pp b/environments/etc/manifests/site.pp index 78fde18db..dc594938c 100644 --- a/environments/etc/manifests/site.pp +++ b/environments/etc/manifests/site.pp @@ -1,9 +1,8 @@ node default { - class { 'datadog_agent': api_key => 'somenonnullapikeythats32charlong', agent_extra_options => { - use_http => true, + use_http => true, }, # Hostname is necessary for Agent to start up properly in container since 7.40.0 # https://github.com/DataDog/datadog-agent/issues/14152#issuecomment-1301842615 @@ -24,5 +23,4 @@ username => 'status', password => 'hunter1', } - } diff --git a/functions/tag6.pp b/functions/tag6.pp index 8e63a1c11..8c02abbfb 100644 --- a/functions/tag6.pp +++ b/functions/tag6.pp @@ -9,7 +9,7 @@ function datadog_agent::tag6( ) { if $tag_names =~ Array { $tags = $tag_names.reduce([]) |$_tags , $tag| { - concat($_tags, datadog_agent::tag6($tag, $lookup_fact, $lookup_table)) + concat($_tags, datadog_agent::tag6($tag, $lookup_fact, $lookup_table)) } } else { if $lookup_fact =~ String { diff --git a/kitchen.yml b/kitchen.yml index bcee3051d..998d744f6 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -14,118 +14,173 @@ provisioner: custom_pre_apply_command: 'cp -r /tmp/modules/* /tmp/kitchen/modules/' platforms: - - name: centos-7-puppet-5 - driver_config: - # we use a custom image that runs systemd - image: 'datadog/docker-library:chef_kitchen_systemd_centos_7' - run_command: /root/start.sh - driver: - provision_command: - - rpm -ivh http://yum.puppetlabs.com/puppet5-release-el-7.noarch.rpm #installs the puppet-agent repo - - yum install -y puppet-agent rubygems - - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet - - - mkdir /home/kitchen/puppet - - printf <%= File.read('environments/etc/Puppetfile').inspect %> > /home/kitchen/puppet/Puppetfile - - printf <%= File.read('environments/etc/Gemfile').inspect %> > /home/Gemfile - - - gem install bundler -v '= 1.17.3' - # we use bundle to install gems and to lock dependencies versions of semantic_puppet and multipart-post - - cd /home && bundle install - - cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules - - - name: rocky-8-puppet-5 - driver_config: - # we use a custom image that runs systemd - image: 'datadog/docker-library:chef_kitchen_systemd_rocky_8' - platform: rhel # kitchen-docker doesn't recognize rocky otherwise - run_command: /root/start.sh - driver: - provision_command: - - dnf install -y https://yum.puppetlabs.com/puppet7-release-el-8.noarch.rpm #installs the puppet-agent repo - - dnf install -y puppet-agent rubygems - - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet - - - mkdir /home/kitchen/puppet - - printf <%= File.read('environments/etc/Puppetfile').inspect %> > /home/kitchen/puppet/Puppetfile - - printf <%= File.read('environments/etc/Gemfile').inspect %> > /home/Gemfile - - - gem install bundler -v '= 1.17.3' - - - cd /home && bundle install - - cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules - - - name: ubuntu-1604-puppet-6 - driver_config: - # we use the official image - image: 'ubuntu:16.04' - driver: - provision_command: - - apt-get install -y apt-utils apt-transport-https ca-certificates - - wget https://apt.puppetlabs.com/puppet6-release-xenial.deb - - dpkg -i puppet6-release-xenial.deb #installs the puppet-agent repo - - apt-get update - - apt-get install -y puppet-agent rubygems - - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet - - - mkdir /home/kitchen/puppet - - printf <%= File.read('environments/etc/Puppetfile').inspect %> > /home/kitchen/puppet/Puppetfile - - printf <%= File.read('environments/etc/Gemfile').inspect %> > /home/Gemfile - - - gem install bundler -v '= 1.17.3' - - cd /home && bundle install - - cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules - - - name: opensuse/leap-15 - # Workaround for flakes on initializing opensuse/leap-15: - # => SCP did not finish successfully (255): (Net::SCP::Error) - transport: - max_ssh_sessions: 1 - driver_config: - # we use a custom image that runs systemd - image: 'datadog/docker-library:chef_kitchen_systemd_opensuse_leap_15' - run_command: /root/start.sh - - driver: - provision_command: - - zypper ar -G https://yum.puppet.com/puppet/sles/15/x86_64/ puppet-repo - - zypper install -y puppet-agent ruby=2.5 - - gem install bundler -v '= 1.17.3' - - gem install net-ssh -v '= 6.1.0' - - gem install rspec-its -v '= 1.3.1' - - gem install serverspec rspec - - ln -s /usr/bin/rspec.ruby2.5 /usr/bin/rspec - - ln -s /opt/puppetlabs/puppet/bin/puppet /usr/bin/puppet - - mkdir /home/kitchen/puppet - - printf <%= File.read('environments/etc/Puppetfile').inspect %> > /home/kitchen/puppet/Puppetfile - - printf <%= File.read('environments/etc/Gemfile').inspect %> > /home/Gemfile - - - cd /home && bundle.ruby2.5 install - - cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules - -verifier: - name: serverspec +- name: ubuntu-24.04-puppet-8 + driver: + image: 'ubuntu:24.04' + provision_command: + - apt-get install -y apt-utils apt-transport-https ca-certificates + - wget https://apt.puppet.com/puppet8-release-noble.deb + - dpkg -i puppet8-release-noble.deb #installs the puppet-agent repo + - apt-get update + - apt-get install -y puppet-agent rubygems ruby-dev make gcc + - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet + + - mkdir /home/kitchen/puppet + - printf <%= File.read('environments/etc/Puppetfile').inspect %> > /home/kitchen/puppet/Puppetfile + - printf <%= File.read('environments/etc/Gemfile').inspect %> > /home/Gemfile + + - gem install bundler -v '= 2.4.13' + - cd /home && bundle install + - cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules + +- name: ubuntu-22.04-puppet-8 + driver: + image: 'ubuntu:22.04' + provision_command: + - apt-get update + - apt-get install -y apt-utils apt-transport-https ca-certificates wget + - wget https://apt.puppet.com/puppet8-release-jammy.deb + - dpkg -i puppet8-release-jammy.deb #installs the puppet-agent repo + - apt-get update + - apt-get install -y puppet-agent rubygems ruby-dev make gcc + - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet + + - mkdir /home/kitchen/puppet -p + - printf <%= File.read('environments/etc/Puppetfile').inspect %> > /home/kitchen/puppet/Puppetfile + - printf <%= File.read('environments/etc/Gemfile').inspect %> > /home/Gemfile + + - gem install bundler -v '= 2.4.13' + - cd /home && bundle install + - cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules + +- name: ubuntu-20.04-puppet-7 + driver: + image: 'ubuntu:20.04' + docker_platform: linux/amd64 + provision_command: + - apt-get install -y apt-utils apt-transport-https ca-certificates make gcc + - wget https://apt.puppet.com/puppet7-release-focal.deb + - dpkg -i puppet7-release-focal.deb #installs the puppet-agent repo + - apt-get update + - apt-get install -y puppet-agent rubygems ruby-dev + - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet + + - mkdir /home/kitchen/puppet + - printf <%= File.read('environments/etc/Puppetfile').inspect %> > /home/kitchen/puppet/Puppetfile + - printf <%= File.read('environments/etc/Gemfile').inspect %> > /home/Gemfile + + - gem install bundler -v '= 2.4.13' + - cd /home && bundle install + - cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules + +- name: centos-stream9-puppet-8 + driver: + image: 'datadog/docker-library:chef_kitchen_systemd_centos_9' + platform: centosstream + docker_platform: linux/amd64 + privileged: true + run_options: --cgroupns=host --tmpfs=/run --volume=/sys/fs/cgroup:/sys/fs/cgroup:rw + run_command: /root/start.sh + provision_command: + - dnf module -y reset ruby + - dnf module -y enable ruby:3.1 + - dnf module -y install ruby:3.1/common + + - rpm -Uvh https://yum.puppet.com/puppet8-release-el-9.noarch.rpm #installs the puppet-agent repo + - yum install -y puppet-agent-8.10.0 rubygems ruby-devel procps-ng + - dnf group install -y "Development Tools" + - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet + + - mkdir /home/kitchen/puppet -p + - printf <%= File.read('environments/etc/Puppetfile').inspect %> > /home/kitchen/puppet/Puppetfile + - printf <%= File.read('environments/etc/Gemfile').inspect %> > /home/Gemfile + + - gem install bundler -v '= 2.4.13' + # we use bundle to install gems and to lock dependencies versions of semantic_puppet and multipart-post + - cd /home && bundle install + - cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules + +- name: rocky-9-puppet-8 + driver: + image: 'datadog/docker-library:chef_kitchen_systemd_rocky_9' + platform: rhel # kitchen-docker has issues installing packages otherwises + docker_platform: linux/amd64 + privileged: true + run_options: --cgroupns=host --volume=/sys/fs/cgroup:/sys/fs/cgroup:rw + run_command: /root/start.sh + provision_command: + - dnf module -y reset ruby + - dnf module -y enable ruby:3.1 + - dnf module -y install ruby:3.1/common + + - rpm -Uvh https://yum.puppet.com/puppet8-release-el-9.noarch.rpm #installs the puppet-agent repo + - yum install -y puppet-agent-8.10.0 rubygems ruby-devel procps-ng + - dnf group install -y "Development Tools" + - ln -s /opt/puppetlabs/bin/puppet /usr/bin/puppet + + - mkdir /home/kitchen/puppet -p + - printf <%= File.read('environments/etc/Puppetfile').inspect %> > /home/kitchen/puppet/Puppetfile + - printf <%= File.read('environments/etc/Gemfile').inspect %> > /home/Gemfile + + - gem install bundler -v '= 2.4.13' + # we use bundle to install gems and to lock dependencies versions of semantic_puppet and multipart-post + - cd /home && bundle install + - cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules + +#- name: opensuse/leap-15 +# # Workaround for flakes on initializing opensuse/leap-15: +# # => SCP did not finish successfully (255): (Net::SCP::Error) +# transport: +# max_ssh_sessions: 1 +# driver_config: +# # we use a custom image that runs systemd +# image: 'datadog/docker-library:chef_kitchen_systemd_opensuse_leap_15' +# docker_platform: linux/amd64 +# run_command: /root/start.sh +# driver: +# provision_command: +# - zypper ar -G https://yum.puppet.com/puppet/sles/15/x86_64/ puppet-repo +# - zypper refresh +# - zypper install -y puppet-agent +# - export PATH="/opt/puppetlabs/puppet/bin:$PATH" +# - ruby -v +# - puppet --version +# +# - gem install bundler -v '= 1.17.3' +# - gem install net-ssh -v '= 6.1.0' +# - gem install rspec-its -v '= 1.3.1' +# - gem install serverspec rspec +# - ln -s /usr/bin/rspec.ruby2.7 /usr/bin/rspec +# - ln -s /opt/puppetlabs/puppet/bin/puppet /usr/bin/puppet +# - mkdir /home/kitchen/puppet +# - printf <%= File.read('environments/etc/Puppetfile').inspect %> > /home/kitchen/puppet/Puppetfile +# - printf <%= File.read('environments/etc/Gemfile').inspect %> > /home/Gemfile +# +# - cd /home && bundle.ruby2.7 install +# - cd /home/kitchen/puppet && r10k puppetfile install --moduledir=/tmp/modules suites: - - name: dd-agent - manifests: init.pp - verifier: - default_pattern: true - additional_install_commmand: source /etc/profile.d/rvm.sh - env_vars: - TARGET_HOST: 127.0.0.1 - TARGET_PORT: 2222 - LOGIN_USER: root - LOGIN_PASSWORD: puppet - - name: dd-installer - manifests: init.pp - provisioner: - manifests_path: environments/etc/installer-manifests - verifier: - default_pattern: true - additional_install_commmand: source /etc/profile.d/rvm.sh - env_vars: - TARGET_HOST: 127.0.0.1 - TARGET_PORT: 2222 - LOGIN_USER: root - LOGIN_PASSWORD: puppet \ No newline at end of file +- name: dd-agent + manifests: init.pp + verifier: + name: serverspec + default_pattern: true + additional_install_commmand: source /etc/profile.d/rvm.sh + env_vars: + TARGET_HOST: 127.0.0.1 + TARGET_PORT: 2222 + LOGIN_USER: root + LOGIN_PASSWORD: puppet +- name: dd-installer + manifests: init.pp + provisioner: + manifests_path: environments/etc/installer-manifests + verifier: + name: serverspec + default_pattern: true + additional_install_commmand: source /etc/profile.d/rvm.sh + env_vars: + TARGET_HOST: 127.0.0.1 + TARGET_PORT: 2222 + LOGIN_USER: root + LOGIN_PASSWORD: puppet diff --git a/lib/puppet/reports/datadog_reports.rb b/lib/puppet/reports/datadog_reports.rb index 56ee35288..86ffde7f4 100644 --- a/lib/puppet/reports/datadog_reports.rb +++ b/lib/puppet/reports/datadog_reports.rb @@ -127,7 +127,7 @@ def process Puppet.debug "Sending metrics for #{@msg_host} to Datadog" @dog.batch_metrics do metrics.each do |metric, data| - data.values.each do |val| + data.each_value do |val| name = "puppet.#{val[1].tr(' ', '_')}.#{metric}".downcase value = val[2] @dog.emit_point(name.to_s, value, host: @msg_host.to_s) @@ -137,7 +137,7 @@ def process facts = Puppet::Node::Facts.indirection.find(host).values facts_tags = REPORT_FACT_TAGS.map { |name| "#{name}:#{facts.dig(*name.split('.'))}" } - trusted_facts = (Puppet.lookup(:trusted_information) { Hash.new }).to_h + trusted_facts = (Puppet.lookup(:trusted_information) { {} }).to_h trusted_fact_tags = REPORT_TRUSTED_FACT_TAGS.map { |name| "#{name}:#{trusted_facts.dig(*name.split('.'))}" } dog_tags = facts_tags + trusted_fact_tags @@ -147,7 +147,7 @@ def process msg_title: event_title, event_type: 'config_management.run', event_object: @msg_host, - alert_type: alert_type, + alert_type: alert_type, # rubocop:disable Style/HashSyntax priority: event_priority, source_type_name: 'puppet', tags: dog_tags), diff --git a/manifests/init.pp b/manifests/init.pp index 0d622015d..f4fdf417f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -49,9 +49,6 @@ # $non_local_traffic # Enable you to use the agent as a proxy. Defaults to false. # See https://github.com/DataDog/dd-agent/wiki/Proxy-Configuration -# $dogstreams -# Optional array of logs to parse and custom parsers to use. -# See https://github.com/DataDog/dd-agent/blob/ed5e698/datadog.conf.example#L149-L178 # $log_level # Set value of 'log_level' variable. Default is 'info' as in dd-agent. # Valid values here are: critical, debug, error, fatal, info, warn and warning. @@ -92,8 +89,6 @@ # separate way of adding keys. # $skip_ssl_validation # Skip SSL validation. -# $use_curl_http_client -# Uses the curl HTTP client for the forwarder # $recent_point_threshold # Sets the threshold for accepting points. # String. Default: empty (30 second intervals) @@ -147,18 +142,6 @@ # $device_blacklist_re # Specifies pattern for device blacklisting. # String. Default: empty -# $ganglia_host -# Specifies host where gmetad is running -# String. Default: empty -# $ganglia_port -# Specifies port for $ganglia_host -# String. Default: empty -# $dogstreams -# Specifies port for list of logstreams/modules to be used. -# String. Default: empty -# $custom_emitters -# Specifies a comma seperated list of non standard emitters to be used -# String. Default: empty # $agent_log_file # Specifies the log file location (Agent 6 and 7 only). # String. Default: empty @@ -284,8 +267,8 @@ Boolean $collect_gce_tags = false, Boolean $collect_instance_metadata = true, Array $tags = [], - $integrations = {}, - $hiera_integrations = false, + Hash $integrations = {}, + Boolean $hiera_integrations = false, Boolean $hiera_tags = false, Array $facts_to_tags = [], Array $trusted_facts_to_tags = [], @@ -294,19 +277,18 @@ String $puppetmaster_user = $settings::user, String $puppet_gem_provider = $datadog_agent::params::gem_provider, Boolean $non_local_traffic = false, - Array $dogstreams = [], String $log_level = 'info', Boolean $log_to_syslog = true, - $service_ensure = 'running', - $service_enable = true, + String $service_ensure = 'running', + Variant[Boolean, Enum['manual', 'mask', 'delayed']] $service_enable = true, Boolean $manage_repo = true, Boolean $manage_dogapi_gem = true, Boolean $manage_install = true, Optional[Boolean] $datadog_installer_enabled = undef, - $hostname_extraction_regex = undef, + Optional[String] $hostname_extraction_regex = undef, Boolean $hostname_fqdn = false, Variant[Stdlib::Port, Pattern[/^\d*$/]] $dogstatsd_port = 8125, - $dogstatsd_socket = '', + String $dogstatsd_socket = '', Array $report_fact_tags = [], Array $report_trusted_fact_tags = [], String $statsd_forward_host = '', @@ -318,11 +300,8 @@ Optional[String] $proxy_password = undef, Variant[Stdlib::Port, Pattern[/^\d*$/]] $graphite_listen_port = '', String $extra_template = '', - String $ganglia_host = '', - $ganglia_port = 8651, Boolean $skip_ssl_validation = false, Boolean $skip_apt_key_trusting = false, - Boolean $use_curl_http_client = false, String $recent_point_threshold = '', Variant[Stdlib::Port, Pattern[/^\d*$/]] $listen_port = '', Optional[String] $additional_checksd = undef, @@ -336,7 +315,6 @@ String $dogstatsd_interval = '', Boolean $dogstatsd_normalize = true, String $device_blacklist_re = '', - String $custom_emitters = '', String $agent_log_file = $datadog_agent::params::agent_log_file, String $collector_log_file = '', String $forwarder_log_file = '', @@ -355,8 +333,8 @@ Optional[Integer] $agent_major_version = undef, Optional[String] $conf_dir = undef, Boolean $conf_dir_purge = $datadog_agent::params::conf_dir_purge, - $dd_group = $datadog_agent::params::dd_group, - $dd_groups = $datadog_agent::params::dd_groups, + String $dd_group = $datadog_agent::params::dd_group, + Any $dd_groups = $datadog_agent::params::dd_groups, Boolean $apm_enabled = $datadog_agent::params::apm_default_enabled, String $apm_env = 'none', Boolean $apm_non_local_traffic = false, @@ -368,7 +346,7 @@ Boolean $scrub_args = $datadog_agent::params::process_default_scrub_args, Array $custom_sensitive_words = $datadog_agent::params::process_default_custom_words, Boolean $logs_enabled = $datadog_agent::params::logs_enabled, - $logs_open_files_limit = $datadog_agent::params::logs_open_files_limit, + Optional[Integer] $logs_open_files_limit = $datadog_agent::params::logs_open_files_limit, Boolean $container_collect_all = $datadog_agent::params::container_collect_all, Hash[String[1], Data] $agent_extra_options = {}, Optional[String] $agent_repo_uri = undef, @@ -391,7 +369,6 @@ Optional[Enum['host', 'docker', 'all']] $apm_instrumentation_enabled = undef, Optional[Array[String]] $apm_instrumentation_libraries = undef, ) inherits datadog_agent::params { - #In this regex, version '1:6.15.0~rc.1-1' would match as $1='1:', $2='6', $3='15', $4='0', $5='~rc.1', $6='1' if $agent_version != 'latest' and $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)((?:~|-)[^0-9\s-]+[^-\s]*)?(?:-([0-9]+))?/ { $_agent_major_version = 0 + $2 # Cast to integer @@ -404,6 +381,8 @@ $_agent_major_version = $agent_major_version } else { $_agent_major_version = $datadog_agent::params::default_agent_major_version + $_agent_minor_version = 0 + $_agent_patch_version = 0 } case $facts['os']['name'] { @@ -420,8 +399,8 @@ default: { $agent_full_version = $agent_version } } - if $_agent_major_version != 5 and $_agent_major_version != 6 and $_agent_major_version != 7 { - fail("agent_major_version must be either 5, 6 or 7, not ${_agent_major_version}") + if $_agent_major_version != 6 and $_agent_major_version != 7 { + fail("agent_major_version must be either 6 or 7, not ${_agent_major_version}") } if ($facts['os']['name'] == 'Windows' and $windows_ddagentuser_name != undef) { @@ -431,23 +410,19 @@ } if $conf_dir == undef { - if $_agent_major_version == 5 { - $_conf_dir = $datadog_agent::params::legacy_conf_dir - } else { - $_conf_dir = $datadog_agent::params::conf_dir - } + $_conf_dir = $datadog_agent::params::conf_dir } else { $_conf_dir = $conf_dir } if $hiera_tags { - $local_tags = lookup({ 'name' => 'datadog_agent::tags', 'merge' => 'unique', 'default_value' => []}) + $local_tags = lookup({ 'name' => 'datadog_agent::tags', 'merge' => 'unique', 'default_value' => [] }) } else { $local_tags = $tags } if $hiera_integrations { - $local_integrations = lookup({ 'name' => 'datadog_agent::integrations', 'default_value' => {}}) + $local_integrations = lookup({ 'name' => 'datadog_agent::integrations', 'default_value' => {} }) } else { $local_integrations = $integrations } @@ -655,316 +630,199 @@ } } - if $_agent_major_version == 5 { - - if ($facts['os']['name'] == 'Windows') { - fail('Installation of agent 5 with puppet is not supported on Windows') - } - - if !empty($agent_extra_options) { - notify { 'Setting agent_extra_options has no effect with Agent 5': } - } - - file { '/etc/dd-agent': - ensure => directory, - owner => $dd_user, - group => $dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$agent_flavor], - } - - file { $_conf_dir: - ensure => directory, - purge => $conf_dir_purge, - recurse => true, - force => $conf_dir_purge, - owner => $dd_user, - group => $dd_group, - notify => Service[$datadog_agent::params::service_name] - } - - concat {'/etc/dd-agent/datadog.conf': - owner => $dd_user, - group => $dd_group, - mode => '0640', - notify => Service[$datadog_agent::params::service_name], - require => File['/etc/dd-agent'], - } - - if $dd_url.empty { - $_dd_url = 'https://app.datadoghq.com' - } else { - $_dd_url = $dd_url - } - concat::fragment{ 'datadog header': - target => '/etc/dd-agent/datadog.conf', - content => template('datadog_agent/datadog_header.conf.erb'), - order => '01', - } - - concat::fragment{ 'datadog tags': - target => '/etc/dd-agent/datadog.conf', - content => 'tags: ', - order => '02', - } - - datadog_agent::tag5{$local_tags: } - datadog_agent::tag5{$facts_to_tags: - lookup_fact => true, + # lint:ignore:quoted_booleans + $process_enabled_str = $process_enabled ? { true => 'true' , default => 'disabled' } + # lint:endignore + $base_extra_config = { + 'apm_config' => { + 'enabled' => $apm_enabled, + 'env' => $apm_env, + 'apm_non_local_traffic' => $apm_non_local_traffic, + }, + 'process_config' => { + 'enabled' => $process_enabled_str, + 'scrub_args' => $scrub_args, + 'custom_sensitive_words' => $custom_sensitive_words, + }, + 'logs_enabled' => $logs_enabled, + } + if $logs_open_files_limit { + $logs_base_config = { + 'logs_config' => { + 'container_collect_all' => $container_collect_all, + 'open_files_limit' => $logs_open_files_limit, + }, } - - concat::fragment{ 'datadog footer': - target => '/etc/dd-agent/datadog.conf', - content => template('datadog_agent/datadog_footer.conf.erb'), - order => '05', + } else { + $logs_base_config = { + 'logs_config' => { + 'container_collect_all' => $container_collect_all, + }, } - - unless $extra_template.empty { - concat::fragment{ 'datadog extra_template footer': - target => '/etc/dd-agent/datadog.conf', - content => template($extra_template), - order => '06', - } + } + if $host.empty { + $host_config = {} + } else { + $host_config = { + 'hostname' => $host, } + } - if ($apm_enabled == true) and (($apm_env != 'none') or $apm_analyzed_spans or $apm_obfuscation) { - concat::fragment{ 'datadog apm footer': - target => '/etc/dd-agent/datadog.conf', - content => template('datadog_agent/datadog_apm_footer.conf.erb'), - order => '07', - } + if $apm_analyzed_spans { + $apm_analyzed_span_config = { + 'apm_config' => { + 'analyzed_spans' => $apm_analyzed_spans, + }, } + } else { + $apm_analyzed_span_config = {} + } - if ($process_enabled == true) { - concat::fragment{ 'datadog process agent footer': - target => '/etc/dd-agent/datadog.conf', - content => template('datadog_agent/datadog_process_footer.conf.erb'), - order => '08', - } + if $apm_obfuscation { + $apm_obfuscation_config = { + 'apm_config' => { + 'obfuscation' => $apm_obfuscation, + }, } + } else { + $apm_obfuscation_config = {} + } - file {'/etc/dd-agent/install_info': - owner => $dd_user, - group => $dd_group, - mode => '0640', - content => template('datadog_agent/install_info.erb'), - require => File['/etc/dd-agent'], + if $apm_filter_tags { + $apm_filter_tags_config = { + 'apm_config' => { + 'filter_tags' => $apm_filter_tags, + }, } + } else { + $apm_filter_tags_config = {} + } - } else { #Agent 6/7 - - # notify of broken params on agent6/7 - if !empty($proxy_host) { - notify { 'Setting proxy_host is only used with Agent 5. Please use agent_extra_options to set your proxy': } - } - if !empty($proxy_port) { - notify { 'Setting proxy_port is only used with Agent 5. Please use agent_extra_options to set your proxy': } - } - if !empty($proxy_user) { - notify { 'Setting proxy_user is only used with Agent 5. Please use agent_extra_options to set your proxy': } - } - if !empty($proxy_password) { - notify { 'Setting proxy_password is only used with Agent 5. Please use agent_extra_options to set your proxy': } + if $apm_filter_tags_regex { + $apm_filter_tags_regex_config = { + 'apm_config' => { + 'filter_tags_regex' => $apm_filter_tags_regex, + }, } + } else { + $apm_filter_tags_regex_config = {} + } - # lint:ignore:quoted_booleans - $process_enabled_str = $process_enabled ? { true => 'true' , default => 'disabled' } - # lint:endignore - $base_extra_config = { - 'apm_config' => { - 'enabled' => $apm_enabled, - 'env' => $apm_env, - 'apm_non_local_traffic' => $apm_non_local_traffic - }, - 'process_config' => { - 'enabled' => $process_enabled_str, - 'scrub_args' => $scrub_args, - 'custom_sensitive_words' => $custom_sensitive_words, - }, - 'logs_enabled' => $logs_enabled, - } - if $logs_open_files_limit { - $logs_base_config = { - 'logs_config' => { - 'container_collect_all' => $container_collect_all, - 'open_files_limit' => $logs_open_files_limit - }, + if $statsd_forward_host.empty { + $statsd_forward_config = {} + } else { + if String($statsd_forward_port).empty { + $statsd_forward_config = { + 'statsd_forward_host' => $statsd_forward_host, } } else { - $logs_base_config = { - 'logs_config' => { - 'container_collect_all' => $container_collect_all, - }, + $statsd_forward_config = { + 'statsd_forward_host' => $statsd_forward_host, + 'statsd_forward_port' => $statsd_forward_port, } } - if $host.empty { - $host_config = {} - } else { - $host_config = { - 'hostname' => $host, - } - } + } - if $apm_analyzed_spans { - $apm_analyzed_span_config = { - 'apm_config' => { - 'analyzed_spans' => $apm_analyzed_spans - } - } - } else { - $apm_analyzed_span_config = {} + if $additional_checksd { + $additional_checksd_config = { + 'additional_checksd' => $additional_checksd, } + } else { + $additional_checksd_config = {} + } - if $apm_obfuscation { - $apm_obfuscation_config = { - 'apm_config' => { - 'obfuscation' => $apm_obfuscation - } - } - } else { - $apm_obfuscation_config = {} - } + $extra_config = deep_merge( + $base_extra_config, + $logs_base_config, + $agent_extra_options, + $apm_analyzed_span_config, + $apm_obfuscation_config, + $apm_filter_tags_config, + $apm_filter_tags_regex_config, + $statsd_forward_config, + $host_config, + $additional_checksd_config + ) + + file { $_conf_dir: + ensure => directory, + purge => $conf_dir_purge, + recurse => true, + force => $conf_dir_purge, + owner => $dd_user, + group => $dd_group, + } - if $apm_filter_tags { - $apm_filter_tags_config = { - 'apm_config' => { - 'filter_tags' => $apm_filter_tags - } - } - } else { - $apm_filter_tags_config = {} - } + if ! $_agent_managed_by_installer { + File[$_conf_dir] ~> Service[$datadog_agent::params::service_name] + } - if $apm_filter_tags_regex { - $apm_filter_tags_regex_config = { - 'apm_config' => { - 'filter_tags_regex' => $apm_filter_tags_regex - } - } - } else { - $apm_filter_tags_regex_config = {} - } + $_local_tags = datadog_agent::tag6($local_tags, false, undef) + $_facts_tags = datadog_agent::tag6($facts_to_tags, true, $facts) + $_trusted_facts_tags = datadog_agent::tag6($trusted_facts_to_tags, true, $trusted) + + $_agent_config = { + 'api_key' => $api_key, + 'dd_url' => $dd_url, + 'site' => $datadog_site, + 'cmd_port' => $cmd_port, + 'hostname_fqdn' => $hostname_fqdn, + 'collect_ec2_tags' => $collect_ec2_tags, + 'collect_gce_tags' => $collect_gce_tags, + 'confd_path' => $_conf_dir, + 'enable_metadata_collection' => $collect_instance_metadata, + 'dogstatsd_port' => $dogstatsd_port, + 'dogstatsd_socket' => $dogstatsd_socket, + 'dogstatsd_non_local_traffic' => $non_local_traffic, + 'log_file' => $agent_log_file, + 'log_level' => $log_level, + 'remote_updates' => $remote_updates, + 'remote_policies' => $remote_policies, + 'tags' => unique(flatten(union($_local_tags, $_facts_tags, $_trusted_facts_tags))), + } - if $statsd_forward_host.empty { - $statsd_forward_config = {} - } else { - if String($statsd_forward_port).empty { - $statsd_forward_config = { - 'statsd_forward_host' => $statsd_forward_host, - } - } else { - $statsd_forward_config = { - 'statsd_forward_host' => $statsd_forward_host, - 'statsd_forward_port' => $statsd_forward_port, - } - } + $agent_config = deep_merge($_agent_config, $extra_config) + + if ($facts['os']['name'] == 'Windows') { + file { 'C:/ProgramData/Datadog': + ensure => directory, } - if $additional_checksd { - $additional_checksd_config = { - 'additional_checksd' => $additional_checksd, - } - } else { - $additional_checksd_config = {} + file { 'C:/ProgramData/Datadog/datadog.yaml': + owner => $dd_user, + group => $dd_group, + mode => '0660', + content => template('datadog_agent/datadog.yaml.erb'), + show_diff => false, + notify => Service[$datadog_agent::params::service_name], + require => File['C:/ProgramData/Datadog'], } - $extra_config = deep_merge( - $base_extra_config, - $logs_base_config, - $agent_extra_options, - $apm_analyzed_span_config, - $apm_obfuscation_config, - $apm_filter_tags_config, - $apm_filter_tags_regex_config, - $statsd_forward_config, - $host_config, - $additional_checksd_config) - - file { $_conf_dir: - ensure => directory, - purge => $conf_dir_purge, - recurse => true, - force => $conf_dir_purge, + file { 'C:/ProgramData/Datadog/install_info': owner => $dd_user, group => $dd_group, + mode => '0660', + content => template('datadog_agent/install_info.erb'), + require => File['C:/ProgramData/Datadog'], } - - if ! $_agent_managed_by_installer { - File[$_conf_dir] ~> Service[$datadog_agent::params::service_name] - } - - $_local_tags = datadog_agent::tag6($local_tags, false, undef) - $_facts_tags = datadog_agent::tag6($facts_to_tags, true, $facts) - $_trusted_facts_tags = datadog_agent::tag6($trusted_facts_to_tags, true, $trusted) - - $_agent_config = { - 'api_key' => $api_key, - 'dd_url' => $dd_url, - 'site' => $datadog_site, - 'cmd_port' => $cmd_port, - 'hostname_fqdn' => $hostname_fqdn, - 'collect_ec2_tags' => $collect_ec2_tags, - 'collect_gce_tags' => $collect_gce_tags, - 'confd_path' => $_conf_dir, - 'enable_metadata_collection' => $collect_instance_metadata, - 'dogstatsd_port' => $dogstatsd_port, - 'dogstatsd_socket' => $dogstatsd_socket, - 'dogstatsd_non_local_traffic' => $non_local_traffic, - 'log_file' => $agent_log_file, - 'log_level' => $log_level, - 'remote_updates' => $remote_updates, - 'remote_policies' => $remote_policies, - 'tags' => unique(flatten(union($_local_tags, $_facts_tags, $_trusted_facts_tags))), + } else { + file { '/etc/datadog-agent/datadog.yaml': + owner => $dd_user, + group => $dd_group, + mode => '0640', + content => template('datadog_agent/datadog.yaml.erb'), + show_diff => false, + notify => Service[$datadog_agent::params::service_name], + require => File['/etc/datadog-agent'], } - $agent_config = deep_merge($_agent_config, $extra_config) - - if ($facts['os']['name'] == 'Windows') { - - - file { 'C:/ProgramData/Datadog': - ensure => directory - } - - file { 'C:/ProgramData/Datadog/datadog.yaml': - owner => $dd_user, - group => $dd_group, - mode => '0660', - content => template('datadog_agent/datadog.yaml.erb'), - show_diff => false, - notify => Service[$datadog_agent::params::service_name], - require => File['C:/ProgramData/Datadog'], - } - - file { 'C:/ProgramData/Datadog/install_info': - owner => $dd_user, - group => $dd_group, - mode => '0660', - content => template('datadog_agent/install_info.erb'), - require => File['C:/ProgramData/Datadog'], - } - - } else { - - file { '/etc/datadog-agent/datadog.yaml': - owner => $dd_user, - group => $dd_group, - mode => '0640', - content => template('datadog_agent/datadog.yaml.erb'), - show_diff => false, - notify => Service[$datadog_agent::params::service_name], - require => File['/etc/datadog-agent'], - } - - file { '/etc/datadog-agent/install_info': - owner => $dd_user, - group => $dd_group, - mode => '0640', - content => template('datadog_agent/install_info.erb'), - require => File['/etc/datadog-agent'], - } + file { '/etc/datadog-agent/install_info': + owner => $dd_user, + group => $dd_group, + mode => '0640', + content => template('datadog_agent/install_info.erb'), + require => File['/etc/datadog-agent'], } - } if $puppet_run_reports { @@ -993,5 +851,4 @@ } create_resources('datadog_agent::integration', $local_integrations) - } diff --git a/manifests/install_integration.pp b/manifests/install_integration.pp index ab661f104..c6b8113aa 100644 --- a/manifests/install_integration.pp +++ b/manifests/install_integration.pp @@ -1,14 +1,15 @@ +# Define: datadog_agent::install_integration +# +# Installs the integration with the given name and version. define datadog_agent::install_integration ( Enum['present', 'absent'] $ensure = 'present', - String $integration_name = undef, - String $version = undef, + Optional[String] $integration_name = undef, + Optional[String] $version = undef, Boolean $third_party = false, -){ - - require ::datadog_agent +) { + require datadog_agent if $ensure == 'present' { - if $third_party { $install_cmd = 'install --third-party' } else { @@ -31,5 +32,4 @@ notify => Service[$datadog_agent::params::service_name], } } - } diff --git a/manifests/integration.pp b/manifests/integration.pp index 7824c94ca..97afa0c53 100644 --- a/manifests/integration.pp +++ b/manifests/integration.pp @@ -1,3 +1,7 @@ +# Define: datadog_agent::integration +# +# Definition for an agent integration +# define datadog_agent::integration ( Array $instances = [], Optional[Hash] $init_config = undef, @@ -5,29 +9,24 @@ String $integration = $title, String $conf_file = 'conf', Enum['present', 'absent'] $ensure = 'present', -){ - +) { # We can't `require ::datadog_agent` from here since this class is used by the # datadog_agent class, causing a dependency cycle. If using this class # directly, you should define datadog_agent before datadog_agent::integration. - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/${integration}.d" - $dst = "${dst_dir}/${$conf_file}.yaml" - if (! defined(File[$dst_dir])) { - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::dd_group, - mode => $datadog_agent::params::permissions_directory, - before => File[$dst] - } + $dst_dir = "${datadog_agent::params::conf_dir}/${integration}.d" + $dst = "${dst_dir}/${$conf_file}.yaml" + if (! defined(File[$dst_dir])) { + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::dd_group, + mode => $datadog_agent::params::permissions_directory, + before => File[$dst], } - } else { - $dst = "${datadog_agent::params::legacy_conf_dir}/${integration}.yaml" } - $file_ensure = $ensure ? { default => file, 'absent' => absent } + $file_ensure = $ensure ? { default => 'file', 'absent' => absent } file { $dst: ensure => $file_ensure, @@ -35,7 +34,6 @@ group => $datadog_agent::dd_group, mode => $datadog_agent::params::permissions_file, content => to_instances_yaml($init_config, $instances, $logs), - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/activemq_xml.pp b/manifests/integrations/activemq_xml.pp index ac1ecbb1e..2b8bb7f8f 100644 --- a/manifests/integrations/activemq_xml.pp +++ b/manifests/integrations/activemq_xml.pp @@ -1,6 +1,15 @@ # Class: datadog_agent::integrations::activemq_xml # -# This class will install the necessary configuration for the activemq_xml integration +# This class will install the necessary configuration for the activemq_xml integration. +# +# See the sample activemq.d/conf.yaml for all available configuration options. +# https://github.com/DataDog/integrations-core/blob/master/activemq/datadog_checks/activemq/data/conf.yaml.example +# +# See the metrics.yaml file for the list of default collected metrics. +# https://github.com/DataDog/integrations-core/blob/master/activemq/datadog_checks/activemq/data/metrics.yaml +# +# This check has a limit of 350 metrics per instance. If you require +# additional metrics, contact Datadog Support at https://docs.datadoghq.com/help/ # # Parameters: # $url @@ -9,7 +18,7 @@ # Username to use for authentication - optional # $password # Password to use for authentication - optional -# $supress_errors +# $suppress_errors # Supress connection errors if URL is expected to be offline at times (eg. standby host) - optional # $detailed_queues # List of queues to monitor, required if you have more than 300 queues you wish to track, otherwise optional. @@ -24,7 +33,7 @@ # url => 'http://localhost:8161', # username => 'datadog', # password => 'some_pass', -# supress_errors => false, +# suppress_errors => false, # detailed_queues => ['queue1', 'queue2', 'queue3'], # detailed_topics => ['topic1', 'topic2', 'topic3'], # detailed_subscribers => ['subscriber1', 'subscriber2', 'subscriber3'], @@ -36,55 +45,48 @@ # - url: 'http://localhost:8161' # username: 'datadog' # password: 'some_pass' -# supress_errors: false +# suppress_errors: false # detailed_queues: ['queue1', 'queue2', 'queue3'] # detailed_topics: ['topic1', 'topic2', 'topic3'] # detailed_subscribers: ['subscriber1', 'subscriber2', 'subscriber3'] # # -class datadog_agent::integrations::activemq_xml( - String $url = 'http://localhost:8161', - Boolean $supress_errors = false, - Optional[String] $username = undef, - Optional[String] $password = undef, - Optional[Array[String]] $detailed_queues = [], - Optional[Array[String]] $detailed_topics = [], - Optional[Array[String]] $detailed_subscribers = [], - Optional[Array] $instances = undef, +class datadog_agent::integrations::activemq_xml ( + String $url = 'http://localhost:8161', + Boolean $supress_errors = false, # keep for backwards-compatibility + Boolean $suppress_errors = $supress_errors, + Optional[String] $username = undef, + Optional[String] $password = undef, + Array[String] $detailed_queues = [], + Array[String] $detailed_topics = [], + Array[String] $detailed_subscribers = [], + Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/activemq_xml.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/activemq_xml.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/activemq_xml.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" if !$instances and $url { $_instances = [{ - 'url' => $url, - 'username' => $username, - 'password' => $password, - 'supress_errors' => $supress_errors, - 'detailed_queues' => $detailed_queues, - 'detailed_topics' => $detailed_topics, - 'detailed_subscribers' => $detailed_subscribers, + 'url' => $url, + 'username' => $username, + 'password' => $password, + 'suppress_errors' => $suppress_errors, + 'detailed_queues' => $detailed_queues, + 'detailed_topics' => $detailed_topics, + 'detailed_subscribers' => $detailed_subscribers, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances diff --git a/manifests/integrations/apache.pp b/manifests/integrations/apache.pp index b6de7fc11..8dd48f8d2 100644 --- a/manifests/integrations/apache.pp +++ b/manifests/integrations/apache.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the apache integration # +# See the sample apache.d/conf.yaml for all available configuration options. +# https://github.com/DataDog/integrations-core/blob/master/apache/datadog_checks/apache/data/conf.yaml.example +# # Parameters: # $url: # The URL for apache status URL handled by mod-status. @@ -33,27 +36,19 @@ Array $tags = [], Boolean $disable_ssl_validation = false ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/apache.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/apache.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/apache.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -62,6 +57,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/apache.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/cacti.pp b/manifests/integrations/cacti.pp index 2f1ee0d41..1a6f20308 100644 --- a/manifests/integrations/cacti.pp +++ b/manifests/integrations/cacti.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the cacti integration # +# See the sample cacti.d/conf.yaml for all available configuration options. +# https://github.com/DataDog/integrations-core/blob/master/cacti/datadog_checks/cacti/data/conf.yaml.example +# # Parameters: # $host: # The host cacti MySQL db is running on @@ -12,33 +15,25 @@ # $path # The path to the cacti rrd directory e.g. /var/lib/cacti/rra/ # -class datadog_agent::integrations::cacti( - $mysql_host = 'localhost', - $mysql_user = 'cacti', - $mysql_password = undef, - $rrd_path = '/var/lib/cacti/rra/', +class datadog_agent::integrations::cacti ( + String $mysql_host = 'localhost', + String $mysql_user = 'cacti', + Optional[Any] $mysql_password = undef, + String $rrd_path = '/var/lib/cacti/rra/', ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/cacti.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/cacti.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/cacti.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -47,6 +42,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/cacti.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/cassandra.pp b/manifests/integrations/cassandra.pp index 8f5e17a4c..7a6ad9d6d 100644 --- a/manifests/integrations/cassandra.pp +++ b/manifests/integrations/cassandra.pp @@ -3,6 +3,12 @@ # This class will install the necessary configuration for the Cassandra # integration. # +# See the sample cassandra.d/conf.yaml for all available configuration options. +# https://github.com/DataDog/integrations-core/blob/master/cassandra/datadog_checks/cassandra/data/conf.yaml.example +# +# See the metrics.yaml file for the list of default collected metrics. +# https://github.com/DataDog/integrations-core/blob/master/cassandra/datadog_checks/cassandra/data/metrics.yaml +# # This check has a limit of 350 metrics per instance. If you require # additional metrics, contact Datadog Support at https://docs.datadoghq.com/help/ # @@ -28,35 +34,27 @@ # } # # -class datadog_agent::integrations::cassandra( +class datadog_agent::integrations::cassandra ( String $host = 'localhost', Integer $port = 7199, Optional[String] $user = undef, Optional[String] $password = undef, - Optional[Hash] $tags = {}, + Hash $tags = {}, Optional[Integer] $max_returned_metrics = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/cassandra.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/cassandra.d" + $dst_dir = "${datadog_agent::params::conf_dir}/cassandra.d" - file { $legacy_dst: - ensure => 'absent' - } - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, diff --git a/manifests/integrations/ceph.pp b/manifests/integrations/ceph.pp index 174c8ba35..afe30bfc6 100644 --- a/manifests/integrations/ceph.pp +++ b/manifests/integrations/ceph.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the ceph integration # +# See the sample ceph.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/ceph/datadog_checks/ceph/data/conf.yaml.example +# # Parameters: # $tags # Optional array of tags @@ -13,35 +16,27 @@ # class { 'datadog_agent::integrations::ceph' : # } # -class datadog_agent::integrations::ceph( - Array $tags = [ 'name:ceph_cluster' ], +class datadog_agent::integrations::ceph ( + Array $tags = ['name:ceph_cluster'], String $ceph_cmd = '/usr/bin/ceph', ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent file { '/etc/sudoers.d/datadog_ceph': - content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n" + content => "# This file is required for dd ceph \ndd-agent ALL=(ALL) NOPASSWD:/usr/bin/ceph\n", } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ceph.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/ceph.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/ceph.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -50,6 +45,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/ceph.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/consul.pp b/manifests/integrations/consul.pp index d999d0e87..bd12020a7 100644 --- a/manifests/integrations/consul.pp +++ b/manifests/integrations/consul.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the consul integration # +# See the sample consul.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/consul/datadog_checks/consul/data/conf.yaml.example +# # Parameters: # $url: # The URL for consul @@ -26,34 +29,26 @@ # new_leader_checks => false, # } # -class datadog_agent::integrations::consul( +class datadog_agent::integrations::consul ( String $url = 'http://localhost:8500', Boolean $catalog_checks = true, Boolean $network_latency_checks = true, Boolean $new_leader_checks = true, - Optional[Array] $service_whitelist = [] + Array $service_whitelist = [] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/consul.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/consul.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/consul.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -62,6 +57,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/consul.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/directory.pp b/manifests/integrations/directory.pp index ca1b20cff..f240614e4 100644 --- a/manifests/integrations/directory.pp +++ b/manifests/integrations/directory.pp @@ -2,6 +2,9 @@ # # This class will install the necessary config to hook the directory in the agent # +# See the sample directory.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/directory/datadog_checks/directory/data/conf.yaml.example +# # Parameters: # directory # (Required) - string, the directory path to monitor @@ -53,7 +56,6 @@ # }, # ] # } - class datadog_agent::integrations::directory ( String $directory = '', Boolean $filegauges = false, @@ -65,7 +67,7 @@ String $pattern = '', Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $directory == '' { fail('bad directory argument and no instances hash provided') @@ -73,40 +75,32 @@ if !$instances and $directory { $_instances = [{ - 'directory' => $directory, - 'filegauges' => $filegauges, - 'recursive' => $recursive, - 'countonly' => $countonly, - 'name' => $nametag, - 'dirtagname' => $dirtagname, - 'filetagname' => $filetagname, - 'pattern' => $pattern, + 'directory' => $directory, + 'filegauges' => $filegauges, + 'recursive' => $recursive, + 'countonly' => $countonly, + 'name' => $nametag, + 'dirtagname' => $dirtagname, + 'filetagname' => $filetagname, + 'pattern' => $pattern, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/directory.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/directory.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/directory.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -115,6 +109,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/directory.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/disk.pp b/manifests/integrations/disk.pp index 305657393..ff39b8206 100644 --- a/manifests/integrations/disk.pp +++ b/manifests/integrations/disk.pp @@ -2,6 +2,9 @@ # # This class will install the necessary config to hook the disk check # +# See the sample disk.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/disk/datadog_checks/disk/data/conf.yaml.default +# # Parameters: # $use_mount # The use_mount parameter will instruct the check to collect disk @@ -51,7 +54,6 @@ # Regular expression (optional) to exclude disks, eg: /dev/sde.* # $excluded_mountpoint_re (DEPRECATED in agent version>6.9, use $mountpoint_exclude instead) # Regular expression (optional) to exclude , eg: /mnt/somebody-elses-problem.* - # # Sample Usage: # @@ -61,9 +63,9 @@ # excluded_disk_re => '/dev/sd[e-z]*' # } class datadog_agent::integrations::disk ( - String $use_mount = 'no', - $all_partitions = undef, - $tag_by_filesystem = undef, + Optional[Boolean] $use_mount = undef, + Optional[Boolean] $all_partitions = undef, + Optional[Boolean] $tag_by_filesystem = undef, Optional[Array[String]] $filesystem_exclude = undef, Optional[Array[String]] $device_exclude = undef, Optional[Array[String]] $mountpoint_exclude = undef, @@ -81,33 +83,19 @@ Optional[String] $excluded_disk_re = undef, # deprecated in agent versions >6.9 Optional[String] $excluded_mountpoint_re = undef, # deprecated in agent versions >6.9 ) inherits datadog_agent::params { - require ::datadog_agent - - validate_legacy('Optional[String]', 'validate_re', $all_partitions, '^(no|yes)$') - - if $use_mount !~ '^(no|yes)$' { - fail('error during compilation') - } + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/disk.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/disk.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/disk.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -116,6 +104,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/disk.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/dns_check.pp b/manifests/integrations/dns_check.pp index 6b6bc7dea..3ee9f7a33 100644 --- a/manifests/integrations/dns_check.pp +++ b/manifests/integrations/dns_check.pp @@ -3,6 +3,9 @@ # This class will install the necessary configuration for the DNS check # integration. # +# See the sample dns_check.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/dns_check/datadog_checks/dns_check/data/conf.yaml.example +# # Parameters: # $hostname: # Domain or IP you wish to check the availability of. @@ -30,30 +33,22 @@ 'hostname' => 'google.com', 'nameserver' => '8.8.8.8', 'timeout' => 5, - } + }, ] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/dns_check.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/dns_check.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/dns_check.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, diff --git a/manifests/integrations/docker_daemon.pp b/manifests/integrations/docker_daemon.pp index 3852b3191..6de9affaa 100644 --- a/manifests/integrations/docker_daemon.pp +++ b/manifests/integrations/docker_daemon.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the docker integration # +# See the sample docker_daemon.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/docker_daemon/datadog_checks/docker_daemon/data/conf.yaml.example +# # Parameters: # $url: # The URL for docker API @@ -19,86 +22,62 @@ # url => 'unix://var/run/docker.sock', # } # -class datadog_agent::integrations::docker_daemon( - $group = 'docker', - $docker_root = '/', - $timeout = 10, - $api_version = 'auto', - $tls = false, - $tls_client_cert = '/path/to/client-cert.pem', - $tls_client_key = '/path/to/client-key.pem', - $tls_cacert = '/path/to/ca.pem', - $tls_verify = true, - $init_retry_interval = 0, - $init_retries = 0, - $url = 'unix://var/run/docker.sock', - $collect_events = true, - $filtered_event_types = [], - $collect_container_size = false, - $custom_cgroups = false, - $health_service_check_whitelist = [], - $collect_container_count = false, - $collect_volume_count = false, - $collect_images_stats = false, - $collect_image_size = false, - $collect_disk_stats = false, - $collect_exit_codes = false, - $exclude = [], - $include = [], - $tags = [], - $ecs_tags = true, +class datadog_agent::integrations::docker_daemon ( + String $group = 'docker', + String $docker_root = '/', + Integer $timeout = 10, + String $api_version = 'auto', + Boolean $tls = false, + String $tls_client_cert = '/path/to/client-cert.pem', + String $tls_client_key = '/path/to/client-key.pem', + String$tls_cacert = '/path/to/ca.pem', + Boolean $tls_verify = true, + Integer $init_retry_interval = 0, + Integer $init_retries = 0, + String $url = 'unix://var/run/docker.sock', + Boolean $collect_events = true, + Array $filtered_event_types = [], + Boolean $collect_container_size = false, + Boolean $custom_cgroups = false, + Array $health_service_check_whitelist = [], + Boolean $collect_container_count = false, + Boolean $collect_volume_count = false, + Boolean $collect_images_stats = false, + Boolean $collect_image_size = false, + Boolean $collect_disk_stats = false, + Boolean $collect_exit_codes = false, + Array $exclude = [], + Array $include = [], + Array $tags = [], + Boolean $ecs_tags = true, # Possible values: "container_name", "image_name", "image_tag", "docker_image" - $performance_tags = [], + Array $performance_tags = [], # Possible values: "image_name", "image_tag", "docker_image" - $container_tags = [], + Array $container_tags = [], # Ex. "com.docker.compose.service", "com.docker.compose.project" - $collect_labels_as_tags = [], - $event_attributes_as_tags = [], + Array $collect_labels_as_tags = [], + Array $event_attributes_as_tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent exec { 'dd-agent-should-be-in-docker-group': command => "/usr/sbin/usermod -aG ${group} ${datadog_agent::dd_user}", unless => "/bin/cat /etc/group | grep '^${group}:' | grep -qw ${datadog_agent::dd_user}", require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - if $::datadog_agent::_agent_major_version > 5 { - $legacy_dir = "${datadog_agent::params::conf_dir}/docker_daemon.d" - - file { $legacy_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $legacy_conf = "${legacy_dir}/conf.yaml" - } else { - $legacy_conf = "${datadog_agent::params::legacy_conf_dir}/docker.yaml" - } - - file { $legacy_conf: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/docker.d" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/docker.d" - - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = "${datadog_agent::params::legacy_conf_dir}/docker_daemon.yaml" + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -107,6 +86,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/docker_daemon.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/elasticsearch.pp b/manifests/integrations/elasticsearch.pp index 05383f7b3..0d10cd202 100644 --- a/manifests/integrations/elasticsearch.pp +++ b/manifests/integrations/elasticsearch.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the elasticsearch integration # +# See the sample elastic.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/elastic/datadog_checks/elastic/data/conf.yaml.example +# # Parameters: # $url: # The URL for Elasticsearch @@ -23,41 +26,50 @@ # url => "http://localhost:9201" # } # -class datadog_agent::integrations::elasticsearch( - Boolean $cluster_stats = false, - Boolean $index_stats = false, - Optional[String] $password = undef, - Boolean$pending_task_stats = true, - Boolean $pshard_stats = false, - Optional[String] $ssl_cert = undef, - Optional[String] $ssl_key = undef, - Variant[Boolean, String] $ssl_verify = true, - Array $tags = [], - String $url = 'http://localhost:9200', - Optional[String] $username = undef, - Optional[Array] $instances = undef +class datadog_agent::integrations::elasticsearch ( + Boolean $cluster_stats = false, + Boolean $index_stats = false, + Optional[String] $password = undef, + Boolean$pending_task_stats = true, + Boolean $pshard_stats = false, + Optional[String] $ssl_cert = undef, + Optional[String] $ssl_key = undef, + Boolean $ssl_verify = true, # kept for backwards compatibility + Boolean $tls_verify = $ssl_verify, + Boolean $tls_use_host_header = false, + Boolean $tls_ignore_warning = false, + Optional[String] $tls_cert = undef, + Optional[String] $tls_private_key = undef, + Optional[String] $tls_ca_cert = undef, + Array $tls_protocols_allowed = [], + Array $tls_ciphers = [], + Array $tags = [], + String $url = 'http://localhost:9200', + Optional[String] $username = undef, + Optional[Array] $instances = undef ) inherits datadog_agent::params { - require ::datadog_agent - - # $ssl_verify can be a bool or a string - # https://github.com/DataDog/dd-agent/blob/master/checks.d/elastic.py#L454-L455 - if validate_legacy('Variant[Boolean, String]', 'is_string', $ssl_verify){ - validate_absolute_path($ssl_verify) - } + require datadog_agent if !$instances and $url { $_instances = [{ - 'cluster_stats' => $cluster_stats, - 'index_stats' => $index_stats, - 'password' => $password, - 'pending_task_stats' => $pending_task_stats, - 'pshard_stats' => $pshard_stats, - 'ssl_cert' => $ssl_cert, - 'ssl_key' => $ssl_key, - 'ssl_verify' => $ssl_verify, - 'tags' => $tags, - 'url' => $url, - 'username' => $username + 'cluster_stats' => $cluster_stats, + 'index_stats' => $index_stats, + 'password' => $password, + 'pending_task_stats' => $pending_task_stats, + 'pshard_stats' => $pshard_stats, + 'ssl_cert' => $ssl_cert, + 'ssl_key' => $ssl_key, + 'tls_verify' => $tls_verify, + 'tags' => $tags, + 'url' => $url, + 'username' => $username, + 'tls_use_host_header' => $tls_use_host_header, + 'tls_ignore_warning' => $tls_ignore_warning, + 'tls_cert' => $tls_cert, + 'tls_private_key' => $tls_private_key, + 'tls_ca_cert' => $tls_ca_cert, + 'tls_protocols_allowed' => $tls_protocols_allowed, + 'tls_ciphers' => $tls_ciphers, }] } elsif !$instances { $_instances = [] @@ -65,25 +77,17 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/elastic.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/elastic.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/elastic.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -92,6 +96,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/elastic.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/fluentd.pp b/manifests/integrations/fluentd.pp index bcbf3c21b..96e99c669 100644 --- a/manifests/integrations/fluentd.pp +++ b/manifests/integrations/fluentd.pp @@ -2,6 +2,9 @@ # # This class will install the fluentd integration # +# See the sample fluentd.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/fluentd/datadog_checks/fluentd/data/conf.yaml.example +# # Parameters: # $monitor_agent_url # The url fluentd lists it's plugins on @@ -17,31 +20,23 @@ # } # # -class datadog_agent::integrations::fluentd( - $monitor_agent_url = 'http://localhost:24220/api/plugins.json', - Optional[Array] $plugin_ids = [], +class datadog_agent::integrations::fluentd ( + String $monitor_agent_url = 'http://localhost:24220/api/plugins.json', + Array $plugin_ids = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/fluentd.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/fluentd.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/fluentd.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, diff --git a/manifests/integrations/generic.pp b/manifests/integrations/generic.pp index c5e23d190..265a0ea34 100644 --- a/manifests/integrations/generic.pp +++ b/manifests/integrations/generic.pp @@ -17,31 +17,23 @@ # integration_contents => template(my_custom_template), # } # -class datadog_agent::integrations::generic( +class datadog_agent::integrations::generic ( Optional[String] $integration_name = undef, Optional[String] $integration_contents = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/${integration_name}.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/${integration_name}.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/${integration_name}.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -50,6 +42,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => $integration_contents, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/haproxy.pp b/manifests/integrations/haproxy.pp index ee8728b27..d4a32fec6 100644 --- a/manifests/integrations/haproxy.pp +++ b/manifests/integrations/haproxy.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the haproxy integration # +# See the sample haproxy.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/haproxy/datadog_checks/haproxy/data/conf.yaml.example +# # Parameters: # $url: # The URL for haproxy @@ -16,19 +19,19 @@ # options => { collect_aggregates_only => 'False' }, # } # -class datadog_agent::integrations::haproxy( - $creds = {}, - $url = "http://${facts['networking']['ip']}:8080", - $options = {}, +class datadog_agent::integrations::haproxy ( + Hash $creds = {}, + String $url = "http://${facts['networking']['ip']}:8080", + Hash $options = {}, Optional[Array] $instances = undef ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $url { $_instances = [{ - 'creds' => $creds, - 'url' => $url, - 'options' => $options, + 'creds' => $creds, + 'url' => $url, + 'options' => $options, }] } elsif !$instances { $_instances = [] @@ -36,33 +39,25 @@ $_instances = $instances } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/haproxy.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/haproxy.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/haproxy.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: - ensure => file, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_file, - content => template('datadog_agent/agent-conf.d/haproxy.yaml.erb'), - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + ensure => file, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_file, + content => template('datadog_agent/agent-conf.d/haproxy.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/http_check.pp b/manifests/integrations/http_check.pp index a5964bb41..26ba2d948 100644 --- a/manifests/integrations/http_check.pp +++ b/manifests/integrations/http_check.pp @@ -2,12 +2,15 @@ # # This class will install the necessary config to hook the http_check in the agent # +# See the sample http_check.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/http_check/datadog_checks/http_check/data/conf.yaml.example +# # Parameters: # sitename -# (Required) The name of the instance. +# The name of the instance. # # url -# (Required) The url to check. +# The url to check. # # timeout # The (optional) timeout in seconds. @@ -98,7 +101,8 @@ # left in the certificate, and alternatively raise a critical # warning if the certificate is y days from the expiration date. # The SSL certificate will always be validated for this additional -# service check regardless of the value of disable_ssl_validation +# service check regardless of the value of disable_ssl_validation. +# check_certification_expiration defaults to true. # # headers # The (optional) headers parameter allows you to send extra headers with @@ -165,99 +169,89 @@ # 'tags' => ['production', 'wordpress'] # }] # } - - class datadog_agent::integrations::http_check ( - $sitename = undef, - $url = undef, - $username = undef, - $password = undef, - $timeout = 1, - $method = 'get', - $min_collection_interval = undef, - $data = undef, - $threshold = undef, - $window = undef, - $content_match = undef, - $reverse_content_match = false, - $include_content = false, - $http_response_status_code = undef, - $collect_response_time = true, - $disable_ssl_validation = false, - $ignore_ssl_warning = false, - $skip_event = true, - $no_proxy = false, - $check_certificate_expiration = true, - $days_warning = undef, - $days_critical = undef, + Optional[String] $sitename = undef, + Optional[String] $url = undef, + Optional[String] $username = undef, + Optional[Any] $password = undef, + Integer $timeout = 1, + String $method = 'get', + Integer $min_collection_interval = 15, + Optional[Any] $data = undef, + Optional[Integer] $threshold = undef, + Optional[Integer] $window = undef, + Optional[String] $content_match = undef, + Boolean $reverse_content_match = false, + Boolean $include_content = false, + Optional[String] $http_response_status_code = undef, + Boolean $collect_response_time = true, + Boolean $disable_ssl_validation = false, + Boolean $ignore_ssl_warning = false, + Boolean $skip_event = true, + Boolean $no_proxy = false, + Boolean $check_certificate_expiration = true, + Optional[Integer] $days_warning = undef, + Optional[Integer] $days_critical = undef, Optional[Boolean] $check_hostname = undef, Optional[String] $ssl_server_name = undef, - $headers = [], - $allow_redirects = true, - $tags = [], - $contact = [], + Array $headers = [], + Boolean $allow_redirects = true, + Array $tags = [], + Array $contact = [], Optional[Array] $instances = undef, - $ca_certs = undef, + Optional[String] $ca_certs = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $url { $_instances = [{ - 'sitename' => $sitename, - 'url' => $url, - 'username' => $username, - 'password' => $password, - 'timeout' => $timeout, - 'method' => $method, - 'min_collection_interval' => $min_collection_interval, - 'data' => $data, - 'threshold' => $threshold, - 'window' => $window, - 'content_match' => $content_match, - 'reverse_content_match' => $reverse_content_match, - 'include_content' => $include_content, - 'http_response_status_code' => $http_response_status_code, - 'collect_response_time' => $collect_response_time, - 'disable_ssl_validation' => $disable_ssl_validation, - 'ignore_ssl_warning' => $ignore_ssl_warning, - 'skip_event' => $skip_event, - 'no_proxy' => $no_proxy, - 'check_certificate_expiration' => $check_certificate_expiration, - 'days_warning' => $days_warning, - 'days_critical' => $days_critical, - 'check_hostname' => $check_hostname, - 'ssl_server_name' => $ssl_server_name, - 'headers' => $headers, - 'allow_redirects' => $allow_redirects, - 'tags' => $tags, - 'contact' => $contact, - 'ca_certs' => $ca_certs, + 'sitename' => $sitename, + 'url' => $url, + 'username' => $username, + 'password' => $password, + 'timeout' => $timeout, + 'method' => $method, + 'min_collection_interval' => $min_collection_interval, + 'data' => $data, + 'threshold' => $threshold, + 'window' => $window, + 'content_match' => $content_match, + 'reverse_content_match' => $reverse_content_match, + 'include_content' => $include_content, + 'http_response_status_code' => $http_response_status_code, + 'collect_response_time' => $collect_response_time, + 'disable_ssl_validation' => $disable_ssl_validation, + 'ignore_ssl_warning' => $ignore_ssl_warning, + 'skip_event' => $skip_event, + 'no_proxy' => $no_proxy, + 'check_certificate_expiration' => $check_certificate_expiration, + 'days_warning' => $days_warning, + 'days_critical' => $days_critical, + 'check_hostname' => $check_hostname, + 'ssl_server_name' => $ssl_server_name, + 'headers' => $headers, + 'allow_redirects' => $allow_redirects, + 'tags' => $tags, + 'contact' => $contact, + 'ca_certs' => $ca_certs, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/http_check.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/http_check.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/http_check.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -266,6 +260,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/http_check.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/jenkins.pp b/manifests/integrations/jenkins.pp deleted file mode 100644 index c3fe39bce..000000000 --- a/manifests/integrations/jenkins.pp +++ /dev/null @@ -1,50 +0,0 @@ -# Class: datadog_agent::integrations::jenkins -# -# This class will install the necessary configuration for the jenkins integration -# -# Parameters: -# $path: -# Jenkins path. Defaults to '/var/lib/jenkins' -# -# Sample Usage: -# -# class { 'datadog_agent::integrations::jenkins' : -# path => '/var/lib/jenkins', -# } -# -# -class datadog_agent::integrations::jenkins( - $path = '/var/lib/jenkins' -) inherits datadog_agent::params { - require ::datadog_agent - - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/jenkins.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/jenkins.d" - file { $legacy_dst: - ensure => 'absent' - } - - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst - } - - file { $dst: - ensure => file, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_protected_file, - content => template('datadog_agent/agent-conf.d/jenkins.yaml.erb'), - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } -} diff --git a/manifests/integrations/jmx.pp b/manifests/integrations/jmx.pp index e32f3ec93..2cfe4d505 100644 --- a/manifests/integrations/jmx.pp +++ b/manifests/integrations/jmx.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the jmx integration # +# See the sample jmx.d/conf.yaml for all available configuration options +# https://docs.datadoghq.com/integrations/java/?tab=host#overview +# # Parameters: # $init_config: # Hash of inital configuration, consisting of the following keys: @@ -61,31 +64,23 @@ # }], # } # -class datadog_agent::integrations::jmx( - $init_config = {}, - $instances = [], +class datadog_agent::integrations::jmx ( + Hash $init_config = {}, + Array $instances = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/jmx.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/jmx.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/jmx.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -94,7 +89,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/jmx.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/kafka.pp b/manifests/integrations/kafka.pp index 2f575e760..01e2105d1 100644 --- a/manifests/integrations/kafka.pp +++ b/manifests/integrations/kafka.pp @@ -2,6 +2,15 @@ # # This class will install the necessary configuration for the kafka integration # +# See the sample kafka.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/kafka/datadog_checks/kafka/data/conf.yaml.example +# +# # See the metrics.yaml file for the list of default collected metrics. +# https://github.com/DataDog/integrations-core/blob/master/kafka/datadog_checks/kafka/data/metrics.yaml +# +# This check has a limit of 350 metrics per instance. If you require +# additional metrics, contact Datadog Support at https://docs.datadoghq.com/help/ +# # Parameters: # $host: # The host kafka is running on. Defaults to 'localhost' @@ -52,59 +61,51 @@ # ] # } # -class datadog_agent::integrations::kafka( - $host = 'localhost', - Variant[String[1], Integer] $port = 9999, - Optional[String[1]] $username = undef, - Optional[String[1]] $password = undef, - Optional[String[1]] $process_name_regex = undef, - Optional[String[1]] $tools_jar_path = undef, - Optional[String[1]] $java_bin_path = undef, - Optional[String[1]] $trust_store_path = undef, - Optional[String[1]] $trust_store_password = undef, - Optional[Hash[String[1], String[1]]] $tags = undef, +class datadog_agent::integrations::kafka ( + String $host = 'localhost', + Variant[String[1], Integer] $port = 9999, + Optional[String[1]] $username = undef, + Optional[String[1]] $password = undef, + Optional[String[1]] $process_name_regex = undef, + Optional[String[1]] $tools_jar_path = undef, + Optional[String[1]] $java_bin_path = undef, + Optional[String[1]] $trust_store_path = undef, + Optional[String[1]] $trust_store_password = undef, + Optional[Hash[String[1], String[1]]] $tags = undef, Optional[Array[Hash[String[1], Data]]] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $host and $port { $servers = [{ - 'host' => $host, - 'port' => $port, - 'username' => $username, - 'password' => $password, - 'process_name_regex' => $process_name_regex, - 'tools_jar_path' => $tools_jar_path, - 'java_bin_path' => $java_bin_path, - 'trust_store_path' => $trust_store_path, - 'trust_store_password' => $trust_store_password, - 'tags' => $tags, + 'host' => $host, + 'port' => $port, + 'username' => $username, + 'password' => $password, + 'process_name_regex' => $process_name_regex, + 'tools_jar_path' => $tools_jar_path, + 'java_bin_path' => $java_bin_path, + 'trust_store_path' => $trust_store_path, + 'trust_store_password' => $trust_store_password, + 'tags' => $tags, }] - } elsif !$instances{ + } elsif !$instances { $servers = [] } else { $servers = $instances } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kafka.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/kafka.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/kafka.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, diff --git a/manifests/integrations/kong.pp b/manifests/integrations/kong.pp index 15a17d92c..13aaa4884 100644 --- a/manifests/integrations/kong.pp +++ b/manifests/integrations/kong.pp @@ -2,7 +2,10 @@ # # This class will install the necessary configuration for the Kong integration # -# Note: if you're Cassandra data-store is large in size the `/status` page may +# See the sample kong.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/kong/datadog_checks/kong/data/conf.yaml.example +# +# Note: if your Kong data-store is large in size the `/status` page may # take a long time to return. # # @@ -25,34 +28,26 @@ # } # class datadog_agent::integrations::kong ( - $instances = [ + Array $instances = [ { 'status_url' => 'http://localhost:8001/status/', - 'tags' => [] + 'tags' => [] } ] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kong.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/kong.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/kong.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -61,6 +56,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/kong.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/kubernetes.pp b/manifests/integrations/kubernetes.pp index b984191c4..8d04767cb 100644 --- a/manifests/integrations/kubernetes.pp +++ b/manifests/integrations/kubernetes.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the kubernetes integration # +# See the sample kubernetes.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/kubernetes/datadog_checks/kubernetes/data/conf.yaml.example +# # Parameters: # $url: # The URL for kubernetes API @@ -21,36 +24,28 @@ # kubelet_client_key => '/etc/ssl/private/key', # } # -class datadog_agent::integrations::kubernetes( - $api_server_url = 'Enter_Your_API_url', - $apiserver_client_crt = '/path/to/crt', - $apiserver_client_key = '/path/to/key', - $kubelet_client_crt = '/path/to/crt', - $kubelet_client_key = '/path/to/key', - $tags = [], +class datadog_agent::integrations::kubernetes ( + String $api_server_url = 'Enter_Your_API_url', + String $apiserver_client_crt = '/path/to/crt', + String $apiserver_client_key = '/path/to/key', + String $kubelet_client_crt = '/path/to/crt', + String $kubelet_client_key = '/path/to/key', + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kubernetes.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/kubernetes.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/kubernetes.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, diff --git a/manifests/integrations/kubernetes_state.pp b/manifests/integrations/kubernetes_state.pp index 10fe409c0..11910e961 100644 --- a/manifests/integrations/kubernetes_state.pp +++ b/manifests/integrations/kubernetes_state.pp @@ -1,6 +1,9 @@ # Class: datadog_agent::integrations::kubernetes # -# This class will install the necessary configuration for the kubernetes integration +# This class will install the necessary configuration for the kubernetes_state integration +# +# See the sample kubernetes_state.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/kubernetes_state/datadog_checks/kubernetes_state/data/conf.yaml.example # # Parameters: # $url: @@ -17,32 +20,24 @@ # url => 'http://kubernetes.com:8080/metrics', # } # -class datadog_agent::integrations::kubernetes_state( - $url = 'Enter_State_URL', - $tags = [], +class datadog_agent::integrations::kubernetes_state ( + String $url = 'Enter_State_URL', + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/kubernetes_state.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/kubernetes_state.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/kubernetes_state.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, diff --git a/manifests/integrations/linux_proc_extras.pp b/manifests/integrations/linux_proc_extras.pp index 9a93c006f..92dd6c71d 100644 --- a/manifests/integrations/linux_proc_extras.pp +++ b/manifests/integrations/linux_proc_extras.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the CPU cores integration # +# See the sample linux_proc_extras.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/linux_proc_extras/datadog_checks/linux_proc_extras/data/conf.yaml.example +# # Parameters: # # tags @@ -12,31 +15,22 @@ # class { 'datadog_agent::integrations::linux_proc_extras': # tags => [ 'env:production' ], # } - -class datadog_agent::integrations::linux_proc_extras( - $tags = [], +class datadog_agent::integrations::linux_proc_extras ( + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/linux_proc_extras.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/linux_proc_extras.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/linux_proc_extras.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -45,7 +39,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/linux_proc_extras.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/logs.pp b/manifests/integrations/logs.pp index a71e0e19a..388192f79 100644 --- a/manifests/integrations/logs.pp +++ b/manifests/integrations/logs.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the logs integration. # +# See the Datadog Logs Collection docs for all available configuration options +# https://docs.datadoghq.com/agent/logs/?tab=tailfiles#custom-log-collection +# # Parameters: # $logs: # array of log sources. @@ -35,21 +38,18 @@ # Documentation: # https://docs.datadoghq.com/logs/log_collection # - -class datadog_agent::integrations::logs( +class datadog_agent::integrations::logs ( Array $logs = [], ) inherits datadog_agent::params { - unless $::datadog_agent::_agent_major_version == 5 { - require ::datadog_agent + require datadog_agent - file { "${datadog_agent::params::conf_dir}/logs.yaml": - ensure => file, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_protected_file, - content => template('datadog_agent/agent-conf.d/logs.yaml.erb'), - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } + file { "${datadog_agent::params::conf_dir}/logs.yaml": + ensure => file, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_protected_file, + content => template('datadog_agent/agent-conf.d/logs.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/marathon.pp b/manifests/integrations/marathon.pp index cf1471564..9f106a7d0 100644 --- a/manifests/integrations/marathon.pp +++ b/manifests/integrations/marathon.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the Marathon integration # +# See the sample marathon.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/marathon/datadog_checks/marathon/data/conf.yaml.example +# # Parameters: # $url: # The URL for Marathon @@ -12,31 +15,23 @@ # url => "http://localhost:8080" # } # -class datadog_agent::integrations::marathon( - $marathon_timeout = 5, - $url = 'http://localhost:8080' +class datadog_agent::integrations::marathon ( + Integer $marathon_timeout = 5, + String $url = 'http://localhost:8080' ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/marathon.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/marathon.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/marathon.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -45,6 +40,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/marathon.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/memcache.pp b/manifests/integrations/memcache.pp index 985da7c9e..d433eb1cb 100644 --- a/manifests/integrations/memcache.pp +++ b/manifests/integrations/memcache.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the memcache integration # +# See the sample memcache.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/memcache/datadog_checks/memcache/data/conf.yaml.example +# # Parameters: # $url: # url used to connect to the memcached instance @@ -38,41 +41,33 @@ Variant[Boolean, String] $slabs = false, Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $url { $_instances = [{ - 'url' => $url, - 'port' => $port, - 'tags' => $tags, - 'items' => $items, - 'slabs' => $slabs, + 'url' => $url, + 'port' => $port, + 'tags' => $tags, + 'items' => $items, + 'slabs' => $slabs, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mcache.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/mcache.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/mcache.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -81,6 +76,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/mcache.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mesos_master.pp b/manifests/integrations/mesos_master.pp index 065fe8d97..fc6772e3d 100644 --- a/manifests/integrations/mesos_master.pp +++ b/manifests/integrations/mesos_master.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the mesos integration # +# See the sample mesos_master.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/mesos_master/datadog_checks/mesos_master/data/conf.yaml.example +# # Parameters: # $url: # The URL for Mesos master @@ -12,51 +15,39 @@ # url => "http://localhost:5050" # } # -class datadog_agent::integrations::mesos_master( - $mesos_timeout = 10, - $url = 'http://localhost:5050' +class datadog_agent::integrations::mesos_master ( + Integer $mesos_timeout = 10, + String $url = 'http://localhost:5050' ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/mesos.d" + $dst_dir = "${datadog_agent::params::conf_dir}/mesos.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = "${datadog_agent::params::legacy_conf_dir}/mesos.yaml" + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: - ensure => 'absent' + ensure => 'absent', } - $legacy_dst_master = "${datadog_agent::params::legacy_conf_dir}/mesos_master.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_master_dir = "${datadog_agent::params::conf_dir}/mesos_master.d" - file { $legacy_dst_master: - ensure => 'absent' - } + $dst_master_dir = "${datadog_agent::params::conf_dir}/mesos_master.d" - file { $dst_master_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst_master = "${dst_master_dir}/conf.yaml" - } else { - $dst_master = $legacy_dst_master + file { $dst_master_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst_master = "${dst_master_dir}/conf.yaml" file { $dst_master: ensure => file, @@ -65,6 +56,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/mesos_master.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mesos_slave.pp b/manifests/integrations/mesos_slave.pp index 9860cf716..3d8238cb0 100644 --- a/manifests/integrations/mesos_slave.pp +++ b/manifests/integrations/mesos_slave.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the mesos slave integration # +# See the sample mesos_slave.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/mesos_slave/datadog_checks/mesos_slave/data/conf.yaml.example +# # Parameters: # $url: # The URL for Mesos slave @@ -12,30 +15,21 @@ # url => "http://localhost:5051" # } # -class datadog_agent::integrations::mesos_slave( - $mesos_timeout = 10, - $url = 'http://localhost:5051' +class datadog_agent::integrations::mesos_slave ( + Integer $mesos_timeout = 10, + String $url = 'http://localhost:5051' ) inherits datadog_agent::params { + $dst_dir = "${datadog_agent::params::conf_dir}/mesos_slave.d" - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mesos_slave.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/mesos_slave.d" - file { $legacy_dst: - ensure => 'absent' - } - - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -44,6 +38,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/mesos_slave.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mongo.pp b/manifests/integrations/mongo.pp index 85c4ba7d3..e5bae95f8 100644 --- a/manifests/integrations/mongo.pp +++ b/manifests/integrations/mongo.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the mongo integration # +# See the sample mongo.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/mongo/datadog_checks/mongo/data/conf.yaml.example +# # NOTE: In newer versions of the Datadog Agent, the ssl parameters will be deprecated in favor the tls variants # # Parameters: @@ -104,30 +107,22 @@ # ] # } # -class datadog_agent::integrations::mongo( - Array $servers = [{'host' => 'localhost', 'port' => '27017'}] +class datadog_agent::integrations::mongo ( + Array $servers = [{ 'host' => 'localhost', 'port' => '27017' }] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mongo.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/mongo.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/mongo.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -136,6 +131,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/mongo.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/mysql.pp b/manifests/integrations/mysql.pp index 26106e13d..0931c6443 100644 --- a/manifests/integrations/mysql.pp +++ b/manifests/integrations/mysql.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the mysql integration # +# See the sample mysql.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/mysql/datadog_checks/mysql/data/conf.yaml.example +# # Parameters: # $password # The mysql password for the datadog user @@ -66,75 +69,67 @@ # } # # -class datadog_agent::integrations::mysql( - String $host = 'localhost', - Optional[String] $user = 'datadog', - Optional[Variant[String, Integer]] $port = 3306, - Optional[String] $password = undef, - Optional[String] $sock = undef, - Array $tags = [], - $replication = '0', - $galera_cluster = '0', - Boolean $extra_status_metrics = false, - Boolean $extra_innodb_metrics = false, - Boolean $extra_performance_metrics = false, - Boolean $schema_size_metrics = false, - Boolean $disable_innodb_metrics = false, - Optional[Boolean] $dbm = undef, - Optional[Array] $queries = [], - Optional[Array] $instances = undef, - Optional[Array] $logs = [], - ) inherits datadog_agent::params { - require ::datadog_agent +class datadog_agent::integrations::mysql ( + String $host = 'localhost', + String $user = 'datadog', + Variant[String, Integer] $port = 3306, + Optional[String] $password = undef, + Optional[String] $sock = undef, + Array $tags = [], + String $replication = '0', + String $galera_cluster = '0', + Boolean $extra_status_metrics = false, + Boolean $extra_innodb_metrics = false, + Boolean $extra_performance_metrics = false, + Boolean $schema_size_metrics = false, + Boolean $disable_innodb_metrics = false, + Optional[Boolean] $dbm = undef, + Array $queries = [], + Optional[Array] $instances = undef, + Array $logs = [], +) inherits datadog_agent::params { + require datadog_agent if ($host == undef and $sock == undef) or - ($host != undef and $port == undef and $sock == undef) { + ($host != undef and $port == undef and $sock == undef) { fail('invalid MySQL configuration') } if !$instances and $host { $_instances = [{ - 'host' => $host, - 'password' => $password, - 'user' => $user, - 'port' => $port, - 'sock' => $sock, - 'tags' => $tags, - 'replication' => $replication, - 'galera_cluster' => $galera_cluster, - 'extra_status_metrics' => $extra_status_metrics, - 'extra_innodb_metrics' => $extra_innodb_metrics, - 'extra_performance_metrics' => $extra_performance_metrics, - 'schema_size_metrics' => $schema_size_metrics, - 'disable_innodb_metrics' => $disable_innodb_metrics, - 'dbm' => $dbm, - 'queries' => $queries, + 'host' => $host, + 'password' => $password, + 'user' => $user, + 'port' => $port, + 'sock' => $sock, + 'tags' => $tags, + 'replication' => $replication, + 'galera_cluster' => $galera_cluster, + 'extra_status_metrics' => $extra_status_metrics, + 'extra_innodb_metrics' => $extra_innodb_metrics, + 'extra_performance_metrics' => $extra_performance_metrics, + 'schema_size_metrics' => $schema_size_metrics, + 'disable_innodb_metrics' => $disable_innodb_metrics, + 'dbm' => $dbm, + 'queries' => $queries, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/mysql.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/mysql.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/mysql.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -146,4 +141,3 @@ notify => Service[$datadog_agent::params::service_name], } } - diff --git a/manifests/integrations/network.pp b/manifests/integrations/network.pp index 3b409d638..f42c2d296 100644 --- a/manifests/integrations/network.pp +++ b/manifests/integrations/network.pp @@ -2,6 +2,9 @@ # # This class will install the network integration # +# See the sample network.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/network/datadog_checks/network/data/conf.yaml.default +# # Parameters: # $collect_connection_state # Enable TCP connection state counts @@ -19,7 +22,7 @@ # } # # -class datadog_agent::integrations::network( +class datadog_agent::integrations::network ( Boolean $collect_connection_state = false, Boolean $collect_connection_queues = false, Array[String] $excluded_interfaces = [], @@ -39,27 +42,19 @@ Array[String] $metric_patterns_include = [], Array[String] $metric_patterns_exclude = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/network.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/network.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/network.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, diff --git a/manifests/integrations/nginx.pp b/manifests/integrations/nginx.pp index 20853a779..7e16a3952 100644 --- a/manifests/integrations/nginx.pp +++ b/manifests/integrations/nginx.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the nginx integration # +# See the sample nginx.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/nginx/datadog_checks/nginx/data/conf.yaml.example +# # Parameters: # $instances: # Array of hashes for all nginx urls and associates tags. See example @@ -58,32 +61,23 @@ # source: nginx # sourcecategory: 'http_web_access' # - -class datadog_agent::integrations::nginx( - Array $instances = [], +class datadog_agent::integrations::nginx ( + Array $instances = [], Optional[Array] $logs = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/nginx.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/nginx.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/nginx.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -92,6 +86,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/nginx.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/ntp.pp b/manifests/integrations/ntp.pp index 14251377e..3d533c5c5 100644 --- a/manifests/integrations/ntp.pp +++ b/manifests/integrations/ntp.pp @@ -2,6 +2,9 @@ # # This class will enable ntp check # +# See the sample ntp.d/conf.yaml for all available configuration options +# https://github.com/DataDog/datadog-agent/blob/main/cmd/agent/dist/conf.d/ntp.d/conf.yaml.default +# # Parameters: # $offset_threshold: # Offset threshold for a critical alert. Defaults to 600. @@ -22,35 +25,26 @@ # host => 'pool.ntp.org', # } # - -class datadog_agent::integrations::ntp( - $offset_threshold = 60, - $host = undef, - $port = undef, - $version = undef, - $timeout = undef, +class datadog_agent::integrations::ntp ( + Integer $offset_threshold = 60, + Optional[String] $host = undef, + Optional[Integer] $port = undef, + Optional[String] $version = undef, + Optional[Integer] $timeout = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ntp.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/ntp.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/ntp.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -59,6 +53,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/ntp.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/oom_kill.pp b/manifests/integrations/oom_kill.pp index 62bb44a8f..0d15c85ec 100644 --- a/manifests/integrations/oom_kill.pp +++ b/manifests/integrations/oom_kill.pp @@ -3,6 +3,9 @@ # This class will install the necessary configuration for the oom_kill integration # For it to work you also need to enable the system-probe with enable_oom_kill set to true. # +# See the sample oom_kill.d/conf.yaml for all available configuration options +# https://github.com/DataDog/datadog-agent/blob/main/cmd/agent/dist/conf.d/oom_kill.d/conf.yaml.example +# # Parameters: # $instances: # Array of hashes for all oom_kill configs and associates tags. See example @@ -18,11 +21,10 @@ # ], # } # - -class datadog_agent::integrations::oom_kill( +class datadog_agent::integrations::oom_kill ( Array $instances = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $dst_dir = "${datadog_agent::params::conf_dir}/oom_kill.d" file { $dst_dir: @@ -31,7 +33,7 @@ group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_directory, require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } $dst = "${dst_dir}/conf.yaml" @@ -42,6 +44,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/oom_kill.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/pgbouncer.pp b/manifests/integrations/pgbouncer.pp index 1d9681d00..801e60acb 100644 --- a/manifests/integrations/pgbouncer.pp +++ b/manifests/integrations/pgbouncer.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the pgbouncer integration # +# See the sample pgbouncer.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/pgbouncer/datadog_checks/pgbouncer/data/conf.yaml.example +# # Parameters: # $password: # The password for the datadog user @@ -43,35 +46,27 @@ # ], # } # -class datadog_agent::integrations::pgbouncer( +class datadog_agent::integrations::pgbouncer ( String $password = '', String $host = 'localhost', Variant[String, Integer] $port = '6432', String $username = 'datadog', - Array $tags = [], - Array $pgbouncers = [], + Array $tags = [], + Array $pgbouncers = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/pgbouncer.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/pgbouncer.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/pgbouncer.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, diff --git a/manifests/integrations/php_fpm.pp b/manifests/integrations/php_fpm.pp index 01fd401d0..0fa7b80b3 100644 --- a/manifests/integrations/php_fpm.pp +++ b/manifests/integrations/php_fpm.pp @@ -1,74 +1,67 @@ -# Class: datadog_agent::integrations::php_fpm +# @summary # # This class will set-up PHP FPM monitoring # -# Parameters: -# $status_url +# See the sample php_fpm.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/php_fpm/datadog_checks/php_fpm/data/conf.yaml.example +# +# @param status_url # URL to fetch FPM metrics. Default: http://localhost/status # -# $ping_url +# @param ping_url # URL to get a reliable check of the FPM pool. Default: http://localhost/ping # -# $ping_reply +# @param ping_reply # Expected response from ping_url. Default: pong # -# $tags +# @param tags # Optional array of tags # -# $use_fastcgi +# @param use_fastcgi # Use fastcgi to get stats. Default: false # -# Sample Usage: +# @example # # class { 'datadog_agent::integrations::php_fpm' : # status_url => 'http://localhost/fpm_status', # ping_url => 'http://localhost/fpm_ping' # } # - -class datadog_agent::integrations::php_fpm( - $status_url = 'http://localhost/status', - $ping_url = 'http://localhost/ping', - $ping_reply = 'pong', - $http_host = undef, - $tags = [], - $instances = undef, - $use_fastcgi = 'false' +class datadog_agent::integrations::php_fpm ( + String $status_url = 'http://localhost/status', + String $ping_url = 'http://localhost/ping', + String $ping_reply = 'pong', + Optional[String] $http_host = undef, + Array $tags = [], + Optional[Array] $instances = undef, + String $use_fastcgi = 'false' ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances { $_instances = [{ - 'http_host' => $http_host, - 'status_url' => $status_url, - 'ping_url' => $ping_url, - 'ping_reply' => $ping_reply, - 'tags' => $tags, - 'use_fastcgi' => $use_fastcgi, + 'http_host' => $http_host, + 'status_url' => $status_url, + 'ping_url' => $ping_url, + 'ping_reply' => $ping_reply, + 'tags' => $tags, + 'use_fastcgi' => $use_fastcgi, }] } else { $_instances = $instances } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/php_fpm.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/php_fpm.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/php_fpm.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -77,6 +70,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/php_fpm.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/postfix.pp b/manifests/integrations/postfix.pp index 1226b8ddd..d44501b05 100644 --- a/manifests/integrations/postfix.pp +++ b/manifests/integrations/postfix.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the Postfix integration # +# See the sample postfix.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/postfix/datadog_checks/postfix/data/conf.yaml.example +# # Parameters: # $url: # url used to connect to the Postfixd instance @@ -30,43 +33,35 @@ # class datadog_agent::integrations::postfix ( String $directory = '/var/spool/postfix', - Array $queues = [ 'active', 'deferred', 'incoming' ], - Optional[Array] $tags = [], + Array $queues = ['active', 'deferred', 'incoming'], + Array $tags = [], Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $directory { $_instances = [{ - 'directory' => $directory, - 'queues' => $queues, - 'tags' => $tags + 'directory' => $directory, + 'queues' => $queues, + 'tags' => $tags }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/postfix.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/postfix.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/postfix.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -75,6 +70,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/postfix.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/postgres.pp b/manifests/integrations/postgres.pp index 71eff1677..cdfe6fd21 100644 --- a/manifests/integrations/postgres.pp +++ b/manifests/integrations/postgres.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the postgres integration # +# See the sample postgres.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/postgres/datadog_checks/postgres/data/conf.yaml.example +# # Parameters: # $password # The password for the datadog user @@ -94,7 +97,7 @@ # descriptors: # - ["tag_column", "tag_column.datadog.tag"] # -class datadog_agent::integrations::postgres( +class datadog_agent::integrations::postgres ( Optional[String] $password = undef, String $host = 'localhost', String $dbname = 'postgres', @@ -112,47 +115,39 @@ Hash $custom_metrics = {}, Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/postgres.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/postgres.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/postgres.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" if !$instances and $host { $_instances = [{ - 'host' => $host, - 'password' => $password, - 'dbname' => $dbname, - 'port' => $port, - 'username' => $username, - 'ssl' => $ssl, - 'use_psycopg2' => $use_psycopg2, - 'tags' => $tags, - 'tables' => $tables, - 'custom_metrics' => $custom_metrics, - 'collect_function_metrics' => $collect_function_metrics, - 'collect_count_metrics' => $collect_count_metrics, - 'collect_activity_metrics' => $collect_activity_metrics, - 'collect_database_size_metrics' => $collect_database_size_metrics, - 'collect_default_database' => $collect_default_database, + 'host' => $host, + 'password' => $password, + 'dbname' => $dbname, + 'port' => $port, + 'username' => $username, + 'ssl' => $ssl, + 'use_psycopg2' => $use_psycopg2, + 'tags' => $tags, + 'tables' => $tables, + 'custom_metrics' => $custom_metrics, + 'collect_function_metrics' => $collect_function_metrics, + 'collect_count_metrics' => $collect_count_metrics, + 'collect_activity_metrics' => $collect_activity_metrics, + 'collect_database_size_metrics' => $collect_database_size_metrics, + 'collect_default_database' => $collect_default_database, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances diff --git a/manifests/integrations/postgres_custom_metric.pp b/manifests/integrations/postgres_custom_metric.pp index 91a7b9139..92011034f 100644 --- a/manifests/integrations/postgres_custom_metric.pp +++ b/manifests/integrations/postgres_custom_metric.pp @@ -15,13 +15,12 @@ # $descriptor: # an array that maps an sql column's to a tag. Each descriptor consists of two # fields -- column name, and datadog tag. -define datadog_agent::integrations::postgres_custom_metric( +define datadog_agent::integrations::postgres_custom_metric ( String $query, Hash $metrics, Boolean $relation = false, Array $descriptors = [], ) { - if $query !~ '^.*%s.*$' { fail('custom_metrics require %s for metric substitution') } diff --git a/manifests/integrations/process.pp b/manifests/integrations/process.pp index c69a3505d..80b2249ac 100644 --- a/manifests/integrations/process.pp +++ b/manifests/integrations/process.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the process integration # +# See the sample process.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/process/datadog_checks/process/data/conf.yaml.example +# # Parameters: # $processes: # Array of process hashes. See example @@ -40,46 +43,42 @@ # # -class datadog_agent::integrations::process( +class datadog_agent::integrations::process ( Boolean $hiera_processes = false, - $init_config = {}, - Array $processes = [], - ) inherits datadog_agent::params { - require ::datadog_agent + Hash $init_config = {}, + Array $processes = [], +) inherits datadog_agent::params { + require datadog_agent if $hiera_processes { - $local_processes = lookup({ 'name' => 'datadog_agent::integrations::process::processes', 'merge' => 'unique', 'default_value' => $processes }) + $local_processes = lookup({ 'name' => 'datadog_agent::integrations::process::processes', 'merge' => 'unique', + 'default_value' => $processes }) } else { $local_processes = $processes } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/process.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/process.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/process.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: - ensure => $local_processes.length ? { 0 => absent, default => file}, + ensure => $local_processes.length ? { + 0 => 'absent', + default => file + }, owner => $datadog_agent::dd_user, group => $datadog_agent::params::dd_group, mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/process.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/rabbitmq.pp b/manifests/integrations/rabbitmq.pp index 66313f84b..c83b78a40 100644 --- a/manifests/integrations/rabbitmq.pp +++ b/manifests/integrations/rabbitmq.pp @@ -2,6 +2,9 @@ # # This class will install the necessary config to hook the rabbitmq in the agent # +# See the sample rabbitmq.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/rabbitmq/datadog_checks/rabbitmq/data/conf.yaml.example +# # Parameters: # $url # Required. URL pointing to the RabbitMQ Managment Plugin @@ -49,43 +52,33 @@ # password => 'guest', # } # - class datadog_agent::integrations::rabbitmq ( - Optional[String] $url = undef, - Optional[String] $username = 'guest', - Optional[String] $password = 'guest', - Boolean $ssl_verify = true, - Boolean $tag_families = false, - Array $nodes = [], - Array $nodes_regexes = [], - Array $queues = [], - Array $queues_regexes = [], - Array $vhosts = [], - Array $exchanges = [], - Array $exchanges_regexes = [], + Optional[String] $url = undef, + String $username = 'guest', + String $password = 'guest', + Boolean $ssl_verify = true, + Boolean $tag_families = false, + Array $nodes = [], + Array $nodes_regexes = [], + Array $queues = [], + Array $queues_regexes = [], + Array $vhosts = [], + Array $exchanges = [], + Array $exchanges_regexes = [], ) inherits datadog_agent::params { + require datadog_agent - require ::datadog_agent + $dst_dir = "${datadog_agent::params::conf_dir}/rabbitmq.d" - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/rabbitmq.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/rabbitmq.d" - file { $legacy_dst: - ensure => 'absent' - } - - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, diff --git a/manifests/integrations/redis.pp b/manifests/integrations/redis.pp index 47eab4cb3..2142c4029 100644 --- a/manifests/integrations/redis.pp +++ b/manifests/integrations/redis.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the redis integration # +# See the sample redisdb.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/redisdb/datadog_checks/redisdb/data/conf.yaml.example +# # Parameters: # $host: # The host redis is running on @@ -54,7 +57,7 @@ # warn_on_missing_keys: true # command_stats: false # -class datadog_agent::integrations::redis( +class datadog_agent::integrations::redis ( String $host = 'localhost', String $password = '', Variant[String, Integer] $port = '6379', @@ -72,10 +75,10 @@ Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if $ports == undef { - $_ports = [ $port ] + $_ports = [$port] } else { $_ports = $ports } @@ -98,29 +101,21 @@ } } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/redisdb.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/redisdb.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/redisdb.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" if !$instances and $host { $_instances = $_port_instances - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances @@ -133,6 +128,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/redisdb.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/riak.pp b/manifests/integrations/riak.pp index 5d5ab753b..54004b092 100644 --- a/manifests/integrations/riak.pp +++ b/manifests/integrations/riak.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the riak integration # +# See the sample riak.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/riak/datadog_checks/riak/data/conf.yaml.example +# # Parameters: # $url: # The URL for riak @@ -18,31 +21,23 @@ # url => 'http://localhost:8098/stats', # } # -class datadog_agent::integrations::riak( - String $url = 'http://localhost:8098/stats', - Array $tags = [], +class datadog_agent::integrations::riak ( + String $url = 'http://localhost:8098/stats', + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/riak.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/riak.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/riak.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: @@ -52,6 +47,6 @@ mode => $datadog_agent::params::permissions_file, content => template('datadog_agent/agent-conf.d/riak.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/snmp.pp b/manifests/integrations/snmp.pp index 6527859d4..e21e018d3 100755 --- a/manifests/integrations/snmp.pp +++ b/manifests/integrations/snmp.pp @@ -2,6 +2,9 @@ # # This class will enable snmp check # +# See the sample snmp.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/snmp/datadog_checks/snmp/data/conf.yaml.example +# # Parameters: # $init_config: # Optional hash (see snmp.yaml.example for reference) @@ -49,18 +52,16 @@ # } # ], # } - - class datadog_agent::integrations::snmp ( - $mibs_folder = undef, - $ignore_nonincreasing_oid = false, - $init_config = {}, - $instances = [], - $snmp_v1_instances = [], - $snmp_v2_instances = [], - $snmp_v3_instances = [], + Optional[Any] $mibs_folder = undef, + Boolean $ignore_nonincreasing_oid = false, + Hash $init_config = {}, + Array[Hash] $instances = [], + Array $snmp_v1_instances = [], + Array $snmp_v2_instances = [], + Array $snmp_v3_instances = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent $versioned_instances = { 1 => $snmp_v1_instances, @@ -68,25 +69,17 @@ 3 => $snmp_v3_instances, } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/snmp.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/snmp.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/snmp.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -95,6 +88,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/snmp.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/solr.pp b/manifests/integrations/solr.pp index 4c6db0201..bbf26867f 100644 --- a/manifests/integrations/solr.pp +++ b/manifests/integrations/solr.pp @@ -2,6 +2,15 @@ # # This class will install the necessary configuration for the solr integration # +# See the sample solr.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/solr/datadog_checks/solr/data/conf.yaml.example +# +# See the metrics.yaml file for the list of default collected metrics. +# https://github.com/DataDog/integrations-core/blob/master/solr/datadog_checks/solr/data/metrics.yaml +# +# This check has a limit of 350 metrics per instance. If you require +# additional metrics, contact Datadog Support at https://docs.datadoghq.com/help/ +# # Parameters: # $hostname: # The host solr is running on. Defaults to 'localhost' @@ -26,37 +35,29 @@ # port => 8081, # } # -class datadog_agent::integrations::solr( - $hostname = 'localhost', - $port = 7199, - $username = undef, - $password = undef, - $java_bin_path = undef, - $trust_store_path = undef, - $trust_store_password = undef, - $tags = {}, +class datadog_agent::integrations::solr ( + String $hostname = 'localhost', + Integer $port = 7199, + Optional[String] $username = undef, + Optional[Any] $password = undef, + Optional[String] $java_bin_path = undef, + Optional[String] $trust_store_path = undef, + Optional[Any] $trust_store_password = undef, + Hash $tags = {}, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/solr.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/solr.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/solr.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -65,7 +66,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/solr.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/ssh.pp b/manifests/integrations/ssh.pp index 697497bc4..f0a807095 100644 --- a/manifests/integrations/ssh.pp +++ b/manifests/integrations/ssh.pp @@ -2,6 +2,9 @@ # # This class will enable ssh check # +# See the sample ssh_check.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/ssh_check/datadog_checks/ssh_check/data/conf.yaml.example +# # Parameters: # $host: # ssh server to use for ssh check @@ -25,37 +28,28 @@ # private_key_file => '/opt/super_secret_key', # } # - -class datadog_agent::integrations::ssh( - $host = $trusted['certname'], - $port = 22, - $username = $datadog_agent::dd_user, - $password = undef, - $sftp_check = true, - $private_key_file = undef, - $add_missing_keys = true, +class datadog_agent::integrations::ssh ( + String $host = $trusted['certname'], + Integer $port = 22, + String $username = $datadog_agent::dd_user, + Optional[Any] $password = undef, + Boolean $sftp_check = true, + Optional[String] $private_key_file = undef, + Boolean $add_missing_keys = true, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/ssh.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/ssh_check.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/ssh_check.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -64,6 +58,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/ssh.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/supervisord.pp b/manifests/integrations/supervisord.pp index 6ad15166c..14a18c863 100644 --- a/manifests/integrations/supervisord.pp +++ b/manifests/integrations/supervisord.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the supervisord integration # +# See the sample supervisord.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/supervisord/datadog_checks/supervisord/data/conf.yaml.example +# # Parameters: # servername # socket @@ -40,31 +43,22 @@ # # # - class datadog_agent::integrations::supervisord ( - $instances = [{'servername' => 'server0', 'hostname' => 'localhost', 'port' => '9001'}], + Array $instances = [{ 'servername' => 'server0', 'hostname' => 'localhost', 'port' => '9001' }], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/supervisord.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/supervisord.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/supervisord.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -73,6 +67,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/supervisord.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/system_core.pp b/manifests/integrations/system_core.pp index 19a0a4e2e..0da643878 100644 --- a/manifests/integrations/system_core.pp +++ b/manifests/integrations/system_core.pp @@ -2,40 +2,35 @@ # # This class will install the necessary configuration for the system_core integration # +# See the sample system_core.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/system_core/datadog_checks/system_core/data/conf.yaml.example +# # Sample Usage: # include 'datadog_agent::integrations::system_core' # # class datadog_agent::integrations::system_core inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/system_core.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/system_core.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/system_core.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: - ensure => file, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_file, - content => template('datadog_agent/agent-conf.d/system_core.yaml.erb'), - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + ensure => file, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_file, + content => template('datadog_agent/agent-conf.d/system_core.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/tcp_check.pp b/manifests/integrations/tcp_check.pp index bd5be5387..78d2710b8 100644 --- a/manifests/integrations/tcp_check.pp +++ b/manifests/integrations/tcp_check.pp @@ -2,6 +2,9 @@ # # This class will install the necessary config to hook the tcp_check in the agent # +# See the sample tcp_check.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/tcp_check/datadog_checks/tcp_check/data/conf.yaml.example +# # Parameters: # check_name # (Required) - Name of the service. @@ -30,11 +33,6 @@ # response time metric will be collected. If it is set to true, the # metric returned is network.tcp.response_time. # -# skip_event -# The (optional) skip_event parameter will instruct the check to not -# create any event to avoid duplicates with a server side service check. -# This default to False. -# # tags # The (optional) tags to add to the check instance. # @@ -64,8 +62,7 @@ # timeout => '8', # threshold => 1, # window => 1, -# collect_response_time => 1, -# skip_event => 1, +# collect_response_time => true, # tags => ['production', 'webserver response time'], # } # @@ -83,59 +80,47 @@ # 'port' => '443', # }] # } - - class datadog_agent::integrations::tcp_check ( - $check_name = undef, - $host = undef, - $port = undef, - Integer $timeout = 10, - $threshold = undef, - $window = undef, - $collect_response_time = undef, - $skip_event = undef, - Array $tags = [], - Optional[Array] $instances = undef, + String $check_name, + String $host, + String $port, + Integer $timeout = 10, + Optional[Integer] $threshold = undef, + Optional[Integer] $window = undef, + Boolean $collect_response_time = false, + Array $tags = [], + Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $host { $_instances = [{ - 'check_name' => $check_name, - 'host' => $host, - 'port' => $port, - 'timeout' => $timeout, - 'threshold' => $threshold, - 'window' => $window, - 'collect_response_time' => $collect_response_time, - 'skip_event' => $skip_event, - 'tags' => $tags, + 'check_name' => $check_name, + 'host' => $host, + 'port' => $port, + 'timeout' => $timeout, + 'threshold' => $threshold, + 'window' => $window, + 'collect_response_time' => $collect_response_time, + 'tags' => $tags, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/tcp_check.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/tcp_check.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/tcp_check.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -144,6 +129,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/tcp_check.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/tomcat.pp b/manifests/integrations/tomcat.pp index 5092603fe..f8ad3692e 100644 --- a/manifests/integrations/tomcat.pp +++ b/manifests/integrations/tomcat.pp @@ -2,6 +2,15 @@ # # This class will install the necessary configuration for the tomcat integration # +# See the sample tomcat.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/tomcat/datadog_checks/tomcat/data/conf.yaml.example +# +# See the metrics.yaml file for the list of default collected metrics. +# https://github.com/DataDog/integrations-core/blob/master/tomcat/datadog_checks/tomcat/data/metrics.yaml +# +# This check has a limit of 350 metrics per instance. If you require +# additional metrics, contact Datadog Support at https://docs.datadoghq.com/help/ +# # Parameters: # $hostname: # The host tomcat is running on. Defaults to 'localhost' @@ -28,39 +37,30 @@ # port => 8081, # } # -class datadog_agent::integrations::tomcat( - $hostname = 'localhost', - $port = 7199, - $jmx_url = undef, - $username = undef, - $password = undef, - $java_bin_path = undef, - $trust_store_path = undef, - $trust_store_password = undef, - $tags = {}, +class datadog_agent::integrations::tomcat ( + String $hostname = 'localhost', + Integer $port = 7199, + Optional[String] $jmx_url = undef, + Optional[String] $username = undef, + Optional[Any] $password = undef, + Optional[String] $java_bin_path = undef, + Optional[String] $trust_store_path = undef, + Optional[Any] $trust_store_password = undef, + Hash $tags = {}, ) inherits datadog_agent::params { - require ::datadog_agent - + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/tomcat.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/tomcat.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/tomcat.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -69,7 +69,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/tomcat.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } - } diff --git a/manifests/integrations/twemproxy.pp b/manifests/integrations/twemproxy.pp index f5f065c22..ecbb80e65 100644 --- a/manifests/integrations/twemproxy.pp +++ b/manifests/integrations/twemproxy.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the twemproxy aka nutcracker integration # +# See the sample twemproxy.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/twemproxy/datadog_checks/twemproxy/data/conf.yaml.example +# # Parameters: # $host: # The host twemproxy is running on. Defaults to '127.0.0.1' @@ -23,43 +26,35 @@ # ] # } # -class datadog_agent::integrations::twemproxy( - $host = 'localhost', - $port = '22222', - $instances = undef, +class datadog_agent::integrations::twemproxy ( + String $host = 'localhost', + String $port = '22222', + Optional[Array] $instances = undef, ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent if !$instances and $host { $_instances = [{ - 'host' => $host, - 'port' => $port, + 'host' => $host, + 'port' => $port, }] - } elsif !$instances{ + } elsif !$instances { $_instances = [] } else { $_instances = $instances } - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/twemproxy.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/twemproxy.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/twemproxy.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -68,6 +63,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/twemproxy.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/varnish.pp b/manifests/integrations/varnish.pp index 95e31e8a6..498e37dfd 100644 --- a/manifests/integrations/varnish.pp +++ b/manifests/integrations/varnish.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the varnish integration # +# See the sample varnish.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/varnish/datadog_checks/varnish/data/conf.yaml.example +# # Parameters: # varnishstat # Path to the varnishstat binary @@ -22,31 +25,23 @@ # } # class datadog_agent::integrations::varnish ( - $varnishstat = '/usr/bin/varnishstat', - $instance_name = undef, - $tags = [], + String $varnishstat = '/usr/bin/varnishstat', + Optional[String] $instance_name = undef, + Array $tags = [], ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/varnish.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/varnish.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/varnish.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -55,6 +50,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/varnish.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/integrations/zk.pp b/manifests/integrations/zk.pp index 0e3fad091..0fc031115 100644 --- a/manifests/integrations/zk.pp +++ b/manifests/integrations/zk.pp @@ -2,6 +2,9 @@ # # This class will install the necessary configuration for the zk integration # +# See the sample zk.d/conf.yaml for all available configuration options +# https://github.com/DataDog/integrations-core/blob/master/zk/datadog_checks/zk/data/conf.yaml.example +# # Parameters: # $host: # The host zk is running on. Defaults to '127.0.0.1' @@ -28,29 +31,21 @@ # } # class datadog_agent::integrations::zk ( - $servers = [{'host' => 'localhost', 'port' => '2181'}] + Array $servers = [{ 'host' => 'localhost', 'port' => '2181' }] ) inherits datadog_agent::params { - require ::datadog_agent + require datadog_agent - $legacy_dst = "${datadog_agent::params::legacy_conf_dir}/zk.yaml" - if $::datadog_agent::_agent_major_version > 5 { - $dst_dir = "${datadog_agent::params::conf_dir}/zk.d" - file { $legacy_dst: - ensure => 'absent' - } + $dst_dir = "${datadog_agent::params::conf_dir}/zk.d" - file { $dst_dir: - ensure => directory, - owner => $datadog_agent::dd_user, - group => $datadog_agent::params::dd_group, - mode => $datadog_agent::params::permissions_directory, - require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] - } - $dst = "${dst_dir}/conf.yaml" - } else { - $dst = $legacy_dst + file { $dst_dir: + ensure => directory, + owner => $datadog_agent::dd_user, + group => $datadog_agent::params::dd_group, + mode => $datadog_agent::params::permissions_directory, + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name], } + $dst = "${dst_dir}/conf.yaml" file { $dst: ensure => file, @@ -59,6 +54,6 @@ mode => $datadog_agent::params::permissions_protected_file, content => template('datadog_agent/agent-conf.d/zk.yaml.erb'), require => Package[$datadog_agent::params::package_name], - notify => Service[$datadog_agent::params::service_name] + notify => Service[$datadog_agent::params::service_name], } } diff --git a/manifests/params.pp b/manifests/params.pp index 0483a91de..50ff4d2ae 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -2,7 +2,6 @@ # # This class contains the parameters for the Datadog module # - class datadog_agent::params { $datadog_site = 'datadoghq.com' $dd_groups = undef @@ -28,7 +27,7 @@ case $facts['os']['name'] { 'Ubuntu','Debian','Raspbian' : { $rubydev_package = 'ruby-dev' - case $::operatingsystemrelease{ + case $facts['os']['release']['full'] { '14.04': { # Specific ruby/rubygems package name for Ubuntu 14.04 $ruby_package = 'ruby' @@ -87,5 +86,4 @@ } default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${facts['os']['name']}") } } - } diff --git a/manifests/redhat.pp b/manifests/redhat.pp index eb2bf2b92..6bab9e165 100644 --- a/manifests/redhat.pp +++ b/manifests/redhat.pp @@ -2,8 +2,7 @@ # # This class contains the DataDog agent installation mechanism for Red Hat derivatives # - -class datadog_agent::redhat( +class datadog_agent::redhat ( Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, Optional[String] $agent_repo_uri = undef, Boolean $manage_repo = true, @@ -11,18 +10,16 @@ String $agent_flavor = $datadog_agent::params::package_name, Optional[Boolean] $rpm_repo_gpgcheck = undef, ) inherits datadog_agent::params { - if $manage_repo { - $all_keys = [ - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', ] #In this regex, version '1:6.15.0~rc.1-1' would match as $1='1:', $2='6', $3='15', $4='0', $5='~rc.1', $6='1' if $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)((?:~|-)[^0-9\s-]+[^-\s]*)?(?:-([0-9]+))?/ or $agent_version == 'latest' { - if $agent_major_version > 5 and ($agent_version == 'latest' or 0 + $3 > 35) { + if $agent_major_version >= 6 and ($agent_version == 'latest' or 0 + $3 > 35) { $keys = $all_keys[0,3] } else { $keys = $all_keys @@ -34,7 +31,7 @@ if ($rpm_repo_gpgcheck != undef) { $repo_gpgcheck = $rpm_repo_gpgcheck } else { - if ($agent_repo_uri == undef) and ($agent_major_version > 5) { + if ($agent_repo_uri == undef) and ($agent_major_version >= 6) { case $facts['os']['name'] { 'RedHat', 'CentOS', 'OracleLinux': { # disable repo_gpgcheck on 8.1 because of https://bugzilla.redhat.com/show_bug.cgi?id=1792506 @@ -51,14 +48,9 @@ } else { $repo_gpgcheck = false } - } case $agent_major_version { - 5 : { - $defaulturl = "https://yum.datadoghq.com/rpm/${facts['os']['architecture']}/" - $gpgkeys = $keys - } 6 : { $defaulturl = "https://yum.datadoghq.com/stable/6/${facts['os']['architecture']}/" $gpgkeys = $keys @@ -85,15 +77,15 @@ ensure => absent, } - yumrepo {'datadog5': - ensure => absent, + yumrepo { 'datadog5': + ensure => absent, } - yumrepo {'datadog6': - ensure => absent, + yumrepo { 'datadog6': + ensure => absent, } - yumrepo {'datadog': + yumrepo { 'datadog': enabled => 1, gpgcheck => 1, gpgkey => join($gpgkeys, "\n "), @@ -108,7 +100,7 @@ } } else { package { $agent_flavor: - ensure => $agent_version, + ensure => $agent_version, } } } diff --git a/manifests/reports.pp b/manifests/reports.pp index ad3fb119a..53dba54ed 100644 --- a/manifests/reports.pp +++ b/manifests/reports.pp @@ -15,53 +15,49 @@ # # Sample Usage: # -class datadog_agent::reports( - $api_key, - $puppetmaster_user, - $dogapi_version, - $manage_dogapi_gem = true, - $hostname_extraction_regex = undef, - $proxy_http = undef, - $proxy_https = undef, - $report_fact_tags = [], - $report_trusted_fact_tags = [], - $datadog_site = 'https://api.datadoghq.com', - $puppet_gem_provider = $datadog_agent::params::gem_provider, +class datadog_agent::reports ( + String $api_key, + String $puppetmaster_user, + String $dogapi_version, + Boolean $manage_dogapi_gem = true, + Optional[String] $hostname_extraction_regex = undef, + Optional[String] $proxy_http = undef, + Optional[String] $proxy_https = undef, + Array $report_fact_tags = [], + Array $report_trusted_fact_tags = [], + String $datadog_site = 'https://api.datadoghq.com', + String $puppet_gem_provider = $datadog_agent::params::gem_provider, ) inherits datadog_agent::params { - if ($facts['os']['name'] == 'Windows') { - fail('Reporting is not yet supported from a Windows host') - } else { - - require ::datadog_agent + require datadog_agent if $manage_dogapi_gem { $rubydev_package = $datadog_agent::params::rubydev_package # check to make sure that you're not installing rubydev somewhere else if ! defined(Package[$rubydev_package]) { - package {$rubydev_package: + package { $rubydev_package: ensure => installed, - before => Package['dogapi'] + before => Package['dogapi'], } } if (! defined(Package['rubygems'])) { package { 'ruby': ensure => 'installed', - name => $datadog_agent::params::ruby_package + name => $datadog_agent::params::ruby_package, } package { 'rubygems': ensure => 'installed', name => $datadog_agent::params::rubygems_package, - require => Package['ruby'] + require => Package['ruby'], } } - package{ 'dogapi': + package { 'dogapi': ensure => $dogapi_version, provider => $puppet_gem_provider, } @@ -75,6 +71,5 @@ mode => '0640', require => File['/etc/datadog-agent'], } - } } diff --git a/manifests/security_agent.pp b/manifests/security_agent.pp index eceb12036..d272ade66 100644 --- a/manifests/security_agent.pp +++ b/manifests/security_agent.pp @@ -1,4 +1,8 @@ -class datadog_agent::security_agent( +# Class: datadog_agent::security_agent +# +# This class defines the Datadog Security Agent configuration. +# +class datadog_agent::security_agent ( Boolean $enabled = false, Optional[String] $socket = undef, @@ -7,16 +11,14 @@ Optional[String] $service_provider = undef, ) inherits datadog_agent::params { - $securityagent_config = { 'runtime_security_config' => { 'enabled' => $enabled, - 'socket' => $socket, + 'socket' => $socket, }, } if $facts['os']['name'] == 'Windows' { - file { 'C:/ProgramData/Datadog/security-agent.yaml': owner => $datadog_agent::params::dd_user, group => $datadog_agent::params::dd_group, @@ -24,9 +26,7 @@ content => template('datadog_agent/security-agent.yaml.erb'), require => File['C:/ProgramData/Datadog'], } - } else { - if $service_provider { service { $datadog_agent::params::securityagent_service_name: ensure => $service_ensure, @@ -55,5 +55,4 @@ require => File['/etc/datadog-agent'], } } - } diff --git a/manifests/service.pp b/manifests/service.pp index fbd74eef9..d0102d108 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -2,21 +2,19 @@ # # This class declares the datadog-agent service # - -class datadog_agent::service( - $service_ensure = 'running', +class datadog_agent::service ( + String $service_ensure = 'running', Variant[Boolean, Enum['manual', 'mask', 'delayed']] $service_enable = true, Optional[String] $service_provider = undef, String $agent_flavor = $datadog_agent::params::package_name, ) inherits datadog_agent::params { - if ($facts['os']['name'] == 'Windows') { - service { $datadog_agent::params::service_name: - ensure => $service_ensure, - enable => $service_enable, - restart => ['powershell', '-Command', 'Restart-Service -Force DatadogAgent'], # Force restarts dependent services - require => Package[$datadog_agent::params::package_name] - } + service { $datadog_agent::params::service_name: + ensure => $service_ensure, + enable => $service_enable, + restart => ['powershell', '-Command', 'Restart-Service -Force DatadogAgent'], # Force restarts dependent services + require => Package[$datadog_agent::params::package_name], + } } else { if $service_provider { service { $datadog_agent::params::service_name: @@ -37,6 +35,4 @@ } } } - - } diff --git a/manifests/suse.pp b/manifests/suse.pp index 37626817d..90d78f46b 100644 --- a/manifests/suse.pp +++ b/manifests/suse.pp @@ -2,8 +2,7 @@ # # This class contains the DataDog agent installation mechanism for SUSE distributions # - -class datadog_agent::suse( +class datadog_agent::suse ( Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, String $agent_version = $datadog_agent::params::agent_version, String $release = $datadog_agent::params::apt_default_release, @@ -11,7 +10,6 @@ String $agent_flavor = $datadog_agent::params::package_name, Optional[Boolean] $rpm_repo_gpgcheck = undef, ) inherits datadog_agent::params { - $current_key = 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public' $all_keys = [ $current_key, @@ -21,11 +19,11 @@ ] #In this regex, version '1:6.15.0~rc.1-1' would match as $1='1:', $2='6', $3='15', $4='0', $5='~rc.1', $6='1' if $agent_version =~ /([0-9]+:)?([0-9]+)\.([0-9]+)\.([0-9]+)((?:~|-)[^0-9\s-]+[^-\s]*)?(?:-([0-9]+))?/ or $agent_version == 'latest' { - if $agent_major_version > 5 and ($agent_version == 'latest' or 0 + $3 > 35) { - $keys_to_use = $all_keys[0,3] - } else { - $keys_to_use = $all_keys - } + if $agent_major_version >= 6 and ($agent_version == 'latest' or 0 + $3 > 35) { + $keys_to_use = $all_keys[0,3] + } else { + $keys_to_use = $all_keys + } } else { $keys_to_use = $all_keys } @@ -41,10 +39,9 @@ } case $agent_major_version { - 5 : { fail('Agent v5 package not available in SUSE') } - 6 : { $gpgkeys = $keys_to_use } - 7 : { $gpgkeys = $keys_to_use } - default: { fail('invalid agent_major_version') } + 6 : { $gpgkeys = $keys_to_use } + 7 : { $gpgkeys = $keys_to_use } + default: { fail('invalid agent_major_version') } } if ($agent_repo_uri != undef) { @@ -99,7 +96,6 @@ } package { $agent_flavor: - ensure => $agent_version, + ensure => $agent_version, } - } diff --git a/manifests/system_probe.pp b/manifests/system_probe.pp index df0443a52..9e0bcc128 100644 --- a/manifests/system_probe.pp +++ b/manifests/system_probe.pp @@ -4,22 +4,19 @@ # On Windows, install the NPM driver by setting 'windows_npm_install' # to 'true on the datadog_agent class. # - -class datadog_agent::system_probe( - Boolean $enabled = false, - Boolean $network_enabled = false, - Boolean $service_monitoring_enabled = false, - Optional[String] $log_file = undef, - Optional[String] $sysprobe_socket = undef, - Optional[Boolean] $enable_oom_kill = false, +class datadog_agent::system_probe ( + Boolean $enabled = false, + Boolean $network_enabled = false, + Boolean $service_monitoring_enabled = false, + Optional[String] $log_file = undef, + Optional[String] $sysprobe_socket = undef, + Boolean $enable_oom_kill = false, Optional[Hash] $runtime_security_config = undef, Boolean $service_enable = true, String $service_ensure = 'running', Optional[String] $service_provider = undef, ) inherits datadog_agent::params { - - $sysprobe_config = { 'system_probe_config' => { 'enabled' => $enabled, @@ -45,9 +42,7 @@ require => File['C:/ProgramData/Datadog'], notify => Service[$datadog_agent::params::service_name], } - } else { - if $service_provider { service { $datadog_agent::params::sysprobe_service_name: ensure => $service_ensure, @@ -76,5 +71,4 @@ require => File['/etc/datadog-agent'], } } - } diff --git a/manifests/tag5.pp b/manifests/tag5.pp deleted file mode 100644 index 9134b4211..000000000 --- a/manifests/tag5.pp +++ /dev/null @@ -1,30 +0,0 @@ -# Allow custom tags via a define -define datadog_agent::tag5( - $tag_name = $name, - $lookup_fact = false, -){ - - if $lookup_fact{ - $value = getvar($tag_name) - - if is_array($value){ - $tags = prefix($value, "${tag_name}:") - datadog_agent::tag5{$tags: } - } else { - if $value { - concat::fragment{ "datadog tag ${tag_name}:${value}": - target => '/etc/dd-agent/datadog.conf', - content => "${tag_name}:${value}, ", - order => '03', - } - } - } - } else { - concat::fragment{ "datadog tag ${tag_name}": - target => '/etc/dd-agent/datadog.conf', - content => "${tag_name}, ", - order => '03', - } - } - -} diff --git a/manifests/ubuntu.pp b/manifests/ubuntu.pp index 806cbef8c..149c78858 100644 --- a/manifests/ubuntu.pp +++ b/manifests/ubuntu.pp @@ -2,24 +2,22 @@ # # This class contains the DataDog agent installation mechanism for Debian derivatives # - -class datadog_agent::ubuntu( - Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, - String $agent_version = $datadog_agent::params::agent_version, - Optional[String] $agent_repo_uri = undef, - String $release = $datadog_agent::params::apt_default_release, - Boolean $skip_apt_key_trusting = false, - String $agent_flavor = $datadog_agent::params::package_name, - Optional[String] $apt_trusted_d_keyring = '/etc/apt/trusted.gpg.d/datadog-archive-keyring.gpg', - Optional[String] $apt_usr_share_keyring = '/usr/share/keyrings/datadog-archive-keyring.gpg', - Optional[Hash[String, String]] $apt_default_keys = { +class datadog_agent::ubuntu ( + Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, + String $agent_version = $datadog_agent::params::agent_version, + Optional[String] $agent_repo_uri = undef, + String $release = $datadog_agent::params::apt_default_release, + Boolean $skip_apt_key_trusting = false, + String $agent_flavor = $datadog_agent::params::package_name, + String $apt_trusted_d_keyring = '/etc/apt/trusted.gpg.d/datadog-archive-keyring.gpg', + String $apt_usr_share_keyring = '/usr/share/keyrings/datadog-archive-keyring.gpg', + Hash[String, String] $apt_default_keys = { 'DATADOG_APT_KEY_CURRENT.public' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_CURRENT.public', '5F1E256061D813B125E156E8E6266D4AC0962C7D' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_C0962C7D.public', 'D75CEA17048B9ACBF186794B32637D44F14F620E' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_F14F620E.public', 'A2923DFF56EDA6E76E55E492D3A80E30382E94DE' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_382E94DE.public', }, ) inherits datadog_agent::params { - if $agent_version =~ /^[0-9]+\.[0-9]+\.[0-9]+((?:~|-)[^0-9\s-]+[^-\s]*)?$/ { $platform_agent_version = "1:${agent_version}-1" } @@ -28,14 +26,13 @@ } case $agent_major_version { - 5 : { $repos = 'main' } 6 : { $repos = '6' } 7 : { $repos = '7' } default: { fail('invalid agent_major_version') } } if !$skip_apt_key_trusting { - ensure_packages(['gnupg']) + stdlib::ensure_packages(['gnupg']) file { $apt_usr_share_keyring: ensure => file, @@ -52,18 +49,20 @@ source => $key_url, } + $unless_cmd = @("CMD"/L) + /usr/bin/gpg --no-default-keyring --keyring ${apt_usr_share_keyring} --list-keys --with-fingerprint --with-colons | grep \ + $(cat /tmp/${key_fingerprint} | gpg --with-colons --with-fingerprint 2>/dev/null | grep 'fpr:' | sed 's|^fpr||' | tr -d ':') + | CMD + exec { "ensure key ${key_fingerprint} is imported in APT keyring": command => "/bin/cat /tmp/${key_fingerprint} | gpg --import --batch --no-default-keyring --keyring ${apt_usr_share_keyring}", # the second part extracts the fingerprint of the key from output like "fpr::::A2923DFF56EDA6E76E55E492D3A80E30382E94DE:" - unless => @("CMD"/L) - /usr/bin/gpg --no-default-keyring --keyring ${apt_usr_share_keyring} --list-keys --with-fingerprint --with-colons | grep \ - $(cat /tmp/${key_fingerprint} | gpg --with-colons --with-fingerprint 2>/dev/null | grep 'fpr:' | sed 's|^fpr||' | tr -d ':') - | CMD + unless => $unless_cmd, } } if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16') == -1) or - ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '9') == -1) { + ($facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '9') == -1) { file { $apt_trusted_d_keyring: mode => '0644', source => "file://${apt_usr_share_keyring}", @@ -104,12 +103,12 @@ package { $agent_flavor: ensure => $platform_agent_version, require => [Apt::Source['datadog'], - Class['apt::update']], + Class['apt::update']], } package { 'datadog-signing-keys': ensure => 'latest', require => [Apt::Source['datadog'], - Class['apt::update']], + Class['apt::update']], } } diff --git a/manifests/ubuntu_installer.pp b/manifests/ubuntu_installer.pp index 9f4ce9e22..6f22c797a 100644 --- a/manifests/ubuntu_installer.pp +++ b/manifests/ubuntu_installer.pp @@ -67,7 +67,7 @@ # Do not re-install keys as it is already managed in `ubuntu.pp` if ! $manage_agent_install { if !$skip_apt_key_trusting { - ensure_packages(['gnupg']) + stdlib::ensure_packages(['gnupg']) file { $apt_usr_share_keyring: ensure => file, @@ -85,13 +85,15 @@ source => $key_url, } + $unless_cmd = @("CMD"/L) + /usr/bin/gpg --no-default-keyring --keyring ${apt_usr_share_keyring} --list-keys --with-fingerprint --with-colons | grep \ + $(cat /tmp/${key_fingerprint} | gpg --with-colons --with-fingerprint 2>/dev/null | grep 'fpr:' | sed 's|^fpr||' | tr -d ':') + | CMD + exec { "ensure key ${key_fingerprint} is imported in APT keyring": command => "/bin/cat /tmp/${key_fingerprint} | gpg --import --batch --no-default-keyring --keyring ${apt_usr_share_keyring}", # the second part extracts the fingerprint of the key from output like "fpr::::A2923DFF56EDA6E76E55E492D3A80E30382E94DE:" - unless => @("CMD"/L) - /usr/bin/gpg --no-default-keyring --keyring ${apt_usr_share_keyring} --list-keys --with-fingerprint --with-colons | grep \ - $(cat /tmp/${key_fingerprint} | gpg --with-colons --with-fingerprint 2>/dev/null | grep 'fpr:' | sed 's|^fpr||' | tr -d ':') - | CMD + unless => $unless_cmd, } } if ($facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '16') == -1) or diff --git a/manifests/windows.pp b/manifests/windows.pp index 15e014af0..f899099ac 100644 --- a/manifests/windows.pp +++ b/manifests/windows.pp @@ -2,8 +2,7 @@ # # This class contains the DataDog agent installation mechanism for Windows # - -class datadog_agent::windows( +class datadog_agent::windows ( Integer $agent_major_version = $datadog_agent::params::default_agent_major_version, String $agent_version = $datadog_agent::params::agent_version, Optional[String] $agent_repo_uri = undef, @@ -18,7 +17,6 @@ Optional[String] $ddagentuser_name = undef, Optional[String] $ddagentuser_password = undef, ) inherits datadog_agent::params { - $msi_full_path = "${msi_location}/datadog-agent-${agent_major_version}-${agent_version}.amd64.msi" if ($agent_repo_uri != undef) { @@ -35,7 +33,7 @@ if $ensure == 'present' { if ($agent_version in ['6.14.0', '6.14.1']) { - fail('The specified agent version has been blacklisted, please specify a version other than 6.14.0 or 6.14.1') + fail('The specified agent version has been deemed unacceptable for installation, please specify a version other than 6.14.0 or 6.14.1') } file { 'installer': @@ -44,18 +42,20 @@ provider => 'windows', } + $unless_cmd = @("ACCEPTABLE"/$L) + \$denylist = '928b00d2f952219732cda9ae0515351b15f9b9c1ea1d546738f9dc0fda70c336','78b2bb2b231bcc185eb73dd367bfb6cb8a5d45ba93a46a7890fd607dc9188194'; + \$fileStream = [system.io.file]::openread('${msi_full_path}'); + \$hasher = [System.Security.Cryptography.HashAlgorithm]::create('sha256'); + \$hash = \$hasher.ComputeHash(\$fileStream); + \$fileStream.close(); + \$fileStream.dispose(); + \$hexhash = [system.bitconverter]::tostring(\$hash).ToLower().replace('-',''); + if (\$denylist.Contains(\$hexhash)) { Exit 1 } else { Exit 0 } + | ACCEPTABLE + exec { 'assert-acceptable-msi':, command => 'Exit 1', - unless => @(ACCEPTABLE), - $blacklist = '928b00d2f952219732cda9ae0515351b15f9b9c1ea1d546738f9dc0fda70c336','78b2bb2b231bcc185eb73dd367bfb6cb8a5d45ba93a46a7890fd607dc9188194'; - $fileStream = [system.io.file]::openread('${msi_full_path}'); - $hasher = [System.Security.Cryptography.HashAlgorithm]::create('sha256'); - $hash = $hasher.ComputeHash($fileStream); - $fileStream.close(); - $fileStream.dispose(); - $hexhash = [system.bitconverter]::tostring($hash).ToLower().replace('-',''); - if ($blacklist.Contains($hexhash)) { Exit 1 } else { Exit 0 } - | ACCEPTABLE + unless => $unless_cmd, provider => 'powershell', logoutput => 'on_failure', require => File['installer'], @@ -71,16 +71,15 @@ $hostname_option = $hostname ? { '' => {}, default => { 'HOSTNAME' => $hostname } } $npm_install_option = $npm_install ? { false => {}, true => { 'ADDLOCAL' => 'MainApplication,NPM' } } - $ddagentuser_name_option = $ddagentuser_name ? { undef => {}, default => { 'DDAGENTUSER_NAME' => $ddagentuser_name}} - $ddagentuser_password_option = ($ddagentuser_name != undef and $ddagentuser_password != undef) ? { true => {'DDAGENTUSER_PASSWORD' => $ddagentuser_password}, false => {}} + $ddagentuser_name_option = $ddagentuser_name ? { undef => {}, default => { 'DDAGENTUSER_NAME' => $ddagentuser_name } } + $ddagentuser_password_option = ($ddagentuser_name != undef and $ddagentuser_password != undef) ? { true => { 'DDAGENTUSER_PASSWORD' => $ddagentuser_password }, false => {} } package { $datadog_agent::params::package_name: ensure => $ensure_version, provider => 'windows', source => $msi_full_path, - install_options => ['/norestart', {'APIKEY' => $api_key, 'TAGS' => $tags_quote_wrap} + $npm_install_option + $hostname_option + $ddagentuser_name_option + $ddagentuser_password_option] + install_options => ['/norestart', { 'APIKEY' => $api_key, 'TAGS' => $tags_quote_wrap } + $npm_install_option + $hostname_option + $ddagentuser_name_option + $ddagentuser_password_option], } - } else { exec { 'datadog_6_14_fix': command => "((New-Object System.Net.WebClient).DownloadFile('https://s3.amazonaws.com/ddagent-windows-stable/scripts/fix_6_14.ps1', \$env:temp + '\\fix_6_14.ps1')); &\$env:temp\\fix_6_14.ps1", @@ -93,6 +92,5 @@ uninstall_options => ['/quiet'], subscribe => Exec['datadog_6_14_fix'], } - } } diff --git a/metadata.json b/metadata.json index 98dfe9587..10b7e5f94 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "datadog-datadog_agent", - "version": "3.24.0", + "version": "4.0.0", "author": "James Turnbull , Rob Terhaar , Jaime Fullaondo , Albert Vaca ", "summary": "Install the Datadog monitoring agent and report Puppet runs to Datadog", "license": "Apache-2.0", @@ -10,31 +10,27 @@ "dependencies": [ { "name": "puppetlabs/stdlib", - "version_requirement": ">=4.25.0 <9.0.0" + "version_requirement": ">=4.25.0 <10.0.0" }, { "name": "puppetlabs/concat", - "version_requirement": ">=4.0.0 <8.0.0" + "version_requirement": ">=4.0.0 <10.0.0" }, { "name": "puppetlabs/apt", - "version_requirement": ">=4.4.0 <9.0.0" - }, - { - "name": "puppetlabs/puppetserver_gem", - "version_requirement": ">=1.0.0 <2.0.0" + "version_requirement": ">=4.4.0 <10.0.0" }, { "name": "puppetlabs/yumrepo_core", - "version_requirement": ">=1.0.3 < 2.0.0" + "version_requirement": ">=1.0.3 < 3.0.0" }, { "name": "puppetlabs/powershell", - "version_requirement": ">=2.3.0 <5.0.0" + "version_requirement": ">=2.3.0 <7.0.0" }, { "name": "puppet/zypprepo", - "version_requirement": ">=3.1.0 <4.0.0" + "version_requirement": ">=3.1.0 <6.0.0" } ], "operatingsystem_support": [ @@ -42,33 +38,41 @@ "operatingsystem": "RedHat", "operatingsystemrelease": [ "6", - "7" + "7", + "8", + "9" ] }, { "operatingsystem": "CentOS", "operatingsystemrelease": [ "6", - "7" + "7", + "8", + "9" ] }, { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "6", - "7" + "7", + "8", + "9" ] }, { "operatingsystem": "AlmaLinux", "operatingsystemrelease": [ - "8" + "8", + "9" ] }, { "operatingsystem": "Rocky", "operatingsystemrelease": [ - "8" + "8", + "9" ] }, { @@ -91,7 +95,13 @@ "26", "27", "28", - "29" + "29", + "30", + "31", + "32", + "33", + "34", + "35" ] }, { @@ -100,7 +110,12 @@ "6", "7", "8", - "9" + "9", + "10", + "11", + "12", + "13", + "14" ] }, { @@ -111,7 +126,10 @@ "17.04", "17.10", "18.04", - "18.10" + "18.10", + "20.04", + "22.04", + "24.04" ] }, { @@ -148,11 +166,11 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">=4.6.0 <8.0.0" + "version_requirement": ">=4.6.0 < 9.0.0" } ], "description": "This will install the Datadog monitoring agent. Sign up and get your API key at: http://www.datadoghq.com", - "pdk-version": "1.15.0", - "template-url": "https://github.com/puppetlabs/pdk-templates#1.15.0", - "template-ref": "tags/1.15.0-0-g0bc522e" + "pdk-version": "3.4.0", + "template-url": "https://github.com/puppetlabs/pdk-templates#3.4.0", + "template-ref": "tags/3.4.0-0-gd3cc13f" } diff --git a/pdk.yaml b/pdk.yaml new file mode 100644 index 000000000..4bef4bd0f --- /dev/null +++ b/pdk.yaml @@ -0,0 +1,2 @@ +--- +ignore: [] diff --git a/spec/classes/datadog_agent_integrations_activemq_xml_spec.rb b/spec/classes/datadog_agent_integrations_activemq_xml_spec.rb index ff5cd0bec..dcb55facd 100644 --- a/spec/classes/datadog_agent_integrations_activemq_xml_spec.rb +++ b/spec/classes/datadog_agent_integrations_activemq_xml_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/activemq_xml.yaml' - else - "#{CONF_DIR}/activemq_xml.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/activemq_xml.d/conf.yaml" context 'with default parameters' do it { is_expected.to compile } @@ -40,7 +36,7 @@ it { is_expected.to contain_file(conf_file) .with_content(%r{http://localhost:8161}) - .with_content(%r{supress_errors: false}) + .with_content(%r{suppress_errors: false}) .without_content(%r{detailed_queues:}) .without_content(%r{detailed_topics:}) .without_content(%r{detailed_subscribers:}) @@ -50,7 +46,7 @@ context 'with extra detailed parameters' do let(:params) do { - supress_errors: true, + suppress_errors: true, detailed_queues: ['queue1', 'queue2'], detailed_topics: ['topic1', 'topic2'], detailed_subscribers: ['subscriber1', 'subscriber2'], @@ -60,7 +56,7 @@ it { is_expected.to contain_file(conf_file) .with_content(%r{http://localhost:8161}) - .with_content(%r{supress_errors: true}) + .with_content(%r{suppress_errors: true}) .with_content(%r{detailed_queues:.*\s+- queue1\s+- queue2}) .with_content(%r{detailed_topics:.*\s+- topic1\s+- topic2}) .with_content(%r{detailed_subscribers:.*\s+- subscriber1\s+- subscriber2}) @@ -94,14 +90,14 @@ it { is_expected.to contain_file(conf_file) .with_content(%r{url: http://localhost:8161}) - .without_content(%r{supress_errors:}) + .without_content(%r{suppress_errors:}) .with_content(%r{username: joe}) .with_content(%r{password: hunter1}) .with_content(%r{detailed_queues:.*\s+- queue1\s+- queue2}) .with_content(%r{detailed_topics:.*\s+- topic1\s+- topic2}) .with_content(%r{detailed_subscribers:.*\s+- subscriber1\s+- subscriber2}) .with_content(%r{url: http://remotehost:8162}) - .without_content(%r{supress_errors:}) + .without_content(%r{suppress_errors:}) .with_content(%r{username: moe}) .with_content(%r{password: hunter2}) .with_content(%r{detailed_queues:.*\s+- queue3\s+- queue4}) diff --git a/spec/classes/datadog_agent_integrations_apache_spec.rb b/spec/classes/datadog_agent_integrations_apache_spec.rb index eef84648e..b2282031e 100644 --- a/spec/classes/datadog_agent_integrations_apache_spec.rb +++ b/spec/classes/datadog_agent_integrations_apache_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/apache.yaml' - else - "#{CONF_DIR}/apache.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/apache.d/conf.yaml" it { is_expected.to compile.with_all_deps } diff --git a/spec/classes/datadog_agent_integrations_cacti_spec.rb b/spec/classes/datadog_agent_integrations_cacti_spec.rb index 02db98133..9cded143d 100644 --- a/spec/classes/datadog_agent_integrations_cacti_spec.rb +++ b/spec/classes/datadog_agent_integrations_cacti_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/cacti.yaml' - else - "#{CONF_DIR}/cacti.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/cacti.d/conf.yaml" context 'with default parameters' do it { is_expected.to compile } diff --git a/spec/classes/datadog_agent_integrations_cassandra_spec.rb b/spec/classes/datadog_agent_integrations_cassandra_spec.rb index 91de455e8..cb3ea59f1 100644 --- a/spec/classes/datadog_agent_integrations_cassandra_spec.rb +++ b/spec/classes/datadog_agent_integrations_cassandra_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/cassandra.yaml' - else - "#{CONF_DIR}/cassandra.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/cassandra.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('datadog_agent') } diff --git a/spec/classes/datadog_agent_integrations_ceph_spec.rb b/spec/classes/datadog_agent_integrations_ceph_spec.rb index add49ee72..59e4c85fe 100644 --- a/spec/classes/datadog_agent_integrations_ceph_spec.rb +++ b/spec/classes/datadog_agent_integrations_ceph_spec.rb @@ -10,11 +10,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/ceph.yaml' - else - "#{CONF_DIR}/ceph.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/ceph.d/conf.yaml" sudo_conf_file = '/etc/sudoers.d/datadog_ceph' diff --git a/spec/classes/datadog_agent_integrations_consul_spec.rb b/spec/classes/datadog_agent_integrations_consul_spec.rb index 50b7a724f..7b44097d3 100644 --- a/spec/classes/datadog_agent_integrations_consul_spec.rb +++ b/spec/classes/datadog_agent_integrations_consul_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/consul.yaml' - else - "#{CONF_DIR}/consul.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/consul.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_directory_spec.rb b/spec/classes/datadog_agent_integrations_directory_spec.rb index 3742e3bd7..e1bd5e22f 100644 --- a/spec/classes/datadog_agent_integrations_directory_spec.rb +++ b/spec/classes/datadog_agent_integrations_directory_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/directory.yaml' - else - "#{CONF_DIR}/directory.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/directory.d/conf.yaml" context 'with default parameters' do it { is_expected.not_to compile } diff --git a/spec/classes/datadog_agent_integrations_disk_spec.rb b/spec/classes/datadog_agent_integrations_disk_spec.rb index 77ee56317..0364b6f28 100644 --- a/spec/classes/datadog_agent_integrations_disk_spec.rb +++ b/spec/classes/datadog_agent_integrations_disk_spec.rb @@ -5,17 +5,22 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/disk.yaml' - else - "#{CONF_DIR}/disk.d/conf.yaml" - end + let(:yaml_conf) do + <<-HEREDOC +### MANAGED BY PUPPET + +init_config: + +instances: + - use_mount: false + HEREDOC + end + + conf_file = "#{CONF_DIR}/disk.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { - is_expected.to contain_file(conf_file).with_content( - %r{\s+use_mount:\s+no[\r]*$}, - ).with( + is_expected.to contain_file(conf_file).with_content(yaml_conf).with( owner: DD_USER, group: DD_GROUP, mode: PERMISSIONS_PROTECTED_FILE, @@ -39,13 +44,13 @@ context 'we handle strings and arrays the same' do let(:params) do { - use_mount: 'yes', + use_mount: true, excluded_filesystems: ['tmpfs', 'dev'], excluded_disks: '/dev/sda1', excluded_disk_re: '/dev/sdb.*', excluded_mountpoint_re: '/mnt/other.*', - all_partitions: 'yes', - tag_by_filesystem: 'no', + all_partitions: true, + tag_by_filesystem: false, } end let(:yaml_conf) do @@ -55,7 +60,7 @@ init_config: instances: - - use_mount: yes + - use_mount: true excluded_filesystems: - tmpfs - dev @@ -63,8 +68,8 @@ - /dev/sda1 excluded_disk_re: /dev/sdb.* excluded_mountpoint_re: /mnt/other.* - all_partitions: yes - tag_by_filesystem: no + all_partitions: true + tag_by_filesystem: false HEREDOC end @@ -74,15 +79,15 @@ context 'we handle new disk configuration option' do let(:params) do { - use_mount: 'yes', + use_mount: true, filesystem_blacklist: ['tmpfs', 'dev'], device_blacklist: ['/dev/sda1'], mountpoint_blacklist: ['/mnt/foo'], filesystem_whitelist: ['ext4', 'hdfs', 'reiserfs'], device_whitelist: ['/dev/sdc1', '/dev/sdc2', '/dev/sdd2'], mountpoint_whitelist: ['/mnt/logs', '/mnt/builds'], - all_partitions: 'yes', - tag_by_filesystem: 'no', + all_partitions: true, + tag_by_filesystem: false, } end let(:yaml_conf) do @@ -92,7 +97,7 @@ init_config: instances: - - use_mount: yes + - use_mount: true file_system_blacklist: - tmpfs - dev @@ -111,8 +116,8 @@ mount_point_whitelist: - /mnt/logs - /mnt/builds - all_partitions: yes - tag_by_filesystem: no + all_partitions: true + tag_by_filesystem: false HEREDOC end @@ -122,15 +127,15 @@ context 'agent_version >= 7.24.0 disk configuration option' do let(:params) do { - use_mount: 'yes', + use_mount: true, filesystem_exclude: ['tmpfs', 'dev'], device_exclude: ['/dev/sda1'], mountpoint_exclude: ['/mnt/foo'], filesystem_include: ['ext4', 'hdfs', 'reiserfs'], device_include: ['/dev/sdc1', '/dev/sdc2', '/dev/sdd2'], mountpoint_include: ['/mnt/logs', '/mnt/builds'], - all_partitions: 'yes', - tag_by_filesystem: 'no', + all_partitions: true, + tag_by_filesystem: false, } end let(:yaml_conf) do @@ -140,7 +145,7 @@ init_config: instances: - - use_mount: yes + - use_mount: true file_system_exclude: - tmpfs - dev @@ -159,8 +164,8 @@ mount_point_include: - /mnt/logs - /mnt/builds - all_partitions: yes - tag_by_filesystem: no + all_partitions: true + tag_by_filesystem: false HEREDOC end diff --git a/spec/classes/datadog_agent_integrations_dns_check_spec.rb b/spec/classes/datadog_agent_integrations_dns_check_spec.rb index fbcfcdada..298c8cbc5 100644 --- a/spec/classes/datadog_agent_integrations_dns_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_dns_check_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/dns_check.yaml' - else - "#{CONF_DIR}/dns_check.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/dns_check.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb b/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb index 17fd36037..75d991d34 100644 --- a/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb +++ b/spec/classes/datadog_agent_integrations_docker_daemon_spec.rb @@ -10,11 +10,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/docker_daemon.yaml' - else - "#{CONF_DIR}/docker.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/docker.d/conf.yaml" it { is_expected.to compile.with_all_deps } @@ -72,16 +68,6 @@ it { is_expected.to contain_file(conf_file).with_content(%r{tags: \[\]}) } end - - context 'single value empty string' do - let(:params) do - { - tags: '', - } - end - - it { is_expected.to contain_file(conf_file).with_content(%r{tags: \[\]}) } - end end end end diff --git a/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb b/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb index 283201ba9..1ad42e22f 100644 --- a/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb +++ b/spec/classes/datadog_agent_integrations_elasticsearch_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/elastic.yaml' - else - "#{CONF_DIR}/elastic.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/elastic.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { @@ -31,9 +27,12 @@ it { is_expected.to contain_file(conf_file).with_content(%r{ pshard_stats: false}) } it { is_expected.not_to contain_file(conf_file).with_content(%r{ username}) } it { is_expected.not_to contain_file(conf_file).with_content(%r{ password}) } - it { is_expected.not_to contain_file(conf_file).with_content(%r{ ssl_verify}) } - it { is_expected.not_to contain_file(conf_file).with_content(%r{ ssl_cert}) } - it { is_expected.not_to contain_file(conf_file).with_content(%r{ ssl_key}) } + it { is_expected.not_to contain_file(conf_file).with_content(%r{ tls_verify}) } + it { is_expected.not_to contain_file(conf_file).with_content(%r{ tls_cert}) } + it { is_expected.not_to contain_file(conf_file).with_content(%r{ tls_ca_cert}) } + it { is_expected.not_to contain_file(conf_file).with_content(%r{ tls_private_key}) } + it { is_expected.not_to contain_file(conf_file).with_content(%r{ tls_use_host_header}) } + it { is_expected.not_to contain_file(conf_file).with_content(%r{ tls_ignore_warning}) } it { is_expected.not_to contain_file(conf_file).with_content(%r{ tags:}) } end @@ -44,9 +43,14 @@ pending_task_stats: false, url: 'https://foo:4242', username: 'username', - ssl_cert: '/etc/ssl/certs/client.pem', - ssl_key: '/etc/ssl/private/client.key', - tags: ['tag1:key1'], + tls_cert: '/etc/ssl/certs/client.pem', + tls_ca_cert: '/etc/ssl/certs/ca.pem', + tls_private_key: '/etc/ssl/private/client.key', + tls_use_host_header: true, + tls_ignore_warning: true, + tls_protocols_allowed: ['TLSv1.2', 'TLSv1.3'], + tls_ciphers: ['TLS_AES_256_GCM_SHA384', 'TLS_CHACHA20_POLY1305_SHA256'], + tags: ['tag1:key1'], } end @@ -54,11 +58,20 @@ it { is_expected.to contain_file(conf_file).with_content(%r{ pending_task_stats: false}) } it { is_expected.to contain_file(conf_file).with_content(%r{ username: username}) } it { is_expected.to contain_file(conf_file).with_content(%r{ password: password}) } - it { is_expected.to contain_file(conf_file).with_content(%r{ ssl_verify: true}) } - it { is_expected.to contain_file(conf_file).with_content(%r{ ssl_cert: /etc/ssl/certs/client.pem}) } - it { is_expected.to contain_file(conf_file).with_content(%r{ ssl_key: /etc/ssl/private/client.key}) } it { is_expected.to contain_file(conf_file).with_content(%r{ tags:}) } it { is_expected.to contain_file(conf_file).with_content(%r{ - tag1:key1}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_verify: true}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_cert: /etc/ssl/certs/client.pem}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_ca_cert: /etc/ssl/certs/ca.pem}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_private_key: /etc/ssl/private/client.key}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_use_host_header: true}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_ignore_warning: true}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_protocols_allowed:}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ - TLSv1.2}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ - TLSv1.3}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_ciphers:}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ - TLS_AES_256_GCM_SHA384}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ - TLS_CHACHA20_POLY1305_SHA256}) } end context 'with multiple instances set' do @@ -73,9 +86,9 @@ 'pshard_stats' => true, 'url' => 'https://foo:4242', 'username' => 'username', - 'ssl_verify' => true, - 'ssl_cert' => '/etc/ssl/certs/client.pem', - 'ssl_key' => '/etc/ssl/private/client.key', + 'tls_verify' => true, + 'tls_cert' => '/etc/ssl/certs/client.pem', + 'tls_private_key' => '/etc/ssl/private/client.key', 'tags' => ['tag1:key1'], }, { @@ -86,8 +99,12 @@ 'pshard_stats' => false, 'url' => 'https://bar:2424', 'username' => 'username_2', - 'ssl_verify' => false, + 'tls_verify' => false, 'tags' => ['tag2:key2'], + 'tls_use_host_header' => true, + 'tls_ignore_warning' => true, + 'tls_protocols_allowed' => ['TLSv1.2', 'TLSv1.3'], + 'tls_ciphers' => ['TLS_AES_256_GCM_SHA384', 'TLS_CHACHA20_POLY1305_SHA256'], }, ], } @@ -101,9 +118,9 @@ it { is_expected.to contain_file(conf_file).with_content(%r{ username: username}) } it { is_expected.to contain_file(conf_file).with_content(%r{ password: password}) } it { is_expected.to contain_file(conf_file).with_content(%r{ pshard_stats: true}) } - it { is_expected.to contain_file(conf_file).with_content(%r{ ssl_verify: true}) } - it { is_expected.to contain_file(conf_file).with_content(%r{ ssl_cert: /etc/ssl/certs/client.pem}) } - it { is_expected.to contain_file(conf_file).with_content(%r{ ssl_key: /etc/ssl/private/client.key}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_verify: true}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_cert: /etc/ssl/certs/client.pem}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_private_key: /etc/ssl/private/client.key}) } it { is_expected.to contain_file(conf_file).with_content(%r{ tags:\n - tag1:key1}) } it { is_expected.to contain_file(conf_file).with_content(%r{ - url: https://bar:2424}) } it { is_expected.to contain_file(conf_file).with_content(%r{ cluster_stats: false}) } @@ -112,8 +129,40 @@ it { is_expected.to contain_file(conf_file).with_content(%r{ username: username_2}) } it { is_expected.to contain_file(conf_file).with_content(%r{ password: password_2}) } it { is_expected.to contain_file(conf_file).with_content(%r{ pshard_stats: false}) } - it { is_expected.to contain_file(conf_file).with_content(%r{ ssl_verify: false}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_verify: false}) } it { is_expected.to contain_file(conf_file).with_content(%r{ tags:\n - tag2:key2}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_use_host_header: true}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_ignore_warning: true}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_protocols_allowed:}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ - TLSv1.2}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ - TLSv1.3}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_ciphers:}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ - TLS_AES_256_GCM_SHA384}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ - TLS_CHACHA20_POLY1305_SHA256}) } + end + + context 'with legacy ssl_verify parameter set' do + let(:params) do + { + password: 'password', + url: 'https://foo:4242', + username: 'username', + ssl_verify: true, + tls_cert: '/etc/ssl/certs/client.pem', + tls_ca_cert: '/etc/ssl/certs/ca.pem', + tls_private_key: '/etc/ssl/private/client.key', + } + end + + it { is_expected.to contain_file(conf_file).with_content(%r{instances:}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ - url: https://foo:4242}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ cluster_stats: false}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ index_stats: false}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ pending_task_stats: true}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ pshard_stats: false}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_verify: true}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_cert: /etc/ssl/certs/client.pem}) } + it { is_expected.to contain_file(conf_file).with_content(%r{ tls_private_key: /etc/ssl/private/client.key}) } end end end diff --git a/spec/classes/datadog_agent_integrations_fluentd_spec.rb b/spec/classes/datadog_agent_integrations_fluentd_spec.rb index 40996438c..119df625f 100644 --- a/spec/classes/datadog_agent_integrations_fluentd_spec.rb +++ b/spec/classes/datadog_agent_integrations_fluentd_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/fluentd.yaml' - else - "#{CONF_DIR}/fluentd.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/fluentd.d/conf.yaml" context 'with default parameters' do it { is_expected.to compile } diff --git a/spec/classes/datadog_agent_integrations_haproxy_spec.rb b/spec/classes/datadog_agent_integrations_haproxy_spec.rb index cd03c8a5a..1c9d4d091 100644 --- a/spec/classes/datadog_agent_integrations_haproxy_spec.rb +++ b/spec/classes/datadog_agent_integrations_haproxy_spec.rb @@ -10,11 +10,7 @@ } end - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/haproxy.yaml' - else - "#{CONF_DIR}/haproxy.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/haproxy.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_http_check_spec.rb b/spec/classes/datadog_agent_integrations_http_check_spec.rb index c0eeeb82c..450a842da 100644 --- a/spec/classes/datadog_agent_integrations_http_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_http_check_spec.rb @@ -4,12 +4,14 @@ ALL_SUPPORTED_AGENTS.each do |agent_major_version| context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + let(:params) do + { + sitename: 'foo.bar.baz', + url: 'http://foo.bar.baz:4096', + } + end - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/http_check.yaml' - else - "#{CONF_DIR}/http_check.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/http_check.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { @@ -23,23 +25,28 @@ it { is_expected.to contain_file(conf_file).that_notifies("Service[#{SERVICE_NAME}]") } context 'with default parameters' do - it { is_expected.to contain_file(conf_file).without_content(%r{name: }) } - it { is_expected.to contain_file(conf_file).without_content(%r{url: }) } + let(:params) do + { + sitename: 'foo.bar.baz', + url: 'http://foo.bar.baz:4096', + } + end + it { is_expected.to contain_file(conf_file).without_content(%r{username: }) } it { is_expected.to contain_file(conf_file).without_content(%r{password: }) } - it { is_expected.to contain_file(conf_file).without_content(%r{timeout: 1}) } + it { is_expected.to contain_file(conf_file).with_content(%r{timeout: 1}) } # default value is 1 it { is_expected.to contain_file(conf_file).without_content(%r{data: }) } it { is_expected.to contain_file(conf_file).without_content(%(threshold: )) } it { is_expected.to contain_file(conf_file).without_content(%r{window: }) } it { is_expected.to contain_file(conf_file).without_content(%r{content_match: }) } - it { is_expected.to contain_file(conf_file).without_content(%r{reverse_content_match: true}) } + it { is_expected.to contain_file(conf_file).without_content(%r{reverse_content_match: false}) } it { is_expected.to contain_file(conf_file).without_content(%r{include_content: true}) } - it { is_expected.to contain_file(conf_file).without_content(%r{collect_response_time: true}) } + it { is_expected.to contain_file(conf_file).with_content(%r{collect_response_time: true}) } # default value is true it { is_expected.to contain_file(conf_file).without_content(%r{http_response_status_code: }) } - it { is_expected.to contain_file(conf_file).without_content(%r{disable_ssl_validation: false}) } - it { is_expected.to contain_file(conf_file).without_content(%r{skip_event: }) } - it { is_expected.to contain_file(conf_file).without_content(%r{no_proxy: }) } - it { is_expected.to contain_file(conf_file).without_content(%r{check_certificate_expiration: }) } + it { is_expected.to contain_file(conf_file).with_content(%r{disable_ssl_validation: false}) } # default value is false + it { is_expected.to contain_file(conf_file).with_content(%r{skip_event: true}) } # default value is true + it { is_expected.to contain_file(conf_file).with_content(%r{no_proxy: false}) } # default value is false + it { is_expected.to contain_file(conf_file).with_content(%r{check_certificate_expiration: true}) } # default value is true it { is_expected.to contain_file(conf_file).without_content(%r{days_warning: }) } it { is_expected.to contain_file(conf_file).without_content(%r{days_critical: }) } it { is_expected.to contain_file(conf_file).without_content(%r{headers: }) } diff --git a/spec/classes/datadog_agent_integrations_jenkins_spec.rb b/spec/classes/datadog_agent_integrations_jenkins_spec.rb deleted file mode 100644 index 53f981b8b..000000000 --- a/spec/classes/datadog_agent_integrations_jenkins_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'spec_helper' - -describe 'datadog_agent::integrations::jenkins' do - ALL_SUPPORTED_AGENTS.each do |agent_major_version| - context 'supported agents' do - let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/jenkins.yaml' - else - "#{CONF_DIR}/jenkins.d/conf.yaml" - end - - it { is_expected.to compile.with_all_deps } - it { - is_expected.to contain_file(conf_file).with( - owner: DD_USER, - group: DD_GROUP, - mode: PERMISSIONS_PROTECTED_FILE, - ) - } - it { is_expected.to contain_file(conf_file).that_requires("Package[#{PACKAGE_NAME}]") } - it { is_expected.to contain_file(conf_file).that_notifies("Service[#{SERVICE_NAME}]") } - - context 'with default parameters' do - it { is_expected.to contain_file(conf_file).with_content(%r{jenkins_home: /var/lib/jenkins}) } - end - - context 'with parameters set' do - let(:params) do - { - path: '/foo/bar/baz', - } - end - - it { is_expected.to contain_file(conf_file).with_content(%r{jenkins_home: /foo/bar/baz}) } - end - end - end -end diff --git a/spec/classes/datadog_agent_integrations_jmx_spec.rb b/spec/classes/datadog_agent_integrations_jmx_spec.rb index 49765a12c..512c40ad9 100644 --- a/spec/classes/datadog_agent_integrations_jmx_spec.rb +++ b/spec/classes/datadog_agent_integrations_jmx_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/jmx.yaml' - else - "#{CONF_DIR}/jmx.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/jmx.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_kafka_spec.rb b/spec/classes/datadog_agent_integrations_kafka_spec.rb index 1c32579a3..fdeacea2d 100644 --- a/spec/classes/datadog_agent_integrations_kafka_spec.rb +++ b/spec/classes/datadog_agent_integrations_kafka_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/kafka.yaml' - else - "#{CONF_DIR}/kafka.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/kafka.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_kong_spec.rb b/spec/classes/datadog_agent_integrations_kong_spec.rb index 767051db9..c00215650 100644 --- a/spec/classes/datadog_agent_integrations_kong_spec.rb +++ b/spec/classes/datadog_agent_integrations_kong_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/kong.yaml' - else - "#{CONF_DIR}/kong.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/kong.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_kubernetes_spec.rb b/spec/classes/datadog_agent_integrations_kubernetes_spec.rb index 300a83186..287191337 100644 --- a/spec/classes/datadog_agent_integrations_kubernetes_spec.rb +++ b/spec/classes/datadog_agent_integrations_kubernetes_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/kubernetes.yaml' - else - "#{CONF_DIR}/kubernetes.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/kubernetes.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb b/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb index efea143f0..138868ae5 100644 --- a/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb +++ b/spec/classes/datadog_agent_integrations_kubernetes_state_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/kubernetes_state.yaml' - else - "#{CONF_DIR}/kubernetes_state.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/kubernetes_state.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_marathon_spec.rb b/spec/classes/datadog_agent_integrations_marathon_spec.rb index 207a1731f..24035aaa3 100644 --- a/spec/classes/datadog_agent_integrations_marathon_spec.rb +++ b/spec/classes/datadog_agent_integrations_marathon_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/marathon.yaml' - else - "#{CONF_DIR}/marathon.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/marathon.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_memcache_spec.rb b/spec/classes/datadog_agent_integrations_memcache_spec.rb index 9514a931c..f141c880b 100644 --- a/spec/classes/datadog_agent_integrations_memcache_spec.rb +++ b/spec/classes/datadog_agent_integrations_memcache_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/mcache.yaml' - else - "#{CONF_DIR}/mcache.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/mcache.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_mesos_master_spec.rb b/spec/classes/datadog_agent_integrations_mesos_master_spec.rb index d4db54e42..9861aa3b2 100644 --- a/spec/classes/datadog_agent_integrations_mesos_master_spec.rb +++ b/spec/classes/datadog_agent_integrations_mesos_master_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/mesos_master.yaml' - else - "#{CONF_DIR}/mesos_master.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/mesos_master.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_mongo_spec.rb b/spec/classes/datadog_agent_integrations_mongo_spec.rb index 528da0d26..e45eb4cc0 100644 --- a/spec/classes/datadog_agent_integrations_mongo_spec.rb +++ b/spec/classes/datadog_agent_integrations_mongo_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/mongo.yaml' - else - "#{CONF_DIR}/mongo.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/mongo.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_mysql_spec.rb b/spec/classes/datadog_agent_integrations_mysql_spec.rb index 74c86804a..5c31f72d0 100644 --- a/spec/classes/datadog_agent_integrations_mysql_spec.rb +++ b/spec/classes/datadog_agent_integrations_mysql_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/mysql.yaml' - else - "#{CONF_DIR}/mysql.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/mysql.d/conf.yaml" context 'with default parameters' do it { is_expected.to compile } diff --git a/spec/classes/datadog_agent_integrations_network_spec.rb b/spec/classes/datadog_agent_integrations_network_spec.rb index b432eed58..fb1439096 100644 --- a/spec/classes/datadog_agent_integrations_network_spec.rb +++ b/spec/classes/datadog_agent_integrations_network_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/network.yaml' - else - "#{CONF_DIR}/network.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/network.d/conf.yaml" context 'with default parameters' do it { is_expected.to compile } diff --git a/spec/classes/datadog_agent_integrations_nginx_spec.rb b/spec/classes/datadog_agent_integrations_nginx_spec.rb index b25a40281..2bb7de38e 100644 --- a/spec/classes/datadog_agent_integrations_nginx_spec.rb +++ b/spec/classes/datadog_agent_integrations_nginx_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/nginx.yaml' - else - "#{CONF_DIR}/nginx.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/nginx.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_ntp_spec.rb b/spec/classes/datadog_agent_integrations_ntp_spec.rb index 2b98a253b..1cd38d192 100644 --- a/spec/classes/datadog_agent_integrations_ntp_spec.rb +++ b/spec/classes/datadog_agent_integrations_ntp_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/ntp.yaml' - else - "#{CONF_DIR}/ntp.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/ntp.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb b/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb index c52ae9b03..0c2eabea6 100644 --- a/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb +++ b/spec/classes/datadog_agent_integrations_pgbouncer_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/pgbouncer.yaml' - else - "#{CONF_DIR}/pgbouncer.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/pgbouncer.d/conf.yaml" context 'with default parameters' do let(:params) do diff --git a/spec/classes/datadog_agent_integrations_php_fpm_spec.rb b/spec/classes/datadog_agent_integrations_php_fpm_spec.rb index f95e8e38f..f3c8c636e 100644 --- a/spec/classes/datadog_agent_integrations_php_fpm_spec.rb +++ b/spec/classes/datadog_agent_integrations_php_fpm_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/php_fpm.yaml' - else - "#{CONF_DIR}/php_fpm.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/php_fpm.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_postfix_spec.rb b/spec/classes/datadog_agent_integrations_postfix_spec.rb index 9656e5032..7c77a9330 100644 --- a/spec/classes/datadog_agent_integrations_postfix_spec.rb +++ b/spec/classes/datadog_agent_integrations_postfix_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/postfix.yaml' - else - "#{CONF_DIR}/postfix.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/postfix.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_postgres_spec.rb b/spec/classes/datadog_agent_integrations_postgres_spec.rb index c1d065f71..975bbec55 100644 --- a/spec/classes/datadog_agent_integrations_postgres_spec.rb +++ b/spec/classes/datadog_agent_integrations_postgres_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/postgres.yaml' - else - "#{CONF_DIR}/postgres.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/postgres.d/conf.yaml" context 'with default parameters' do it { is_expected.to compile } diff --git a/spec/classes/datadog_agent_integrations_process_spec.rb b/spec/classes/datadog_agent_integrations_process_spec.rb index 8195a0d3d..88d29635e 100644 --- a/spec/classes/datadog_agent_integrations_process_spec.rb +++ b/spec/classes/datadog_agent_integrations_process_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/process.yaml' - else - "#{CONF_DIR}/process.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/process.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb b/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb index e1f479019..bf54edef7 100644 --- a/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb +++ b/spec/classes/datadog_agent_integrations_rabbitmq_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/rabbitmq.yaml' - else - "#{CONF_DIR}/rabbitmq.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/rabbitmq.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_redis_spec.rb b/spec/classes/datadog_agent_integrations_redis_spec.rb index 8f710846b..bf66c1867 100644 --- a/spec/classes/datadog_agent_integrations_redis_spec.rb +++ b/spec/classes/datadog_agent_integrations_redis_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/redisdb.yaml' - else - "#{CONF_DIR}/redisdb.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/redisdb.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_riak_spec.rb b/spec/classes/datadog_agent_integrations_riak_spec.rb index c15c0f6e1..df2c2667f 100644 --- a/spec/classes/datadog_agent_integrations_riak_spec.rb +++ b/spec/classes/datadog_agent_integrations_riak_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/riak.yaml' - else - "#{CONF_DIR}/riak.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/riak.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_snmp_spec.rb b/spec/classes/datadog_agent_integrations_snmp_spec.rb index d3c4da03e..e0510d8a8 100644 --- a/spec/classes/datadog_agent_integrations_snmp_spec.rb +++ b/spec/classes/datadog_agent_integrations_snmp_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/snmp.yaml' - else - "#{CONF_DIR}/snmp.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/snmp.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { @@ -30,34 +26,36 @@ let(:params) do { ignore_nonincreasing_oid: true, - instances: { - ip_address: 'localhost', - port: 161, - community_string: 'public', - tags: [ - 'optional_tag_1', - ], - metrics: [ - { - MIB: 'IF-MIB', - table: 'ifTable', - symbols: [ - 'ifInOctets', - 'ifOutOctets', - ], - metric_tags: [ - { - tag: 'interface', - column: 'ifDescr', - }, - { - tag: 'interface_index', - column: 'ifIndex', - }, - ], - }, - ], - }, + instances: [ + { + ip_address: 'localhost', + port: 161, + community_string: 'public', + tags: [ + 'optional_tag_1', + ], + metrics: [ + { + MIB: 'IF-MIB', + table: 'ifTable', + symbols: [ + 'ifInOctets', + 'ifOutOctets', + ], + metric_tags: [ + { + tag: 'interface', + column: 'ifDescr', + }, + { + tag: 'interface_index', + column: 'ifIndex', + }, + ], + }, + ], + }, + ] } end @@ -69,8 +67,8 @@ expect(yaml).to include('init_config') expect(yaml['init_config']).to include('ignore_nonincreasing_oid') expect(yaml).to include('instances') - expect(yaml['instances']).to include('tags') - expect(yaml['instances']['tags']).to include('optional_tag_1') + expect(yaml['instances'][0]).to include('tags') + expect(yaml['instances'][0]['tags']).to include('optional_tag_1') end end end diff --git a/spec/classes/datadog_agent_integrations_solr_spec.rb b/spec/classes/datadog_agent_integrations_solr_spec.rb index d14ac4edd..c5ad2b42f 100644 --- a/spec/classes/datadog_agent_integrations_solr_spec.rb +++ b/spec/classes/datadog_agent_integrations_solr_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/solr.yaml' - else - "#{CONF_DIR}/solr.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/solr.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_ssh_spec.rb b/spec/classes/datadog_agent_integrations_ssh_spec.rb index 70551a65e..22e350623 100644 --- a/spec/classes/datadog_agent_integrations_ssh_spec.rb +++ b/spec/classes/datadog_agent_integrations_ssh_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/ssh.yaml' - else - "#{CONF_DIR}/ssh_check.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/ssh_check.d/conf.yaml" context 'with default parameters' do it { is_expected.to compile } diff --git a/spec/classes/datadog_agent_integrations_supervisrd_spec.rb b/spec/classes/datadog_agent_integrations_supervisrd_spec.rb index 1dc5e4685..97185ba13 100644 --- a/spec/classes/datadog_agent_integrations_supervisrd_spec.rb +++ b/spec/classes/datadog_agent_integrations_supervisrd_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/supervisord.yaml' - else - "#{CONF_DIR}/supervisord.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/supervisord.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_system_core_spec.rb b/spec/classes/datadog_agent_integrations_system_core_spec.rb index 1ed0dd9ea..6942495be 100644 --- a/spec/classes/datadog_agent_integrations_system_core_spec.rb +++ b/spec/classes/datadog_agent_integrations_system_core_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/system_core.yaml' - else - "#{CONF_DIR}/system_core.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/system_core.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_tcp_check_spec.rb b/spec/classes/datadog_agent_integrations_tcp_check_spec.rb index b91f8fb1a..d17838678 100644 --- a/spec/classes/datadog_agent_integrations_tcp_check_spec.rb +++ b/spec/classes/datadog_agent_integrations_tcp_check_spec.rb @@ -4,12 +4,15 @@ ALL_SUPPORTED_AGENTS.each do |agent_major_version| context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } + let(:params) do + { + check_name: 'foo.bar.baz', + host: 'foo.bar.baz', + port: '80' + } + end - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/tcp_check.yaml' - else - "#{CONF_DIR}/tcp_check.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/tcp_check.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { @@ -23,14 +26,21 @@ it { is_expected.to contain_file(conf_file).that_notifies("Service[#{SERVICE_NAME}]") } context 'with default parameters' do - it { is_expected.to contain_file(conf_file).without_content(%r{name: }) } - it { is_expected.to contain_file(conf_file).without_content(%r{host: }) } - it { is_expected.to contain_file(conf_file).without_content(%r{port: }) } - it { is_expected.to contain_file(conf_file).without_content(%r{timeout: 1}) } + let(:params) do + { + check_name: 'foo.bar.baz', + host: 'foo.bar.baz', + port: '80' + } + end + + it { is_expected.to contain_file(conf_file).with_content(%r{name: }) } + it { is_expected.to contain_file(conf_file).with_content(%r{host: }) } + it { is_expected.to contain_file(conf_file).with_content(%r{port: }) } + it { is_expected.to contain_file(conf_file).with_content(%r{timeout: 10}) } # default value is 10 it { is_expected.to contain_file(conf_file).without_content(%(threshold: )) } it { is_expected.to contain_file(conf_file).without_content(%r{window: }) } it { is_expected.to contain_file(conf_file).without_content(%r{collect_response_time: }) } - it { is_expected.to contain_file(conf_file).without_content(%r{skip_event: }) } it { is_expected.to contain_file(conf_file).without_content(%r{tags: }) } end @@ -44,7 +54,6 @@ threshold: 456, window: 789, collect_response_time: true, - skip_event: true, } end @@ -55,7 +64,6 @@ it { is_expected.to contain_file(conf_file).with_content(%r{threshold: 456}) } it { is_expected.to contain_file(conf_file).with_content(%r{window: 789}) } it { is_expected.to contain_file(conf_file).with_content(%r{collect_response_time: true}) } - it { is_expected.to contain_file(conf_file).with_content(%r{skip_event: true}) } end context 'with tags parameter array' do diff --git a/spec/classes/datadog_agent_integrations_tomcat_spec.rb b/spec/classes/datadog_agent_integrations_tomcat_spec.rb index 0a3105ec9..2057f50f7 100644 --- a/spec/classes/datadog_agent_integrations_tomcat_spec.rb +++ b/spec/classes/datadog_agent_integrations_tomcat_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/tomcat.yaml' - else - "#{CONF_DIR}/tomcat.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/tomcat.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_twemproxy_spec.rb b/spec/classes/datadog_agent_integrations_twemproxy_spec.rb index fa3f24c60..7a86ed703 100644 --- a/spec/classes/datadog_agent_integrations_twemproxy_spec.rb +++ b/spec/classes/datadog_agent_integrations_twemproxy_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/twemproxy.yaml' - else - "#{CONF_DIR}/twemproxy.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/twemproxy.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_varnish_spec.rb b/spec/classes/datadog_agent_integrations_varnish_spec.rb index f5c3888ac..9273a7bca 100644 --- a/spec/classes/datadog_agent_integrations_varnish_spec.rb +++ b/spec/classes/datadog_agent_integrations_varnish_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/varnish.yaml' - else - "#{CONF_DIR}/varnish.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/varnish.d/conf.yaml" it { is_expected.to compile.with_all_deps } it { diff --git a/spec/classes/datadog_agent_integrations_zk_spec.rb b/spec/classes/datadog_agent_integrations_zk_spec.rb index 332089afe..55fbb462c 100644 --- a/spec/classes/datadog_agent_integrations_zk_spec.rb +++ b/spec/classes/datadog_agent_integrations_zk_spec.rb @@ -5,11 +5,7 @@ context 'supported agents' do let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } - conf_file = if agent_major_version == 5 - '/etc/dd-agent/conf.d/zk.yaml' - else - "#{CONF_DIR}/zk.d/conf.yaml" - end + conf_file = "#{CONF_DIR}/zk.d/conf.yaml" it { is_expected.to compile.with_all_deps } diff --git a/spec/classes/datadog_agent_redhat_spec.rb b/spec/classes/datadog_agent_redhat_spec.rb index 2c4ea4da7..c469717f7 100644 --- a/spec/classes/datadog_agent_redhat_spec.rb +++ b/spec/classes/datadog_agent_redhat_spec.rb @@ -1,66 +1,6 @@ require 'spec_helper' describe 'datadog_agent::redhat' do - context 'agent 5' do - if RSpec::Support::OS.windows? - return - end - - let(:facts) do - { - os: { - 'architecture' => 'x86_64', - 'family' => 'redhat', - 'name' => 'Fedora', - 'release' => { - 'major' => '36', - 'full' => '36', - }, - }, - } - end - - # it should install the mirror - context 'with manage_repo => true' do - let(:params) do - { - manage_repo: true, - agent_major_version: 5, - } - end - - it do - is_expected.to contain_yumrepo('datadog') - .with_enabled(1)\ - .with_gpgcheck(1)\ - .with_gpgkey('https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public - https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public - https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public - https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public')\ - .with_baseurl('https://yum.datadoghq.com/rpm/x86_64/')\ - .with_repo_gpgcheck(false) - end - end - context 'with manage_repo => false' do - let(:params) do - { - manage_repo: false, agent_major_version: 5 - } - end - - it do - is_expected.not_to contain_yumrepo('datadog') - is_expected.not_to contain_yumrepo('datadog5') - is_expected.not_to contain_yumrepo('datadog6') - end - end - # it should install the packages - it do - is_expected.to contain_package('datadog-agent')\ - .with_ensure('latest') - end - end - context 'agent 6' do let(:facts) do { diff --git a/spec/classes/datadog_agent_reports_spec.rb b/spec/classes/datadog_agent_reports_spec.rb index a88c20418..1ef0ec645 100644 --- a/spec/classes/datadog_agent_reports_spec.rb +++ b/spec/classes/datadog_agent_reports_spec.rb @@ -28,6 +28,9 @@ 'major' => getosmajor(operatingsystem), 'full' => getosrelease(operatingsystem), }, + 'distro' => { + 'codename' => getoscodename(operatingsystem), + } }, } end @@ -95,6 +98,9 @@ 'major' => '8', 'full' => '8.1', }, + 'distro' => { + 'codename' => 'jessie', + } }, } end @@ -144,6 +150,9 @@ 'major' => '8', 'full' => '8.1', }, + 'distro' => { + 'codename' => 'jessie', + } }, } end @@ -188,6 +197,9 @@ 'major' => '8', 'full' => '8.1', }, + 'distro' => { + 'codename' => 'jessie', + } }, } end @@ -234,6 +246,9 @@ 'major' => '8', 'full' => '8.1', }, + 'distro' => { + 'codename' => 'jessie', + } }, } end diff --git a/spec/classes/datadog_agent_spec.rb b/spec/classes/datadog_agent_spec.rb index d765197e8..a874bfb5c 100644 --- a/spec/classes/datadog_agent_spec.rb +++ b/spec/classes/datadog_agent_spec.rb @@ -14,6 +14,9 @@ 'major' => '3', 'full' => '3.0', }, + 'distro' => { + 'codename' => 'nexenta', + } }, } end @@ -42,13 +45,17 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end it do - is_expected.to contain_file('/etc/apt/sources.list.d/datadog.list')\ - .with_content(%r{deb\s+\[signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg\]\s+https://apt.datadoghq.com/\s+stable\s+main}) + expect { + is_expected.to contain_package('module') + }.to raise_error(Puppet::Error, %r{agent_major_version must be either 6 or 7, not 5}) end end @@ -68,6 +75,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end @@ -94,6 +104,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end @@ -120,6 +133,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end @@ -146,6 +162,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end @@ -172,6 +191,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end @@ -198,6 +220,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end @@ -226,6 +251,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + }, }, } end @@ -304,6 +332,9 @@ 'major' => getosmajor(operatingsystem), 'full' => getosrelease(operatingsystem), }, + 'distro' => { + 'code' => getoscodename(operatingsystem), + } }, } end @@ -336,1366 +367,6 @@ end end - describe "datadog_agent 5 class common actions on #{operatingsystem}" do - let(:params) do - { - puppet_run_reports: true, - agent_major_version: 5, - } - end - let(:facts) do - { - os: { - 'architecture' => 'x86_64', - 'family' => getosfamily(operatingsystem), - 'name' => operatingsystem, - 'release' => { - 'major' => getosmajor(operatingsystem), - 'full' => getosrelease(operatingsystem), - }, - }, - } - end - - if WINDOWS_OS.include?(operatingsystem) - it 'agent 5 should raise on Windows' do - is_expected.to raise_error(Puppet::Error, %r{Installation of agent 5 with puppet is not supported on Windows}) - end - else - it { is_expected.to compile.with_all_deps } - - it { is_expected.to contain_class('datadog_agent') } - - describe 'datadog_agent imports the default params' do - it { is_expected.to contain_class('datadog_agent::params') } - end - - it { is_expected.to contain_file('/etc/datadog-agent') } - it { is_expected.to contain_file('/etc/dd-agent') } - it { is_expected.to contain_concat('/etc/dd-agent/datadog.conf') } - it { is_expected.to contain_file('/etc/dd-agent/conf.d').with_ensure('directory') } - - it { is_expected.to contain_class('datadog_agent::reports') } - - describe 'parameter check' do - context 'with defaults' do - context 'for proxy' do - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{dd_url: https://app.datadoghq.com\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# proxy_host:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# proxy_port:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# proxy_user:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# proxy_password:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# skip_ssl_validation: no\n}, - ) - } - end - - context 'for general' do - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^api_key: your_API_key\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^# hostname:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^non_local_traffic: false\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^collect_ec2_tags: false\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^collect_instance_metadata: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# recent_point_threshold: 30\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# listen_port: 17123\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# graphite_listen_port: 17124\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# additional_checksd: /etc/dd-agent/checks.d/\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_curl_http_client: false\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# device_blacklist_re: .*\\/dev\\/mapper\\/lxc-box.*\n}, - ) - } - end - - context 'for pup' do - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_pup: no\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# pup_port: 17125\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# pup_interface: localhost\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# pup_url: http://localhost:17125\n}, - ) - } - end - - context 'for dogstatsd' do - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# bind_host: localhost\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_dogstatsd: yes\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_port: 8125\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# dogstatsd_target: http://localhost:17123\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# dogstatsd_interval: 10\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_normalize: yes\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# statsd_forward_host: address_of_own_statsd_server\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# statsd_forward_port: 8125\n}, - ) - } - end - - context 'for ganglia' do - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# ganglia_host: localhost\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# ganglia_port: 8651\n}, - ) - } - end - - context 'for logging' do - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^log_level: INFO\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^log_to_syslog: yes\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# collector_log_file: /var/log/datadog/collector.log\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# forwarder_log_file: /var/log/datadog/forwarder.log\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{# dogstatsd_log_file: /var/log/datadog/dogstatsd.log\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with - # 'content' => %r{# pup_log_file: /var/log/datadog/pup.log\n}, - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# syslog_host:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^# syslog_port:\n}, - ) - } - end - - context 'for service_discovery' do - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^service_discovery_backend:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^sd_config_backend:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^sd_backend_host:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^sd_backend_port:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^sd_template_dir:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^consul_token:\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').without( - 'content' => %r{^# sd_jmx_enable:\n}, - ) - } - end - - context 'for APM' do - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^apm_enabled: false\n}, - ) - } - end - end - - context 'with user provided paramaters' do - context 'with a custom dd_url' do - let(:params) do - { - dd_url: 'https://notaurl.datadoghq.com', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{dd_url: https://notaurl.datadoghq.com\n}, - ) - } - end - context 'with a custom proxy_host' do - let(:params) do - { - proxy_host: 'localhost', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^proxy_host: localhost\n}, - ) - } - end - context 'with a custom proxy_port' do - let(:params) do - { - proxy_port: '1234', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^proxy_port: 1234\n}, - ) - } - end - context 'with a custom proxy_port, specified as an integer' do - let(:params) do - { - proxy_port: 1234, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^proxy_port: 1234\n}, - ) - } - end - context 'with a custom proxy_user' do - let(:params) do - { - proxy_user: 'notauser', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^proxy_user: notauser\n}, - ) - } - end - context 'with a custom api_key' do - let(:params) do - { - api_key: 'notakey', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^api_key: notakey\n}, - ) - } - end - context 'with a custom hostname' do - let(:params) do - { - host: 'notahost', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^hostname: notahost\n}, - ) - } - end - context 'with non_local_traffic set to true' do - let(:params) do - { - non_local_traffic: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^non_local_traffic: true\n}, - ) - } - end - # Should expand testing to cover changes to the case upcase - context 'with log level set to critical' do - let(:params) do - { - log_level: 'critical', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^log_level: CRITICAL\n}, - ) - } - end - context 'with a custom hostname' do - let(:params) do - { - host: 'notahost', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^hostname: notahost\n}, - ) - } - end - context 'with log_to_syslog set to false' do - let(:params) do - { - log_to_syslog: false, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^log_to_syslog: no\n}, - ) - } - end - context 'with skip_ssl_validation set to true' do - let(:params) do - { - skip_ssl_validation: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog header').with( - 'content' => %r{^skip_ssl_validation: true\n}, - ) - } - end - context 'with collect_ec2_tags set to yes' do - let(:params) do - { - collect_ec2_tags: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^collect_ec2_tags: true\n}, - ) - } - end - context 'with collect_instance_metadata set to no' do - let(:params) do - { - collect_instance_metadata: false, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^collect_instance_metadata: false\n}, - ) - } - end - context 'with recent_point_threshold set to 60' do - let(:params) do - { - recent_point_threshold: '60', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^recent_point_threshold: 60\n}, - ) - } - end - context 'with a custom port set to 17125' do - let(:params) do - { - listen_port: '17125', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^listen_port: 17125\n}, - ) - } - end - context 'with a custom port set to 17125, specified as an integer' do - let(:params) do - { - listen_port: 17_125, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^listen_port: 17125\n}, - ) - } - end - context 'listening for graphite data on port 17124' do - let(:params) do - { - graphite_listen_port: '17124', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^graphite_listen_port: 17124\n}, - ) - } - end - context 'listening for graphite data on port 17124, port specified as an integer' do - let(:params) do - { - graphite_listen_port: 17_124, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^graphite_listen_port: 17124\n}, - ) - } - end - context 'with configuration for a custom checks.d' do - let(:params) do - { - additional_checksd: '/etc/dd-agent/checks_custom.d', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{additional_checksd: /etc/dd-agent/checks_custom.d\n}, - ) - } - end - context 'with configuration for a custom checks.d' do - let(:params) do - { - additional_checksd: '/etc/dd-agent/checks_custom.d', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{additional_checksd: /etc/dd-agent/checks_custom.d\n}, - ) - } - end - context 'with configuration for a custom checks.d' do - let(:params) do - { - additional_checksd: '/etc/dd-agent/checks_custom.d', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{additional_checksd: /etc/dd-agent/checks_custom.d\n}, - ) - } - end - context 'with using the Tornado HTTP client' do - let(:params) do - { - use_curl_http_client: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_curl_http_client: true\n}, - ) - } - end - context 'with a custom bind_host' do - let(:params) do - { - bind_host: 'test', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^bind_host: test\n}, - ) - } - end - context 'with pup enabled' do - let(:params) do - { - use_pup: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_pup: yes\n}, - ) - } - end - context 'with a custom pup_port' do - let(:params) do - { - pup_port: '17126', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^pup_port: 17126\n}, - ) - } - end - context 'with a custom pup_port, specified as an integer' do - let(:params) do - { - pup_port: 17_126, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^pup_port: 17126\n}, - ) - } - end - context 'with a custom pup_interface' do - let(:params) do - { - pup_interface: 'notalocalhost', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^pup_interface: notalocalhost\n}, - ) - } - end - context 'with a custom pup_url' do - let(:params) do - { - pup_url: 'http://localhost:17126', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{pup_url: http://localhost:17126\n}, - ) - } - end - context 'with use_dogstatsd set to no' do - let(:params) do - { - use_dogstatsd: false, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_dogstatsd: no\n}, - ) - } - end - context 'with use_dogstatsd set to yes' do - let(:params) do - { - use_dogstatsd: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^use_dogstatsd: yes\n}, - ) - } - end - context 'with dogstatsd_port set to 8126 - must be specified as an integer!' do - let(:params) do - { - dogstatsd_port: 8126, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_port: 8126\n}, - ) - } - end - context 'with dogstatsd_port set to 8126' do - let(:params) do - { - dogstatsd_port: 8126, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_port: 8126\n}, - ) - } - end - context 'with dogstatsd_target set to localhost:17124' do - let(:params) do - { - dogstatsd_target: 'http://localhost:17124', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{dogstatsd_target: http://localhost:17124\n}, - ) - } - end - context 'with dogstatsd_interval set to 5' do - let(:params) do - { - dogstatsd_interval: '5', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_interval: 5\n}, - ) - } - end - context 'with dogstatsd_interval set to 5' do - let(:params) do - { - dogstatsd_interval: '5', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_interval: 5\n}, - ) - } - end - context 'with dogstatsd_normalize set to false' do - let(:params) do - { - dogstatsd_normalize: false, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^dogstatsd_normalize: no\n}, - ) - } - end - context 'with statsd_forward_host set to localhost:3958' do - let(:params) do - { - statsd_forward_host: 'localhost:3958', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^statsd_forward_host: localhost:3958\n}, - ) - } - end - context 'with statsd_forward_port set to 8126' do - let(:params) do - { - statsd_forward_port: '8126', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^statsd_forward_port: 8126\n}, - ) - } - end - context 'with statsd_forward_port set to 8126, specified as an integer' do - let(:params) do - { - statsd_forward_port: 8126, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^statsd_forward_port: 8126\n}, - ) - } - end - context 'with device_blacklist_re set to test' do - let(:params) do - { - device_blacklist_re: 'test', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^device_blacklist_re: test\n}, - ) - } - end - context 'with device_blacklist_re set to test' do - let(:params) do - { - device_blacklist_re: 'test', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^device_blacklist_re: test\n}, - ) - } - end - context 'with ganglia_host set to localhost and ganglia_port set to 12345' do - let(:params) do - { - ganglia_host: 'testhost', - ganglia_port: '12345', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^ganglia_port: 12345\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^ganglia_host: testhost\n}, - ) - } - end - context 'with ganglia_host set to localhost and ganglia_port set to 12345, port specified as an integer' do - let(:params) do - { - ganglia_host: 'testhost', - ganglia_port: 12_345, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^ganglia_port: 12345\n}, - ) - } - end - context 'with dogstreams set to /path/to/log1:/path/to/parser' do - let(:params) do - { - dogstreams: ['/path/to/log1:/path/to/parser'], - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{dogstreams: /path/to/log1:/path/to/parser\n}, - ) - } - end - context 'with custom_emitters set to /test/emitter' do - let(:params) do - { - custom_emitters: '/test/emitter/', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{custom_emitters: /test/emitter/\n}, - ) - } - end - context 'with custom_emitters set to /test/emitter' do - let(:params) do - { - custom_emitters: '/test/emitter/', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{custom_emitters: /test/emitter/\n}, - ) - } - end - context 'with collector_log_file set to /test/log' do - let(:params) do - { - collector_log_file: '/test/log', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{collector_log_file: /test/log\n}, - ) - } - end - context 'with forwarder_log_file set to /test/log' do - let(:params) do - { - forwarder_log_file: '/test/log', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{forwarder_log_file: /test/log\n}, - ) - } - end - context 'with forwarder_log_file set to /test/log' do - let(:params) do - { - forwarder_log_file: '/test/log', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{forwarder_log_file: /test/log\n}, - ) - } - end - context 'with dogstatsd_log_file set to /test/log' do - let(:params) do - { - dogstatsd_log_file: '/test/log', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{dogstatsd_log_file: /test/log\n}, - ) - } - end - context 'with pup_log_file set to /test/log' do - let(:params) do - { - pup_log_file: '/test/log', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^pup_log_file: /test/log\n}, - ) - } - end - context 'with syslog location set to localhost' do - let(:params) do - { - syslog_host: 'localhost', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^syslog_host: localhost\n}, - ) - } - end - context 'with syslog port set to 8080' do - let(:params) do - { - syslog_port: '8080', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^syslog_port: 8080\n}, - ) - } - end - context 'with syslog port set to 8080, specified as an integer' do - let(:params) do - { - syslog_port: 8080, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^syslog_port: 8080\n}, - ) - } - end - context 'with apm_enabled set to true' do - let(:params) do - { - apm_enabled: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^apm_enabled: true\n}, - ) - } - end - context 'with apm_enabled set to true and env specified' do - let(:params) do - { - apm_enabled: true, - apm_env: 'foo', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^apm_enabled: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'content' => %r{^\[trace.agent\]\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'content' => %r{^env: foo\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with apm_enabled and apm_analyzed_spans set' do - let(:params) do - { - apm_enabled: true, - agent_major_version: 5, - apm_analyzed_spans: { - 'foo|bar' => 0.5, - 'haz|qux' => 0.1, - }, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^apm_enabled: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'content' => %r{^\[trace.analyzed_spans\]\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'content' => %r{^\[trace.analyzed_spans\]\nfoo|bar: 0.5\nhaz|qux: 0.1}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with service_discovery enabled' do - let(:params) do - { - service_discovery_backend: 'docker', - sd_config_backend: 'etcd', - sd_backend_host: 'localhost', - sd_backend_port: 8080, - sd_jmx_enable: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^service_discovery_backend: docker\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^sd_config_backend: etcd\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^sd_backend_host: localhost\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^sd_backend_port: 8080\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^sd_jmx_enable: true\n}, - ) - } - end - context 'with extra_template enabled' do - let(:params) do - { - extra_template: 'custom_datadog/extra_template_test.erb', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog extra_template footer').with( - 'order' => '06', - ) - } - it { - is_expected.to contain_concat__fragment('datadog extra_template footer').with( - 'content' => %r{^# extra template is here\n}, - ) - } - it { - is_expected.not_to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with APM enabled' do - let(:params) do - { - apm_enabled: true, - apm_env: 'foo', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with APM enabled but no APM env' do - let(:params) do - { - apm_enabled: true, - agent_major_version: 5, - } - end - - it { - is_expected.not_to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with extra_template and APM enabled' do - let(:params) do - { - extra_template: 'custom_datadog/extra_template_test.erb', - apm_enabled: true, - apm_env: 'foo', - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog extra_template footer').with( - 'order' => '06', - ) - } - it { - is_expected.to contain_concat__fragment('datadog extra_template footer').with( - 'content' => %r{^# extra template is here\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog apm footer').with( - 'order' => '07', - ) - } - end - context 'with process_agent enabled' do - let(:params) do - { - process_enabled: true, - agent_major_version: 5, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^process_agent_enabled: true\n}, - ) - } - end - - context 'with data scrubbing disabled' do - let(:params) do - { - process_enabled: true, - agent_major_version: 5, - scrub_args: false, - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^process_agent_enabled: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^\[process.config\]\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^scrub_args: false\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^custom_sensitive_words: \n}, - ) - } - end - - context 'with data scrubbing enabled with custom sensitive_words' do - let(:params) do - { - process_enabled: true, - agent_major_version: 5, - custom_sensitive_words: ['consul_token', 'dd_key'], - } - end - - it { - is_expected.to contain_concat__fragment('datadog footer').with( - 'content' => %r{^process_agent_enabled: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^\[process.config\]\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^scrub_args: true\n}, - ) - } - it { - is_expected.to contain_concat__fragment('datadog process agent footer').with( - 'content' => %r{^custom_sensitive_words: consul_token,dd_key\n}, - ) - } - end - end - end - - if REDHAT_OS.include?(operatingsystem) - it { is_expected.to contain_class('datadog_agent::redhat') } - end - end - end - describe "datadog_agent 6/7 class with reports on #{operatingsystem}" do let(:params) do { @@ -1712,6 +383,9 @@ 'major' => getosmajor(operatingsystem), 'full' => getosrelease(operatingsystem), }, + 'distro' => { + 'codename' => getoscodename(operatingsystem), + } }, } end @@ -1745,6 +419,9 @@ 'major' => getosmajor(operatingsystem), 'full' => getosrelease(operatingsystem), }, + 'distro' => { + 'codename' => getoscodename(operatingsystem) + }, }, } end @@ -1767,11 +444,6 @@ it { is_expected.to contain_file(install_info_file) } it { is_expected.to contain_file(config_dir + '/conf.d').with_ensure('directory') } - # Agent 5 files - it { is_expected.not_to contain_file('/etc/dd-agent') } - it { is_expected.not_to contain_concat('/etc/dd-agent/datadog.conf') } - it { is_expected.not_to contain_file('/etc/dd-agent/conf.d').with_ensure('directory') } - describe 'install_info check' do let!(:install_info) do contents = catalogue.resource('file', install_info_file).send(:parameters)[:content] @@ -1781,8 +453,8 @@ it 'adds an install_info' do expect(install_info['install_method']).to match( 'tool' => 'puppet', - 'tool_version' => %r{^puppet-unknown$}, # puppetversion is not set in tests, this field has to be tested manually - 'installer_version' => %r{^datadog_module-\d+\.\d+\.\d+$}, + 'tool_version' => %r{^puppet-\d+\.\d+\.\d}, # puppetversion is not set in tests, this field has to be tested manually + 'installer_version' => %r{^datadog_module-\d+\.\d+\.\d}, ) end end @@ -1955,68 +627,6 @@ ) } end - context 'deprecated proxy settings' do - let(:params) do - { - proxy_host: 'foo', - proxy_port: 1234, - proxy_user: 'bar', - proxy_password: 'abcd1234', - } - end - - it { - is_expected.to contain_notify( - 'Setting proxy_host is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.to contain_notify( - 'Setting proxy_port is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.to contain_notify( - 'Setting proxy_user is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.to contain_notify( - 'Setting proxy_password is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - end - context 'deprecated proxy settings with default values' do - let(:params) do - { - proxy_host: '', - proxy_port: '', - proxy_user: '', - proxy_password: '', - } - end - - it { - is_expected.not_to contain_notify( - 'Setting proxy_host is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.not_to contain_notify( - 'Setting proxy_port is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.not_to contain_notify( - 'Setting proxy_user is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - it { - is_expected.not_to contain_notify( - 'Setting proxy_password is only used with Agent 5. Please use agent_extra_options to set your proxy', - ) - } - end end context 'with additional agents config' do @@ -2361,6 +971,9 @@ 'major' => '6', 'full' => '6.3', }, + 'distro' => { + 'codename' => 'santiago', + } }, } end @@ -2411,6 +1024,9 @@ 'major' => '6', 'full' => '6.3', }, + 'distro' => { + 'codename' => 'santiago', + } }, } end @@ -2420,36 +1036,5 @@ .with_content(%r{tags:\n- os.family:redhat\n- facts_array:one\n- facts_array:two\n- facts_hash.actor.first_name:Macaulay\n- looks.like.a.path:but_its_not}) end end - - describe 'a5 ensure facts_array outputs a list of tags' do - let(:params) do - { - agent_major_version: 5, - puppet_run_reports: true, - facts_to_tags: ['osfamily', 'facts_array'], - } - end - let(:facts) do - { - facts_array: ['one', 'two'], - osfamily: 'redhat', - os: { - 'architecture' => 'x86_64', - 'family' => 'redhat', - 'name' => 'CentOS', - 'release' => { - 'major' => '6', - 'full' => '6.3', - }, - }, - } - end - - it { is_expected.to contain_concat('/etc/dd-agent/datadog.conf') } - it { is_expected.to contain_concat__fragment('datadog tags').with_content('tags: ') } - it { is_expected.to contain_concat__fragment('datadog tag osfamily:redhat').with_content('osfamily:redhat, ') } - it { is_expected.to contain_concat__fragment('datadog tag facts_array:one').with_content('facts_array:one, ') } - it { is_expected.to contain_concat__fragment('datadog tag facts_array:two').with_content('facts_array:two, ') } - end end end diff --git a/spec/classes/datadog_agent_ubuntu_spec.rb b/spec/classes/datadog_agent_ubuntu_spec.rb index 6de162e5d..da5c31e97 100644 --- a/spec/classes/datadog_agent_ubuntu_spec.rb +++ b/spec/classes/datadog_agent_ubuntu_spec.rb @@ -23,60 +23,6 @@ end describe 'datadog_agent::ubuntu' do - context 'agent 5' do - if RSpec::Support::OS.windows? - return - end - let(:params) do - { - agent_major_version: 5, - } - end - let(:facts) do - { - os: { - 'architecture' => 'x86_64', - 'family' => 'debian', - 'name' => 'Ubuntu', - 'release' => { - 'major' => '14', - 'full' => '14.04', - }, - }, - } - end - - it do - is_expected.to contain_file('/etc/apt/sources.list.d/datadog5.list') - .with_ensure('absent') - is_expected.to contain_file('/etc/apt/sources.list.d/datadog6.list') - .with_ensure('absent') - is_expected.to contain_file('/etc/apt/sources.list.d/datadog.list')\ - .with_content(%r{deb\s+\[signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg\]\s+https://apt.datadoghq.com/\s+stable\s+main}) - end - - # it should install the mirror - it { is_expected.not_to contain_apt__key('935F5A436A5A6E8788F0765B226AE980C7A7DA52') } - - it do - is_expected.to contain_file('/etc/apt/sources.list.d/datadog.list')\ - .that_notifies('exec[apt_update]') - end - it { is_expected.to contain_exec('apt_update') } - - # it should install the packages - it do - is_expected.to contain_package('datadog-agent-base')\ - .with_ensure('absent')\ - .that_comes_before('package[datadog-agent]') - end - it do - is_expected.to contain_package('datadog-agent')\ - .that_requires('file[/etc/apt/sources.list.d/datadog.list]')\ - .that_requires('exec[apt_update]') - end - end - context 'agent 6' do let(:params) do { @@ -94,6 +40,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + } }, } end @@ -146,6 +95,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + } }, } end @@ -195,6 +147,9 @@ 'major' => '14', 'full' => '14.04', }, + 'distro' => { + 'codename' => 'trusty', + } }, } end @@ -219,6 +174,9 @@ 'major' => '16', 'full' => '16.04', }, + 'distro' => { + 'codename' => 'xenial', + } }, } end @@ -243,6 +201,9 @@ 'major' => '8', 'full' => '8.0', }, + 'distro' => { + 'codename' => 'jessie', + } }, } end @@ -267,6 +228,9 @@ 'major' => '9', 'full' => '9.0', }, + 'distro' => { + 'codename' => 'stretch', + } }, } end diff --git a/spec/default_facts.yml b/spec/default_facts.yml new file mode 100644 index 000000000..3346c394d --- /dev/null +++ b/spec/default_facts.yml @@ -0,0 +1,9 @@ +# Use default_module_facts.yml for module specific facts. +# +# Facts specified here will override the values provided by rspec-puppet-facts. +--- +networking: + ip: "172.16.254.254" + ip6: "FE80:0000:0000:0000:AAAA:AAAA:AAAA" + mac: "AA:AA:AA:AA:AA:AA" +is_pe: false diff --git a/spec/defines/datadog_agent__integration_spec.rb b/spec/defines/datadog_agent__integration_spec.rb index bbdacab9b..fdea34f2b 100644 --- a/spec/defines/datadog_agent__integration_spec.rb +++ b/spec/defines/datadog_agent__integration_spec.rb @@ -3,20 +3,15 @@ describe 'datadog_agent::integration' do ALL_SUPPORTED_AGENTS.each do |agent_major_version| context 'supported agents' do - if agent_major_version == 5 - conf_file = '/etc/dd-agent/conf.d/test.yaml' - else - conf_dir = "#{CONF_DIR}/test.d" - conf_file = "#{conf_dir}/conf.yaml" - end + conf_dir = "#{CONF_DIR}/test.d" + conf_file = "#{conf_dir}/conf.yaml" let(:pre_condition) { "class {'::datadog_agent': agent_major_version => #{agent_major_version}}" } let(:title) { 'test' } - if agent_major_version > 5 - it { is_expected.to contain_file(conf_dir.to_s).that_comes_before("File[#{conf_file}]") } - end + it { is_expected.to contain_file(conf_dir.to_s).that_comes_before("File[#{conf_file}]") } + it { is_expected.to contain_file(conf_file.to_s).that_notifies("Service[#{SERVICE_NAME}]") } context 'with instances' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8bf6b9389..103363309 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,15 @@ +# frozen_string_literal: true + +RSpec.configure do |c| + c.mock_with :rspec +end + require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' + +require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) + +include RspecPuppetFacts DEBIAN_OS = ['Ubuntu', 'Debian'].freeze REDHAT_OS = ['RedHat', 'CentOS', 'Fedora', 'Amazon', 'Scientific', 'OracleLinux', 'AlmaLinux', 'Rocky'].freeze @@ -7,23 +18,23 @@ if RSpec::Support::OS.windows? ALL_OS = WINDOWS_OS ALL_SUPPORTED_AGENTS = [6, 7].freeze - CONF_DIR = 'C:/ProgramData/Datadog/conf.d'.freeze - DD_USER = 'ddagentuser'.freeze - DD_GROUP = 'S-1-5-32-544'.freeze - SERVICE_NAME = 'datadogagent'.freeze - PACKAGE_NAME = 'Datadog Agent'.freeze - PERMISSIONS_FILE = '0664'.freeze - PERMISSIONS_PROTECTED_FILE = '0660'.freeze + CONF_DIR = 'C:/ProgramData/Datadog/conf.d' + DD_USER = 'ddagentuser' + DD_GROUP = 'S-1-5-32-544' + SERVICE_NAME = 'datadogagent' + PACKAGE_NAME = 'Datadog Agent' + PERMISSIONS_FILE = '0664' + PERMISSIONS_PROTECTED_FILE = '0660' else ALL_OS = DEBIAN_OS + REDHAT_OS - ALL_SUPPORTED_AGENTS = [5, 6, 7].freeze - CONF_DIR = '/etc/datadog-agent/conf.d'.freeze - DD_USER = 'dd-agent'.freeze - DD_GROUP = 'dd-agent'.freeze - SERVICE_NAME = 'datadog-agent'.freeze - PACKAGE_NAME = 'datadog-agent'.freeze - PERMISSIONS_FILE = '0644'.freeze - PERMISSIONS_PROTECTED_FILE = '0600'.freeze + ALL_SUPPORTED_AGENTS = [6, 7].freeze + CONF_DIR = '/etc/datadog-agent/conf.d' + DD_USER = 'dd-agent' + DD_GROUP = 'dd-agent' + SERVICE_NAME = 'datadog-agent' + PACKAGE_NAME = 'datadog-agent' + PERMISSIONS_FILE = '0644' + PERMISSIONS_PROTECTED_FILE = '0600' end def min_puppet_version(version) @@ -60,30 +71,101 @@ def getosrelease(operatingsystem) end end -RSpec.configure do |c| - c.default_facts = { - 'architecture' => 'x86_64', - 'operatingsystem' => (RSpec::Support::OS.windows? ? 'Windows' : 'Ubuntu'), - 'osfamily' => (RSpec::Support::OS.windows? ? 'windows' : 'Debian'), - 'operatingsystemmajrelease' => (RSpec::Support::OS.windows? ? '2019' : '14'), - 'operatingsystemminrelease' => (RSpec::Support::OS.windows? ? 'SP1' : '04'), - 'operatingsystemrelease' => (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), - 'lsbdistrelease' => (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), - 'lsbdistcodename' => (RSpec::Support::OS.windows? ? '2019' : '14.04'), - 'os' => { - 'architecture' => 'x86_64', - 'name' => (RSpec::Support::OS.windows? ? 'Windows' : 'Ubuntu'), - 'family' => (RSpec::Support::OS.windows? ? 'windows' : 'Debian'), - 'release' => { - 'major' => (RSpec::Support::OS.windows? ? '2019' : '14'), - 'minor' => (RSpec::Support::OS.windows? ? 'SP1' : '04'), - 'full' => (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), - }, - }, - } +def getoscodename(operatingsystem) + if DEBIAN_OS.include?(operatingsystem) + 'trusty' + elsif REDHAT_OS.include?(operatingsystem) + 'maipo' + else + 'seattle' + end end # Get parameters from catalogue. def get_from_catalogue(type, name, parameter) catalogue.resource(type, name).send(:parameters)[parameter.to_sym] end + +default_facts = { + puppetversion: Puppet.version, + facterversion: Facter.version, + architecture: 'x86_64', + operatingsystem: (RSpec::Support::OS.windows? ? 'Windows' : 'Ubuntu'), + osfamily: (RSpec::Support::OS.windows? ? 'windows' : 'Debian'), + operatingsystemmajrelease: (RSpec::Support::OS.windows? ? '2019' : '14'), + operatingsystemminrelease: (RSpec::Support::OS.windows? ? 'SP1' : '04'), + operatingsystemrelease: (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), + lsbdistrelease: (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), + lsbdistcodename: (RSpec::Support::OS.windows? ? '2019' : '14.04'), + os: { + architecture: 'x86_64', + name: (RSpec::Support::OS.windows? ? 'Windows' : 'Ubuntu'), + family: (RSpec::Support::OS.windows? ? 'windows' : 'Debian'), + release: { + major: (RSpec::Support::OS.windows? ? '2019' : '14'), + minor: (RSpec::Support::OS.windows? ? 'SP1' : '04'), + full: (RSpec::Support::OS.windows? ? '2019 SP1' : '14.04'), + }, + 'distro' => { + 'codename' => (RSpec::Support::OS.windows? ? 'seattle' : 'focal'), + }, + } +} + +default_fact_files = [ + File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')), + File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')), +] + +default_fact_files.each do |f| + next unless File.exist?(f) && File.readable?(f) && File.size?(f) + + begin + require 'deep_merge' + default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) + rescue StandardError => e + RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" + end +end + +# read default_facts and merge them over what is provided by facterdb +default_facts.each do |fact, value| + add_custom_fact fact, value, merge_facts: true +end + +RSpec.configure do |c| + c.default_facts = default_facts + c.before :each do + # set to strictest setting for testing + # by default Puppet runs at warning level + Puppet.settings[:strict] = :warning + Puppet.settings[:strict_variables] = true + end + c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] + c.after(:suite) do + RSpec::Puppet::Coverage.report!(0) + end + + # Filter backtrace noise + backtrace_exclusion_patterns = [ + %r{spec_helper}, + %r{gems}, + ] + + if c.respond_to?(:backtrace_exclusion_patterns) + c.backtrace_exclusion_patterns = backtrace_exclusion_patterns + elsif c.respond_to?(:backtrace_clean_patterns) + c.backtrace_clean_patterns = backtrace_exclusion_patterns + end +end + +# Ensures that a module is defined +# @param module_name Name of the module +def ensure_module_defined(module_name) + module_name.split('::').reduce(Object) do |last_module, next_module| + last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false) + last_module.const_get(next_module, false) + end +end + +# 'spec_overrides' from sync.yml will appear below this line diff --git a/templates/agent-conf.d/activemq_xml.yaml.erb b/templates/agent-conf.d/activemq_xml.yaml.erb index a4053baa1..dd0150235 100644 --- a/templates/agent-conf.d/activemq_xml.yaml.erb +++ b/templates/agent-conf.d/activemq_xml.yaml.erb @@ -11,8 +11,8 @@ instances: <% unless instance['password'].nil? -%> password: <%= instance['password'] %> <%- end -%> -<% unless instance['supress_errors'].nil? -%> - supress_errors: <%= instance['supress_errors'] %> +<% unless instance['suppress_errors'].nil? -%> + suppress_errors: <%= instance['suppress_errors'] %> <%- end -%> <%- unless instance['detailed_queues'].nil? || instance['detailed_queues'].empty? -%> detailed_queues: diff --git a/templates/agent-conf.d/cassandra.yaml.erb b/templates/agent-conf.d/cassandra.yaml.erb index afc51389d..86afee025 100644 --- a/templates/agent-conf.d/cassandra.yaml.erb +++ b/templates/agent-conf.d/cassandra.yaml.erb @@ -33,8 +33,7 @@ init_config: ## @param conf - list of objects - required ## List of metrics to be collected by the integration ## Read http://docs.datadoghq.com/integrations/java/ to learn how to customize it - ## Agent 5: Customize all your metrics below - ## Agent 6: The default metrics to be collected are kept in metrics.yaml, but you can still add your own metrics here + ## Agent 6/7: The default metrics to be collected are kept in metrics.yaml, but you can still add your own metrics here # conf: - include: diff --git a/templates/agent-conf.d/disk.yaml.erb b/templates/agent-conf.d/disk.yaml.erb index 5681f4b3c..5d7e90761 100644 --- a/templates/agent-conf.d/disk.yaml.erb +++ b/templates/agent-conf.d/disk.yaml.erb @@ -3,7 +3,11 @@ init_config: instances: +<% if @use_mount.nil? -%> + - use_mount: false +<% else -%> - use_mount: <%= @use_mount %> +<% end -%> <% if @filesystem_blacklist -%> file_system_blacklist: <% (Array(@filesystem_blacklist)).each do |fs| -%> @@ -94,9 +98,9 @@ instances: <% if @excluded_mountpoint_re -%> excluded_mountpoint_re: <%= @excluded_mountpoint_re %> <% end -%> -<% if @all_partitions -%> +<% if not @all_partitions.nil? -%> all_partitions: <%= @all_partitions %> <% end -%> -<% if @tag_by_filesystem -%> +<% if not @tag_by_filesystem.nil? -%> tag_by_filesystem: <%= @tag_by_filesystem %> <% end -%> diff --git a/templates/agent-conf.d/elastic.yaml.erb b/templates/agent-conf.d/elastic.yaml.erb index 6eebac2ee..a461ad3a4 100644 --- a/templates/agent-conf.d/elastic.yaml.erb +++ b/templates/agent-conf.d/elastic.yaml.erb @@ -16,13 +16,22 @@ instances: pshard_stats: <%= instance['pshard_stats'] %> pending_task_stats: <%= instance['pending_task_stats'] %> <%- if instance['url'].match(/^https/) -%> - ssl_verify: <%= instance['ssl_verify'] %> + tls_verify: <%= instance['tls_verify'] %> <%- end -%> -<%- if instance['ssl_cert'] && instance['ssl_cert'] != :undef -%> - ssl_cert: <%= instance['ssl_cert'] %> +<%- if instance['tls_cert'] && instance['tls_cert'] != :undef -%> + tls_cert: <%= instance['tls_cert'] %> <%- end -%> -<%- if instance['ssl_key'] && instance['ssl_key'] != :undef -%> - ssl_key: <%= instance['ssl_key'] %> +<%- if instance['tls_ca_cert'] && instance['tls_ca_cert'] != :undef -%> + tls_ca_cert: <%= instance['tls_ca_cert'] %> +<%- end -%> +<%- if instance['tls_private_key'] && instance['tls_private_key'] != :undef -%> + tls_private_key: <%= instance['tls_private_key'] %> +<%- end -%> +<%- if instance['tls_use_host_header'] && instance['tls_use_host_header'] != :undef -%> + tls_use_host_header: <%= instance['tls_use_host_header'] %> +<%- end -%> +<%- if instance['tls_ignore_warning'] && instance['tls_ignore_warning'] != :undef -%> + tls_ignore_warning: <%= instance['tls_ignore_warning'] %> <%- end -%> <%- unless instance['tags'].empty? -%> tags: @@ -30,4 +39,16 @@ instances: - <%= tag %> <%- end -%> <%- end -%> +<%- unless instance['tls_protocols_allowed'].nil? -%> + tls_protocols_allowed: + <%- instance['tls_protocols_allowed'].each do |protocol| -%> + - <%= protocol %> + <%- end -%> +<%- end -%> +<%- unless instance['tls_ciphers'].nil? -%> + tls_ciphers: + <%- instance['tls_ciphers'].each do |cipher| -%> + - <%= cipher %> + <%- end -%> +<%- end -%> <%- end -%> diff --git a/templates/agent-conf.d/jenkins.yaml.erb b/templates/agent-conf.d/jenkins.yaml.erb deleted file mode 100644 index 2b39d863a..000000000 --- a/templates/agent-conf.d/jenkins.yaml.erb +++ /dev/null @@ -1,7 +0,0 @@ -### MANAGED BY PUPPET - -init_config: - -instances: - - name: default - jenkins_home: <%= @path %> diff --git a/templates/agent-conf.d/kafka.yaml.erb b/templates/agent-conf.d/kafka.yaml.erb index c76955f28..88ffabbc9 100644 --- a/templates/agent-conf.d/kafka.yaml.erb +++ b/templates/agent-conf.d/kafka.yaml.erb @@ -1,11 +1,5 @@ ### MANAGED BY PUPPET -########## -# WARNING -########## -# This sample works only for Kafka >= 0.8.2. -# If you are running a version older than that, you can refer to agent 5.2.x released -# sample files, https://raw.githubusercontent.com/DataDog/dd-agent/5.2.1/conf.d/kafka.yaml.example instances: <% @servers.each do |server| -%> - host: <%= server['host'] %> diff --git a/templates/agent-conf.d/tcp_check.yaml.erb b/templates/agent-conf.d/tcp_check.yaml.erb index 0ba232c9c..579afb884 100644 --- a/templates/agent-conf.d/tcp_check.yaml.erb +++ b/templates/agent-conf.d/tcp_check.yaml.erb @@ -19,9 +19,6 @@ instances: <% if instance['collect_response_time'] -%> collect_response_time: <%= instance['collect_response_time'] %> <% end -%> -<% if instance['skip_event'] -%> - skip_event: <%= instance['skip_event'] %> -<% end -%> <% if instance['tags'] and ! instance['tags'].empty? -%> tags: <%- Array(instance['tags']).each do |tag| -%> diff --git a/templates/datadog_footer.conf.erb b/templates/datadog_footer.conf.erb index 32820d32d..9bf4bb35b 100644 --- a/templates/datadog_footer.conf.erb +++ b/templates/datadog_footer.conf.erb @@ -27,13 +27,6 @@ recent_point_threshold: <%= @recent_point_threshold %> listen_port: <%= @listen_port %> <% end -%> -# Start a graphite listener on this port -<% if @graphite_listen_port.to_s.empty? -%> -# graphite_listen_port: 17124 -<% else -%> -graphite_listen_port: <%= @graphite_listen_port %> -<% end -%> - # Additional directory to look for Datadog checks <% if @additional_checksd.nil? -%> # additional_checksd: /etc/dd-agent/checks.d/ @@ -48,10 +41,6 @@ additional_checksd: <%= @additional_checksd %> # https://github.com/DataDog/dd-agent/wiki/Network-Traffic-and-Proxy-Configuration non_local_traffic: <%= @non_local_traffic %> -# Select the Tornado HTTP Client in the forwarder -# Default to the simple http client -use_curl_http_client: <%= @use_curl_http_client %> - # The loopback address the Forwarder and Dogstatsd will bind. # Optional, it is mainly used when running the agent on Openshift <% if @bind_host.empty? -%> @@ -162,80 +151,6 @@ statsd_forward_port: <%= @statsd_forward_port %> device_blacklist_re: <%= @device_blacklist_re %> <% end -%> -# -------------------------------------------------------------------------- # -# Ganglia # -# -------------------------------------------------------------------------- # - -<% if @ganglia_host.empty? -%> -# Ganglia host where gmetad is running -# ganglia_host: localhost -# -# Ganglia port where gmetad is running -# ganglia_port: 8651 -<% else -%> -# Ganglia host where gmetad is running -ganglia_host: <%= @ganglia_host %> - -# Ganglia port where gmetad is running -ganglia_port: <%= @ganglia_port %> -<% end -%> - - -# -------------------------------------------------------------------------- # -# Dogstream (log file parser) -# -------------------------------------------------------------------------- # - -# Comma-separated list of logs to parse and optionally custom parsers to use. -# The form should look like this: -# -# dogstreams: /path/to/log1:parsers_module:custom_parser, /path/to/log2, /path/to/log3, ... -# -# Or this: -# -# dogstreams: /path/to/log1:/path/to/my/parsers_module.py:custom_parser, /path/to/log2, /path/to/log3, ... -# -# Each entry is a path to a log file and optionally a Python module/function pair -# separated by colons. -# -# Custom parsers should take a 2 parameters, a logger object and -# a string parameter of the current line to parse. It should return a tuple of -# the form: -# (metric (str), timestamp (unix timestamp), value (float), attributes (dict)) -# where attributes should at least contain the key 'metric_type', specifying -# whether the given metric is a 'counter' or 'gauge'. -# -# Unless parsers are specified with an absolute path, the modules must exist in -# the Agent's PYTHONPATH. You can set this as an environment variable when -# starting the Agent. If the name of the custom parser function is not passed, -# 'parser' is assumed. -# -# If this value isn't specified, the default parser assumes this log format: -# metric timestamp value key0=val0 key1=val1 ... -# -<% -if not @dogstreams.empty? --%> -dogstreams: <%= @dogstreams.join(', ') %> -<% end -%> - -# ========================================================================== # -# Custom Emitters # -# ========================================================================== # - -# Comma-separated list of emitters to be used in addition to the standard one -# -# Expected to be passed as a comma-separated list of colon-delimited -# name/object pairs. -# -<% if @custom_emitters.empty? -%> -# custom_emitters: /usr/local/my-code/emitters/rabbitmq.py:RabbitMQEmitter -<% else -%> -custom_emitters: <%= @custom_emitters %> -<% end -%> -# -# If the name of the emitter function is not specified, 'emitter' is assumed. - - # ========================================================================== # # Logging # ========================================================================== # diff --git a/templates/installer/telemetry/log.json.epp b/templates/installer/telemetry/log.json.epp index c0dd58f88..c303a1d8e 100644 --- a/templates/installer/telemetry/log.json.epp +++ b/templates/installer/telemetry/log.json.epp @@ -6,7 +6,7 @@ "seq_id": 2, "origin": "puppet", "host": { - "hostname": "<%= $hostname %>", + "hostname": "<%= $facts['networking']['hostname'] %>", "os": "<%= $facts['os']['name'] %>", "distribution": "<%= $facts['os']['family'] %>", "architecture": "<%= $facts['os']['architecture'] %>", diff --git a/templates/installer/telemetry/trace.json.epp b/templates/installer/telemetry/trace.json.epp index bfb274a78..1c20c0588 100644 --- a/templates/installer/telemetry/trace.json.epp +++ b/templates/installer/telemetry/trace.json.epp @@ -6,7 +6,7 @@ "seq_id": 1, "origin": "puppet", "host": { - "hostname": "<%= $hostname %>", + "hostname": "<%= $facts['networking']['hostname'] %>", "os": "<%= $facts['os']['name'] %>", "distribution": "<%= $facts['os']['family'] %>", "architecture": "<%= $facts['os']['architecture'] %>",