diff --git a/.circleci/config.yml b/.circleci/config.yml index 850e642e..99862c18 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,21 +1,30 @@ version: 2 jobs: kitchen-docker-tests: - machine: true + machine: + image: ubuntu-2004:2024.01.2 + resource_class: large environment: + CHEF_LICENSE: accept # newer versions of Chef client need explicit license accept to run KITCHEN_LOCAL_YAML: kitchen.docker.yml RUBY_VERSION: '2.6.3' # ruby used to invoke kitchen, not the version used in the tests + DOCKER_BUILDKIT: 0 # Disable buildkit for compatibility with version of kitchen we use + shell: /bin/bash --login -eo pipefail steps: - checkout - run: name: Set Ruby version command: | echo "Using $RUBY_VERSION" + gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB + curl -sSL https://get.rvm.io | bash -s stable + source /home/circleci/.rvm/scripts/rvm + rvm reload rvm install $RUBY_VERSION echo . $(rvm $RUBY_VERSION do rvm env --path) >> $BASH_ENV - run: name: Install bundler - command: gem install bundler:1.17.3 + command: gem install bundler:2.3.26 - run: name: Install dependencies with bundler command: bundle install --path .bundle @@ -25,7 +34,8 @@ jobs: no_output_timeout: 900 style: - machine: true + machine: + image: ubuntu-2004:202201-02 environment: CHEF_VERSION: '16.5.77' RUBY_VERSION: '2.6.3' @@ -35,11 +45,15 @@ jobs: name: Set Ruby version command: | echo "Using $RUBY_VERSION" + curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - + # Update RVM. Using this path instead of https://get.rvm.io because the later uses the letsencrypt cert that breaks openssl 1.0 + curl -sSL https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer | bash -s stable + rvm reload rvm install $RUBY_VERSION echo . $(rvm $RUBY_VERSION do rvm env --path) >> $BASH_ENV - run: name: Install bundler - command: gem install bundler:1.17.3 + command: gem install bundler:2.3.26 - run: name: Check bundler version command: bundle --version @@ -56,7 +70,8 @@ jobs: command: bundle exec rake style specs-base: &specs - machine: true + machine: + image: ubuntu-2004:202201-02 environment: CHEF_VERSION: 'needs-to-be-specified' RUBY_VERSION: 'needs-to-be-specified' @@ -66,11 +81,15 @@ jobs: name: Set Ruby version command: | echo "Using $RUBY_VERSION" + curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - + # Update RVM. Using this path instead of https://get.rvm.io because the later uses the letsencrypt cert that breaks openssl 1.0 + curl -sSL https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer | bash -s stable + rvm reload rvm install $RUBY_VERSION echo . $(rvm $RUBY_VERSION do rvm env --path) >> $BASH_ENV - run: name: Install bundler - command: gem install bundler:1.17.3 + command: gem install bundler:2.3.26 - run: name: Check bundler version command: bundle --version @@ -86,6 +105,30 @@ jobs: name: Run specs command: bundle exec rake spec + specs-ruby3.0.0-chef17.4.38: + <<: *specs + environment: + CHEF_VERSION: '17.4.38' + RUBY_VERSION: '3.0.0' + + specs-ruby3.0.0-chef16.5.77: + <<: *specs + environment: + CHEF_VERSION: '16.5.77' + RUBY_VERSION: '3.0.0' + + specs-ruby2.7.2-chef17.4.38: + <<: *specs + environment: + CHEF_VERSION: '17.4.38' + RUBY_VERSION: '2.7.2' + + specs-ruby2.7.2-chef16.5.77: + <<: *specs + environment: + CHEF_VERSION: '16.5.77' + RUBY_VERSION: '2.7.2' + specs-ruby2.6.3-chef16.5.77: <<: *specs environment: @@ -110,20 +153,17 @@ jobs: CHEF_VERSION: '13.12.14' RUBY_VERSION: '2.4.3' - specs-ruby2.3.6-chef13.12.14: - <<: *specs - environment: - CHEF_VERSION: '13.12.14' - RUBY_VERSION: '2.3.6' - workflows: version: 2 build_and_test: jobs: - kitchen-docker-tests - style + - specs-ruby3.0.0-chef17.4.38 + - specs-ruby3.0.0-chef16.5.77 + - specs-ruby2.7.2-chef17.4.38 + - specs-ruby2.7.2-chef16.5.77 - specs-ruby2.6.3-chef16.5.77 - specs-ruby2.6.3-chef14.10.9 - specs-ruby2.5.1-chef14.10.9 - specs-ruby2.4.3-chef13.12.14 - - specs-ruby2.3.6-chef13.12.14 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 338fd9f8..eb1f176d 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ -* @DataDog/agent-platform +* @DataDog/agent-build-and-releases # Docs -*README.md @DataDog/agent-platform @DataDog/documentation +*README.md @DataDog/agent-build-and-releases @DataDog/documentation diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 00000000..fc03cb78 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,25 @@ +--- +name: Bug Report +about: Identify a bug in the scripts +title: "[BUG] " +labels: triage +assignees: '' + +--- + + + + +**Environment details (Operating System, Cloud provider, etc):** + + +**Describe what happened:** + + +**Describe what you expected:** + + +**Steps to reproduce the issue:** diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 00000000..11906e79 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,12 @@ +--- +name: Feature Request +about: Suggest a new feature +title: '' +labels: '' +assignees: '' + +--- + +This issue tracker is primarily used to track bugs in the scripts. For feature requests, please contact [Datadog support](http://docs.datadoghq.com/help/) and share your ideas with them. + +Thanks! diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..8c63c1ec --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,53 @@ + +### What does this PR do? + + + +### Motivation + + + +### Additional Notes + + + +### Possible Drawbacks / Trade-offs + + + +### Describe how to test/QA your changes + + + +### Reviewer's Checklist + diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..e26bb8d8 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,46 @@ +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'ruby' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/Berksfile b/Berksfile index 1af09669..43a3273e 100644 --- a/Berksfile +++ b/Berksfile @@ -6,3 +6,5 @@ group :integration do cookbook 'sudo' # Use '< 5.0.0' with Chef < 13 cookbook 'test', path: './test/cookbooks/test' # Used to test custom resources (datadog_monitor, integration) end + +cookbook 'yum', '< 7.0.0' diff --git a/CHANGELOG.md b/CHANGELOG.md index e03bc96b..23d8757a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,78 @@ Changes ======= +# 4.19.0 / 2024-02-19 +* [FEATURE] Add support for installation of the datadog-fips-proxy package [#853] [@truthbk] +* [FEATURE] Add support for CWS on Windows [#907] [@paulcacheux] + +# 4.18.0 / 2023-07-25 + * [BUGFIX] Syntax update to support old chef-infra versions [#898] [@chouetz] + * [FEATURE] Update recipes to support amazonlinux 2023 installation [#896] [@chouetz] + * [FEATURE] Add agent configuration value to config template [#888] [@nichols2k] + * [FEATURE] Actually enforce `apt` and `yum` versions in the `metadata.rb` file [#874] [@amenasria] + * [FEATURE] support weblogic integration [#891] [@vigohe] + * [FEATURE] Add new APT and RPM signing keys [#890] [@chouetz] + * [BUGFIX] Fix dead link in http_check.rb recipe [#887] [@amenasria] + +# 4.17.0 / 2023-02-20 +* [FEATURE] Added the option to enable Universal Service Monitoring (USM) [#876][] [@guyarb][] +* [BUGFIX] Fix crash for jmx integrations with `init_config` attributes set [#869][] [@KSerrania][] + +# 4.16.0 / 2023-01-12 + +* [DEPRECATION] Remove old RPM GPG key. This also removes the `yumrepo_gpgkey` parameter [#877][] [@amenasria][] +* [FEATURE] Add min_collection_interval option to ssh_check config [#867][] [@nilskuehme][] +* [BUGFIX] Remove source file and datadog-signing-keys package when removing the Agent [#865][] [@amenasria][] + +# 4.15.0 / 2022-10-06 +* [BUGFIX] Enforce calls of agent version without color output [#863][] [@KSerrania][] +* [FEATURE] Add configuration for custom_log_collection [#861][] [@nilskuehme][] +* [FEATURE] Add configuration for gearmand integration [#860][] [@nilskuehme][] +* [FEATURE] Add unit types to Systemd integration [#859][] [@nilskuehme][] +* [BUGFIX] Specify release but not epoch for RPM packages on Chef < 14 [#858][] [@KSerrania][] +* [BUGFIX] Don't use epoch/release for yum package version on Chef < 14 [#856][] [@bkabrda][] +* [FEATURE] Use agent version instead of agent status to determine the current Agent version [#852][] [@amenasria][] + +# 4.14.0 / 2022-06-14 +* [BUGFIX] Fix system probe recipe on Windows [#850][] [@julien-lebot][] + +# 4.13.0 / 2022-03-30 + +* [FEATURE] Allow enabling CWS and CSPM [#843][] [@lebauce][] +* [FEATURE] Add support for AlmaLinux and Rocky Linux [#836][] [@bkabrda][] +* [FEATURE] Add `monitor_unlisted_consumer_groups` and `kafka_consumer_offsets` to kafka_consumer [#834][] [@ganeshkumarsv][] +* [BUGFIX] Specify package epoch on RH-like platforms to ensure proper upgrade path [#839][] [@bkabrda][] +* [BUGFIX] Use the correct socket for system probe on Windows [#833][] [@julien-lebot][] +* [BUGFIX] Add is_jmx by default to jmxfetch checks [#792][] [@albertvaka][] + +# 4.12.0 / 2021-12-03 + +* [FEATURE] Added support for Chef 18+. [@axl89][] [#822][] +* [FEATURE] Enabled unified mode on compatible platforms since it will be the default on Chef 18. See [CHEF-33](https://docs.chef.io/deprecations_unified_mode/) deprecation. [@axl89][] [#822][] +* [FEATURE] Include `dogstatsd_port` in `datadog.yaml` for Agent 6 and Agent 7 [@brentm5][] [#828][] +* [BUGFIX] Ignore `apt update` failures to keep running if some sources are offline [#830][] [@bkabrda][] + +# 4.11.1 / 2021-08-24 + +* [BUGFIX] Support cookbook renaming [#810][] [@lchayoun][] +* [BUGFIX] Use YAML.dump instead of to_yaml [#813][] [@mbaitelman][] + +# 4.11.0 / 2021-08-10 + +* [FEATURE] Get keys from keys.datadoghq.com, not Ubuntu keyserver, and other improvements to APT keys management [#796][] [@bkabrda][] +* [FEATURE] Install datadog-signing-keys on Debian based platforms [#804][] [@bkabrda][] +* [BUGFIX] Ensure NPM is not turned off by default when system probe is enabled [#799][] [@bkabrda][] +* [BUGFIX] Integration resource notifies a restart of the Agent after installing a new version [#806][] [@lchayoun][] +* [BUGFIX] On Windows, don't try to start NPM unless network_enabled is set [#803][] [] [@KSerrania][] + +# 4.10.0 / 2021-05-06 + +* [FEATURE] Support for NPM on Windows [#780][], [#781][] and [#784][] ([@mikezhu-dd][]) +* [FEATURE] Implement usage of multiple GPG keys in repofiles, get keys from keys.datadoghq.com [#782][] ([@bkabrda][]) +* [FEATURE] Enable yum repository repo_gpgcheck option for Red Hat platforms by default [#789][] and [#793][] ([@bkabrda][]) +* [BUGFIX] Added collect_default_metrics: true to kafka.d/conf.yaml [#786][] ([@nilskuehme][]) +* [BUGFIX] Set is_jmx in solr template [#791][] ([@albertvaka][]) + # 4.9.0 / 2021-02-17 * [FEATURE] allow muting a host during an MSI install [#778][] [@albertvaka][] * [FEATURE] Kafka recipe: allow setting any conf [#776][] [@albertvaka][] @@ -961,6 +1033,51 @@ A fix has gone in to `apt` 2.1.0 that relaxes this condition, and plays well wit [#776]: https://github.com/DataDog/chef-datadog/issues/776 [#777]: https://github.com/DataDog/chef-datadog/issues/777 [#778]: https://github.com/DataDog/chef-datadog/issues/778 +[#780]: https://github.com/DataDog/chef-datadog/issues/780 +[#781]: https://github.com/DataDog/chef-datadog/issues/781 +[#782]: https://github.com/DataDog/chef-datadog/issues/782 +[#784]: https://github.com/DataDog/chef-datadog/issues/784 +[#786]: https://github.com/DataDog/chef-datadog/issues/786 +[#789]: https://github.com/DataDog/chef-datadog/issues/789 +[#791]: https://github.com/DataDog/chef-datadog/issues/791 +[#792]: https://github.com/DataDog/chef-datadog/issues/792 +[#793]: https://github.com/DataDog/chef-datadog/issues/793 +[#796]: https://github.com/DataDog/chef-datadog/issues/796 +[#799]: https://github.com/DataDog/chef-datadog/issues/799 +[#803]: https://github.com/DataDog/chef-datadog/issues/803 +[#804]: https://github.com/DataDog/chef-datadog/issues/804 +[#806]: https://github.com/DataDog/chef-datadog/issues/806 +[#810]: https://github.com/DataDog/chef-datadog/issues/810 +[#813]: https://github.com/DataDog/chef-datadog/issues/813 +[#822]: https://github.com/DataDog/chef-datadog/issues/822 +[#828]: https://github.com/DataDog/chef-datadog/issues/828 +[#830]: https://github.com/DataDog/chef-datadog/issues/830 +[#833]: https://github.com/DataDog/chef-datadog/issues/833 +[#834]: https://github.com/DataDog/chef-datadog/issues/834 +[#836]: https://github.com/DataDog/chef-datadog/issues/836 +[#839]: https://github.com/DataDog/chef-datadog/issues/839 +[#843]: https://github.com/DataDog/chef-datadog/issues/843 +[#850]: https://github.com/DataDog/chef-datadog/issues/850 +[#852]: https://github.com/DataDog/chef-datadog/issues/852 +[#856]: https://github.com/DataDog/chef-datadog/issues/856 +[#858]: https://github.com/DataDog/chef-datadog/issues/858 +[#859]: https://github.com/DataDog/chef-datadog/issues/859 +[#860]: https://github.com/DataDog/chef-datadog/issues/860 +[#861]: https://github.com/DataDog/chef-datadog/issues/861 +[#863]: https://github.com/DataDog/chef-datadog/issues/863 +[#865]: https://github.com/DataDog/chef-datadog/issues/865 +[#867]: https://github.com/DataDog/chef-datadog/issues/867 +[#869]: https://github.com/DataDog/chef-datadog/issues/869 +[#874]: https://github.com/DataDog/chef-datadog/issues/874 +[#876]: https://github.com/DataDog/chef-datadog/issues/876 +[#877]: https://github.com/DataDog/chef-datadog/issues/877 +[#887]: https://github.com/DataDog/chef-datadog/issues/887 +[#888]: https://github.com/DataDog/chef-datadog/issues/888 +[#890]: https://github.com/DataDog/chef-datadog/issues/890 +[#891]: https://github.com/DataDog/chef-datadog/issues/891 +[#895]: https://github.com/DataDog/chef-datadog/issues/895 +[#896]: https://github.com/DataDog/chef-datadog/issues/896 +[#898]: https://github.com/DataDog/chef-datadog/issues/898 [@ABrehm264]: https://github.com/ABrehm264 [@AlexBevan]: https://github.com/AlexBevan [@Azraeht]: https://github.com/Azraeht @@ -983,9 +1100,11 @@ A fix has gone in to `apt` 2.1.0 that relaxes this condition, and plays well wit [@albertvaka]: https://github.com/albertvaka [@alexism]: https://github.com/alexism [@alq]: https://github.com/alq +[@amenasria]: https://github.com/amenasria [@antonio-osorio]: https://github.com/antonio-osorio [@arthurnn]: https://github.com/arthurnn [@asherf]: https://github.com/asherf +[@axl89]: https://github.com/axl89 [@aymen-chetoui]: https://github.com/aymen-chetoui [@azuretek]: https://github.com/azuretek [@babbottscott]: https://github.com/babbottscott @@ -993,6 +1112,7 @@ A fix has gone in to `apt` 2.1.0 that relaxes this condition, and plays well wit [@benmanns]: https://github.com/benmanns [@bflad]: https://github.com/bflad [@bitmonk]: https://github.com/bitmonk +[@bkabrda]: https://github.com/bkabrda [@borgilb]: https://github.com/borgilb [@brentm5]: https://github.com/brentm5 [@ccannell67]: https://github.com/ccannell67 @@ -1026,12 +1146,14 @@ A fix has gone in to `apt` 2.1.0 that relaxes this condition, and plays well wit [@flah00]: https://github.com/flah00 [@foobarto]: https://github.com/foobarto [@frezbo]: https://github.com/frezbo +[@ganeshkumarsv]: https://github.com/ganeshkumarsv [@gkze]: https://github.com/gkze [@gmmeyer]: https://github.com/gmmeyer [@graemej]: https://github.com/graemej [@gregf]: https://github.com/gregf [@grogancolin]: https://github.com/grogancolin [@gswallow]: https://github.com/gswallow +[@guyarb]: https://github.com/guyarb [@haidars]: https://github.com/haidars [@hartfordfive]: https://github.com/hartfordfive [@hilli]: https://github.com/hilli @@ -1063,9 +1185,12 @@ A fix has gone in to `apt` 2.1.0 that relaxes this condition, and plays well wit [@krasnoukhov]: https://github.com/krasnoukhov [@kurochan]: https://github.com/kurochan [@kylegoch]: https://github.com/kylegoch +[@lchayoun]: https://github.com/lchayoun +[@lebauce]: https://github.com/lebauce [@lefthand]: https://github.com/lefthand [@martinisoft]: https://github.com/martinisoft [@mattrobenolt]: https://github.com/mattrobenolt +[@mbaitelman]: https://github.com/mbaitelman [@mfischer-zd]: https://github.com/mfischer-zd [@mhebbar1]: https://github.com/mhebbar1 [@mikelaning]: https://github.com/mikelaning @@ -1119,3 +1244,7 @@ A fix has gone in to `apt` 2.1.0 that relaxes this condition, and plays well wit [@xt99]: https://github.com/xt99 [@yannmh]: https://github.com/yannmh [@zshenker]: https://github.com/zshenker +[@nichols2k]: https://github.com/nichols2k +[@chouetz]: https://github.com/chouetz +[@vigohe]: https://github.com/vigohe +[@paulcacheux]: https://github.com/paulcacheux diff --git a/Gemfile b/Gemfile index 10673ded..703f832d 100644 --- a/Gemfile +++ b/Gemfile @@ -3,18 +3,30 @@ source 'https://rubygems.org' chef_version = ENV.fetch('CHEF_VERSION', '14.10.9') gem 'rake' +gem 'rspec-expectations', '< 3.12.4' gem 'chef', "= #{chef_version}" gem 'cucumber-core', '~> 3.2.1' gem 'yaml' gem 'chefspec' gem 'berkshelf' -gem 'fauxhai-ng', '~> 7.5.1' +gem 'fauxhai-ng', '~> 8.3.1' gem 'cookstyle' -gem 'coveralls', '~> 0.8.19' gem 'test-kitchen' gem 'json_spec', '~> 1.1.4' gem 'kitchen-vagrant' gem 'kitchen-docker', '~> 2.3.0' +gem 'rbnacl', '~> 4.0.2' +gem 'rbnacl-libsodium', '~> 1.0.16' +gem 'bcrypt_pbkdf', '>= 1.0', '< 2.0' + +if RUBY_VERSION < '2.6.4' + gem 'term-ansicolor', '~> 1.8.0' +end +gem 'coveralls', '~> 0.8.19' + +if RUBY_VERSION >= '3.0.0' && RUBY_VERSION < '3.1.0' + gem 'uri', '= 0.10.1' +end if RUBY_VERSION < '2.4' gem 'json', '~> 2.4.1' diff --git a/Gemfile.lock b/Gemfile.lock index add28008..23d51f2c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - activesupport (6.0.3.4) + activesupport (6.0.6.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -78,6 +78,8 @@ GEM mixlib-config (>= 2.2.12, < 3.0) mixlib-shellout (~> 2.0) tomlrb (~> 1.2) + chef-utils (18.4.12) + concurrent-ruby chef-zero (14.0.17) ffi-yajl (~> 2.2) hashie (>= 2.0, < 4.0) @@ -110,7 +112,7 @@ GEM cucumber-tag_expressions (1.1.1) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - diff-lcs (1.4.4) + diff-lcs (1.5.1) docile (1.3.2) ed25519 (1.2.4) equalizer (0.0.11) @@ -118,7 +120,7 @@ GEM erubis (2.7.0) faraday (1.0.1) multipart-post (>= 1.2, < 3) - fauxhai-ng (7.5.1) + fauxhai-ng (8.3.1) net-ssh ffi (1.13.1) ffi-yajl (2.3.4) @@ -134,8 +136,9 @@ GEM gherkin (5.1.0) gssapi (1.3.0) ffi (>= 1.0.1) - gyoku (1.3.1) + gyoku (1.4.0) builder (>= 2.1.2) + rexml (~> 3.0) hashie (3.6.0) highline (1.7.10) httpclient (2.8.3) @@ -164,9 +167,9 @@ GEM logging (2.3.0) little-plugger (~> 1.1) multi_json (~> 1.14) - mini_portile2 (2.5.0) + mini_portile2 (2.8.5) minitar (0.9) - minitest (5.14.2) + minitest (5.22.3) mixlib-archive (1.0.7) mixlib-log mixlib-authentication (2.1.1) @@ -194,8 +197,8 @@ GEM net-ssh (>= 2.6.5) net-ssh-gateway (>= 1.2.0) net-telnet (0.1.1) - nokogiri (1.11.1) - mini_portile2 (~> 2.5.0) + nokogiri (1.13.10) + mini_portile2 (~> 2.8.0) racc (~> 1.4) nori (2.6.0) octokit (4.18.0) @@ -223,19 +226,23 @@ GEM polyglot (0.3.5) proxifier (1.0.3) public_suffix (4.0.6) - racc (1.5.2) + racc (1.7.3) rack (2.2.3) rainbow (3.0.0) - rake (13.0.1) + rake (13.2.1) + rbnacl (4.0.2) + ffi + rbnacl-libsodium (1.0.16) + rbnacl (>= 3.0.1) retryable (3.0.5) - rexml (3.2.4) + rexml (3.2.5) rspec (3.9.0) rspec-core (~> 3.9.0) rspec-expectations (~> 3.9.0) rspec-mocks (~> 3.9.0) rspec-core (3.9.3) rspec-support (~> 3.9.3) - rspec-expectations (3.9.2) + rspec-expectations (3.9.4) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.9.0) rspec-its (1.3.0) @@ -283,9 +290,9 @@ GEM net-ssh (>= 2.7) net-telnet (= 0.1.1) sfl - strings (0.2.0) + strings (0.2.1) strings-ansi (~> 0.2) - unicode-display_width (~> 1.5) + unicode-display_width (>= 1.5, < 3.0) unicode_utils (~> 1.4) strings-ansi (0.2.0) sync (0.5.0) @@ -293,8 +300,9 @@ GEM systemu (2.6.5) term-ansicolor (1.7.1) tins (~> 1.0) - test-kitchen (2.7.2) + test-kitchen (2.12.0) bcrypt_pbkdf (~> 1.0) + chef-utils (>= 16.4.35) ed25519 (~> 1.2) license-acceptance (>= 1.0.11, < 3.0) mixlib-install (~> 3.6) @@ -313,7 +321,7 @@ GEM tomlrb (1.3.0) treetop (1.6.11) polyglot (~> 0.3) - tty-box (0.6.0) + tty-box (0.7.0) pastel (~> 0.8) strings (~> 0.2.0) tty-cursor (~> 0.7) @@ -327,7 +335,7 @@ GEM tty-screen (~> 0.8) wisper (~> 2.0) tty-screen (0.8.1) - tzinfo (1.2.7) + tzinfo (1.2.11) thread_safe (~> 0.1) unicode-display_width (1.6.1) unicode_utils (1.4.0) @@ -358,30 +366,34 @@ GEM wisper (2.0.1) wmi-lite (1.0.5) yaml (0.1.0) - zeitwerk (2.4.0) + zeitwerk (2.6.13) PLATFORMS ruby DEPENDENCIES activesupport (~> 6.0.3) + bcrypt_pbkdf (>= 1.0, < 2.0) berkshelf chef (= 14.10.9) chefspec cookstyle coveralls (~> 0.8.19) cucumber-core (~> 3.2.1) - fauxhai-ng (~> 7.5.1) + fauxhai-ng (~> 8.3.1) foodcritic (~> 16.3.0) inflecto json_spec (~> 1.1.4) kitchen-docker (~> 2.3.0) kitchen-vagrant rake + rbnacl (~> 4.0.2) + rbnacl-libsodium (~> 1.0.16) + rspec-expectations (< 3.12.4) rubocop (~> 0.80.1) test-kitchen virtus yaml BUNDLED WITH - 1.17.3 + 2.3.26 diff --git a/LICENSE b/LICENSE index a213ba60..f49a4e16 100644 --- a/LICENSE +++ b/LICENSE @@ -1,13 +1,201 @@ -Copyright 2012, 2013, 2014, 2015, 2016 Datadog, Inc. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - http://www.apache.org/licenses/LICENSE-2.0 + 1. Definitions. -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..fbd8ad8c --- /dev/null +++ b/NOTICE @@ -0,0 +1,4 @@ +Datadog chef-datadog +Copyright [2011-Present] Datadog, Inc. + +This product includes software developed at Datadog (https://www.datadoghq.com/). \ No newline at end of file diff --git a/README.md b/README.md index 9cbb9be9..307e0a0d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The Datadog Chef recipes are used to deploy Datadog's components and configurati * Datadog Agent v6.x * Datadog Agent v5.x -**Note**: This page may refer to features that are not available for your selected version. Check the README of the +**Note**: This page may discuss features that are not available for your selected version. Check the README of the git tag or gem version for your version's documentation. ## Setup @@ -19,10 +19,12 @@ The Datadog Chef cookbook is compatible with `chef-client` >= 12.7. If you need The following platforms are supported: +* AlmaLinux (requires Chef 16 >= 16.10.8 or Chef >= 17.0.69) * Amazon Linux * CentOS * Debian * RedHat (RHEL 8 requires Chef >= 15) +* Rocky (requires Chef 16 >= 16.17.4 or Chef >= 17.1.35) * Scientific Linux * Ubuntu * Windows @@ -40,29 +42,14 @@ The following Opscode cookbooks are dependencies: #### Chef -**Chef 12 users**: Depending on your version of Chef 12, additional dependency constraints may apply: - -```ruby -# Chef < 12.14 -depends 'yum', '< 5.0' -``` - -```ruby -# Chef < 12.9 -depends 'apt', '< 6.0.0' -depends 'yum', '< 5.0' -``` - **Chef 13 users**: With Chef 13 and `chef_handler` 1.x, you may have trouble using the `dd-handler` recipe. The known workaround is to update your dependency to `chef_handler` >= 2.1. -**Chef 14 and 15 users**: To support Chef 12 and 13, the `datadog` cookbook has a dependency to the `chef_handler` cookbook, which is shipped as a resource in Chef 14. Unfortunately, it displays a deprecation message to Chef 14 and 15 users. - ### Installation 1. Add the cookbook to your Chef server with [Berkshelf][5] or [Knife][6]: ```text # Berksfile - cookbook 'datadog', '~> 4.0.0' + cookbook 'datadog', '~> 4.0' ``` ```shell @@ -93,23 +80,6 @@ depends 'yum', '< 5.0' 5. Wait for the next scheduled `chef-client` run or trigger it manually. -### Dockerized environment - -To build a Docker environment, use the files under `docker_test_env`: - -``` -cd docker_test_env -docker build -t chef-datadog-container . -``` - -To run the container use: - -``` -docker run -d -v /dev/vboxdrv:/dev/vboxdrv --privileged=true chef-datadog-container -``` - -Then attach a console to the container or use the VScode remote-container feature to develop inside the container. - #### Datadog attributes The following methods are available for adding your [Datadog API and application keys][4]: @@ -161,13 +131,13 @@ Follow the steps below to deploy the Datadog Agent with Chef on AWS OpsWorks: 2. Include the recipe in the `install-lifecycle` recipe: ```ruby - include_recipe 'datadog::dd-agent' + include_recipe '::dd-agent' ``` ### Integrations Enable Agent integrations by including the [recipe](#recipes) and configuration details in your role’s run-list and attributes. -**Note**: You can create additional integration recipes by using the [datadog_monitor](#datadog-monitor) resource. +**Note**: You can use the `datadog_monitor` resource for enabling Agent integrations without a recipe. Associate your recipes with the desired `roles`, for example `role:chef-client` should contain `datadog::dd-handler` and `role:base` should start the Agent with `datadog::dd-agent`. Below is an example role with the `dd-handler`, `dd-agent`, and `mongo` recipes: @@ -222,7 +192,7 @@ Some attribute names have changed from version 3.x to 4.x of the cookbook. Use t | Pin agent version | `'agent_version'` or `'agent6_version'` | `'agent_version'` for all versions | | Change package_action | `'agent_package_action'` or `'agent6_package_action'` | `'agent_package_action'` for all versions | | Change APT repo URL | `'aptrepo'` or `'agent6_aptrepo'` | `'aptrepo'` for all versions | -| Change APT repo dist | `'aptrepo_dist'` or `'agent6_aptrepo_dist'` | `'aptrepo_dist'` for all versions | +| Change APT repo distribution | `'aptrepo_dist'` or `'agent6_aptrepo_dist'` | `'aptrepo_dist'` for all versions | | Change YUM repo | `'yumrepo'` or `'agent6_yumrepo'` | `'yumrepo'` for all versions | | Change SUSE repo | `'yumrepo_suse'` or `'agent6_yumrepo_suse'` | `'yumrepo_suse'` for all versions | @@ -259,6 +229,26 @@ The following example downgrades to Agent v6. The same applies if you are downgr ) ``` +### Uninstall + +To uninstall the Agent, remove the `dd-agent` recipe and add the `remove-dd-agent` recipe with no attributes. + +### Custom Agent repository + +To use an Agent from a custom repository, you can set the `aptrepo` option. + +By default, this option is equal to `[signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg] apt.datadoghq.com`. If a custom value is set, another `signed-by` keyring can also be set `[signed-by=custom-repo-keyring-path] custom-repo`. + +The example below uses the staging repository: + +```ruby + default_attributes( + 'datadog' => { + 'aptrepo' => '[signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg] apt.datad0g.com', + } + } +``` + ## Recipes Access the [Datadog Chef recipes on GitHub][7]. @@ -275,14 +265,14 @@ The [dd-agent recipe][9] installs the Datadog Agent on the target system, sets y ### Handler -The [dd-handler recipe][11] installs the [chef-handler-datadog][12] gem and invokes the handler at the end of a Chef run to report the details to the newsfeed. +The [dd-handler recipe][11] installs the [chef-handler-datadog][12] gem and invokes the handler at the end of a Chef run to report the details to the news feed. ### DogStatsD To install a language-specific library that interacts with DogStatsD: - Ruby: [dogstatsd-ruby recipe][13] -- Python: Add a dependency on the `poise-python` cookbook to your custom/wrapper cookbook, and use the resource below. For more details, refer to the [poise-python repository][14]. +- Python: Add a dependency on the `poise-python` cookbook to your custom/wrapper cookbook, and use the resource below. For more details, see the [poise-python repository][14]. ```ruby python_package 'dogstatsd-python' # assumes python and pip are installed ``` @@ -292,7 +282,7 @@ To install a language-specific library that interacts with DogStatsD: To install a language-specific library for application tracing (APM): - Ruby: [ddtrace-ruby recipe][15] -- Python: Add a dependency on the `poise-python` cookbook to your custom/wrapper cookbook, and use the resource below. For more details, refer to the [poise-python repository][14]. +- Python: Add a dependency on the `poise-python` cookbook to your custom/wrapper cookbook, and use the resource below. For more details, see the [poise-python repository][14]. ```ruby python_package 'ddtrace' # assumes python and pip are installed ``` @@ -301,6 +291,16 @@ To install a language-specific library for application tracing (APM): There are many [recipes][7] to assist you with deploying Agent integration configuration files and dependencies. +### System-probe + +The [system-probe recipe][17] is automatically included by default. It writes the `system-probe.yaml` file. This behavior can be disabled by setting `node['datadog']['system_probe']['manage_config']` to false. + +To enable [Network Performance Monitoring][7] (NPM) in `system-probe.yaml`, set `node['datadog']['system_probe']['network_enabled']` to true. + +To enable [Universal Service Monitoring][7] (USM) in `system-probe.yaml`, set `node['datadog']['system_probe']['service_monitoring_enabled']` to true. + +**Note for Windows users**: NPM is supported on Windows with Agent v6.27+ and v7.27+. It ships as an optional component that is only installed if `node['datadog']['system_probe']['network_enabled']` is set to true when the Agent is installed or upgraded. Because of this, existing installations might need to do an uninstall and reinstall of the Agent once to install the NPM component, unless the Agent is upgraded at the same time. + ## Resources ### Integrations without recipes @@ -332,7 +332,7 @@ end | `instances` | The fields used to fill values under the `instances` section in the integration configuration file. | | `init_config` | The fields used to fill values under the the `init_config` section in the integration configuration file. | | `logs` | The fields used to fill values under the the `logs` section in the integration configuration file. | -| `use_integration_template` | Set to `true` (recommended) to use the default template, which writes the values of `instances`, `init_config`, and `logs` in the YAML under their respective keys. This defaults to `false` for backward compatibility, but will default to `true` in a future major version of the cookbook. | +| `use_integration_template` | Set to `true` (recommended) to use the default template, which writes the values of `instances`, `init_config`, and `logs` in the YAML under their respective keys. This defaults to `false` for backward compatibility, but may default to `true` in a future major version of the cookbook. | #### Example @@ -341,7 +341,7 @@ This example enables the ElasticSearch integration by using the `datadog_monitor **Note**: The Agent installation must be above this recipe in the run list. ```ruby -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' datadog_monitor 'elastic' do instances [{'url' => 'http://localhost:9200'}] @@ -384,22 +384,48 @@ This example installs version `1.11.0` of the ElasticSearch integration by using **Note**: The Agent installation must be above this recipe in the run list. ```ruby -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' datadog_integration 'datadog-elastic' do version '1.11.0' end ``` -To get the available versions of the integrations, refer to the integration-specific `CHANGELOG.md` in the [integrations-core repository][16]. +To get the available versions of the integrations, see the integration-specific `CHANGELOG.md` in the [integrations-core repository][16]. **Note**: For Chef Windows users, the `chef-client` must have read access to the `datadog.yaml` file when the `datadog-agent` binary available on the node is used by this resource. +## Development + +### Dockerized environment + +To build a Docker environment with which to run kitchen tests, use the files under `docker_test_env`: + +``` +cd docker_test_env +docker build -t chef-datadog-test-env . +``` + +To run the container use: + +``` +docker run -d -v /var/run/docker.sock:/var/run/docker.sock chef-datadog-test-env +``` + +Then attach a console to the container or use the VS Code remote-container feature to develop inside the container. + +To run kitchen-docker tests from within the container: + +``` +# Note: Also set KITCHEN_DOCKER_HOSTNAME=host.docker.internal if on MacOS or Windows +# Run this under a login shell (otherwise `bundle` won't be found) +KITCHEN_LOCAL_YAML=kitchen.docker.yml bundle exec rake circle +``` [1]: https://github.com/DataDog/chef-datadog/blob/master/attributes/default.rb [2]: https://github.com/DataDog/chef-datadog/releases/tag/v2.18.0 [3]: https://github.com/DataDog/chef-datadog/blob/master/CHANGELOG.md -[4]: https://app.datadoghq.com/account/settings#api +[4]: https://app.datadoghq.com/organization-settings/api-keys [5]: https://docs.chef.io/berkshelf/ [6]: https://docs.chef.io/knife/ [7]: https://github.com/DataDog/chef-datadog/tree/master/recipes @@ -412,3 +438,4 @@ To get the available versions of the integrations, refer to the integration-spec [14]: https://github.com/poise/poise-python [15]: https://github.com/DataDog/chef-datadog/blob/master/recipes/ddtrace-ruby.rb [16]: https://github.com/DataDog/integrations-core +[17]: https://github.com/DataDog/chef-datadog/blob/master/recipes/system-probe.rb diff --git a/attributes/cassandra.rb b/attributes/cassandra.rb index 3df57b70..72ea4d97 100644 --- a/attributes/cassandra.rb +++ b/attributes/cassandra.rb @@ -1 +1,15 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + default['datadog']['cassandra']['version'] = 1 diff --git a/attributes/default.rb b/attributes/default.rb index d466fd58..59156457 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Attributes:: default # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -42,9 +42,14 @@ default['datadog']['agent_version'] = nil # nil to install latest # Agent flavor to install, acceptable values are "datadog-agent", "datadog-iot-agent" default['datadog']['agent_flavor'] = 'datadog-agent' # "datadog-agent" to install the datadog-agent package +default['datadog']['fips_proxy_version'] = nil +# Datadog FIPS proxy package name: +default['datadog']['fips_proxy_package_name'] = 'datadog-fips-proxy' # "datadog-fips-proxy" to install the datadog-fips-proxy package # Allow override with `upgrade` to get latest (Linux only) default['datadog']['agent_package_action'] = 'install' +# Allow override with `upgrade` to get latest (Linux only) +default['datadog']['fips_proxy_package_action'] = 'install' # Agent package options # retries and retry_delay for package download/install @@ -54,6 +59,7 @@ # Allow downgrades of the agent (Linux only) # Note: on apt-based platforms, this will use the `--force-yes` option on the apt-get command. Use with caution. default['datadog']['agent_allow_downgrade'] = false +default['datadog']['fips_proxy_allow_downgrade'] = false ######################################################################## ### Agent 6/7 only attributes ### @@ -140,7 +146,7 @@ # If you're installing a pre-release version of the Agent (beta or RC), you need to: # * on debian: set node['datadog']['aptrepo_dist'] to 'beta' instead of 'stable' # * on RHEL: set node['datadog']['yumrepo'] to 'https://yum.datadoghq.com/beta/x86_64/' -default['datadog']['aptrepo'] = 'http://apt.datadoghq.com' +default['datadog']['aptrepo'] = nil # uses Datadog stable repos by default default['datadog']['aptrepo_dist'] = 'stable' default['datadog']['yumrepo'] = nil # uses Datadog stable repos by default default['datadog']['yumrepo_suse'] = nil # uses Datadog stable repos by default @@ -157,10 +163,10 @@ # to pin the version you're installing with node['datadog']['agent_version'] default['datadog']['installrepo'] = true default['datadog']['aptrepo_retries'] = 4 -default['datadog']['aptrepo_use_backup_keyserver'] = false -default['datadog']['aptrepo_keyserver'] = 'hkp://keyserver.ubuntu.com:80' -default['datadog']['aptrepo_backup_keyserver'] = 'hkp://pool.sks-keyservers.net:80' -default['datadog']['yumrepo_gpgkey'] = "#{yum_protocol}://keys.datadoghq.com/DATADOG_RPM_KEY.public" +# When repo_gpgcheck set to nil, it will get turned on in the code when +# not running on RHEL/CentOS <= 5 and not providing custom yumrepo. +# You can set it to true/false explicitly to override this behaviour. +default['datadog']['yumrepo_repo_gpgcheck'] = nil default['datadog']['yumrepo_proxy'] = nil default['datadog']['yumrepo_proxy_username'] = nil default['datadog']['yumrepo_proxy_password'] = nil @@ -175,8 +181,10 @@ # of the Agent will be signed with this key. # DATADOG_RPM_KEY_CURRENT always contains the key that is used to sign repodata and latest packages default['datadog']['yumrepo_gpgkey_new_current'] = "#{yum_protocol}://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public" -default['datadog']['yumrepo_gpgkey_new_e09422b3'] = "#{yum_protocol}://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public" +default['datadog']['yumrepo_gpgkey_new_4f09d16b'] = "#{yum_protocol}://keys.datadoghq.com/DATADOG_RPM_KEY_4F09D16B.public" +default['datadog']['yumrepo_gpgkey_new_b01082d3'] = "#{yum_protocol}://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public" default['datadog']['yumrepo_gpgkey_new_fd4bf915'] = "#{yum_protocol}://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public" +default['datadog']['yumrepo_gpgkey_new_e09422b3'] = "#{yum_protocol}://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public" # Windows Agent Blacklist # Attribute to enforce silent failures on agent installs when attempting to install a @@ -216,6 +224,8 @@ default['datadog']['windows_ddagentuser_password'] = nil # Since 7.27, the MSI has a switch to install NPM driver. Default to not install. Specify "true" to install. +# Note: If the Agent is already installed before setting this to true, this will have no effect until the Agent +# is either upgraded or uninstalled and installed again. Use the `remove-dd-agent` recipe to uninstall the Agent. default['datadog']['windows_npm_install'] = nil # Chef handler version @@ -248,6 +258,12 @@ # Start agent or not default['datadog']['agent_start'] = true +# Enable the fips-proxy to start at boot. +default['datadog']['fips_proxy_enable'] = true + +# Start fips_proxy or not +default['datadog']['fips_proxy_start'] = true + # installation info default['datadog']['install_info_enabled'] = true @@ -357,14 +373,26 @@ default['datadog']['process_agent']['container_interval'] = nil default['datadog']['process_agent']['rtcontainer_interval'] = nil +# Cloud Workload Security functionality settings +default['datadog']['security_agent']['cws']['enabled'] = false +default['datadog']['security_agent']['cspm']['enabled'] = false + # System probe functionality settings # Whether this cookbook should write system-probe.yaml or not. # If set to false all other system-probe settings are ignored default['datadog']['system_probe']['manage_config'] = true +# When `system_probe.enabled` is set to false and `network_enabled` is set to true, +# the NPM module of system probe will still run. default['datadog']['system_probe']['enabled'] = false # sysprobe_socket defines the unix socket location -default['datadog']['system_probe']['sysprobe_socket'] = '/opt/datadog-agent/run/sysprobe.sock' +default['datadog']['system_probe']['sysprobe_socket'] = + if platform_family?('windows') + 'localhost:3333' + else + '/opt/datadog-agent/run/sysprobe.sock' + end + # debug_port is the http port for expvar, it is disabled if set to 0 default['datadog']['system_probe']['debug_port'] = 0 default['datadog']['system_probe']['bpf_debug'] = false @@ -372,7 +400,10 @@ # Enable this switch will install NPM driver and sysprobe, as well as generate the config file. # Turning on this setting will effectively turn on the setting(s) automatically: # ['datadog']['system_probe']['enabled'] -default['datadog']['system_probe']['network_enabled'] = false +# When this is set to nil (default), `network_config` won't be rendered in system-probe.yaml, +# making the Agent use the default setting for this value. +default['datadog']['system_probe']['network_enabled'] = nil +default['datadog']['system_probe']['service_monitoring_enabled'] = nil # Logs functionality settings (Agent 6/7 only) # Set `enable_logs_agent` to: diff --git a/attributes/go-metro.rb b/attributes/go-metro.rb index 8da68958..c3f41595 100644 --- a/attributes/go-metro.rb +++ b/attributes/go-metro.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # The implementation for the go-metro recipe allows any package resource # property to be defined as an attribute underneath the # node['datadog']['go-metro']['libcap_package'] namespace diff --git a/attributes/kafka.rb b/attributes/kafka.rb index 45ceaf04..8165b807 100644 --- a/attributes/kafka.rb +++ b/attributes/kafka.rb @@ -1 +1,15 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + default['datadog']['kafka']['version'] = 1 diff --git a/attributes/network.rb b/attributes/network.rb index 00c30b21..a83bbf6e 100644 --- a/attributes/network.rb +++ b/attributes/network.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + default['datadog']['network']['instances'] = [ { 'collect_connection_state' => 'false', diff --git a/docker_test_env/Dockerfile b/docker_test_env/Dockerfile index a3214aef..eeb0d07f 100644 --- a/docker_test_env/Dockerfile +++ b/docker_test_env/Dockerfile @@ -1,25 +1,59 @@ -# docker run --rm -it -v /dev/vboxdrv:/dev/vboxdrv ARG BASE_IMAGE=ubuntu:20.04 FROM $BASE_IMAGE ARG TZ=America/New_York -ARG RUBY_VERSION=2.6 +ARG RUBY_VERSION=2.6.3 ENV TZ=$TZ ENV RUBY_VERSION=$RUBY_VERSION ENV DEBIAN_FRONTEND=noninteractive RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone -RUN apt-get update && apt-get install -y wget virtualbox git zlib1g-dev curl +RUN apt-get update && apt-get install -y wget git zlib1g-dev curl gpg # RVM -RUN gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB +RUN gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB RUN curl -sSL https://get.rvm.io | bash -s stable -RUN /bin/bash -l -c "rvm requirements" + +RUN /bin/bash -l -c "rvm requirements" # || cat /usr/local/rvm/log/*/*.log && false RUN /bin/bash -l -c "rvm install ${RUBY_VERSION} && rvm cleanup all" -RUN /bin/bash -l -c "gem install bundler --no-document" +RUN /bin/bash -l -c "gem install bundler:2.3.26 --no-document" + +RUN /bin/bash -l -c "gem install nori:2.6.0 test-kitchen:2.7.2 octokit:4.18.0 semverse:3.0.0 chef:14.10.9 berkshelf:7.0.10 kitchen-vagrant:1.7.0 kitchen-docker:2.3.0" + +# build with --build-arg INSTALL_VAGRANT=1 to get vagrant support (not needed for kitchen-docker-tests) +# requires `-v /dev/vboxdrv:/dev/vboxdrv` when running +ARG INSTALL_VAGRANT +RUN if [ -n "${INSTALL_VAGRANT}" ]; then \ + apt-get install -y virtualbox && wget https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb && dpkg -i vagrant_2.2.9_x86_64.deb && rm vagrant_2.2.9_x86_64.deb \ + ; fi + +# Install docker. Requires `-v /var/run/docker.sock:/var/run/docker.sock` when running to use the host's docker daemon +RUN \ + apt-get update && \ + apt-get install -y ca-certificates && \ + install -m 0755 -d /etc/apt/keyrings && \ + curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && \ + chmod a+r /etc/apt/keyrings/docker.asc && \ + # Add the repository to Apt sources: + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + tee /etc/apt/sources.list.d/docker.list > /dev/null && \ + apt-get update && \ + apt-get install -y docker-ce-cli -RUN /bin/bash -l -c "gem install test-kitchen berkshelfbundler kitchen-vagrant" -RUN wget https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb && dpkg -i vagrant_2.2.9_x86_64.deb && rm vagrant_2.2.9_x86_64.deb COPY entrypoint.sh /usr/bin/entrypoint.sh RUN chmod 755 /usr/bin/entrypoint.sh -ENTRYPOINT ["/usr/bin/entrypoint.sh"] + +# Apply patch kitchen-docker to make it possible to manually override the hostname for docker +# with the `KITCHEN_DOCKER_HOSTNAME` environment variable, which is necessary when working on non-native docker. +COPY docker.rb.patch / +RUN patch -p1 -i /docker.rb.patch + +# Helpful defaults to run kitchen tests +ENV DOCKER_BUILDKIT=0 \ + CIRCLE_NODE_TOTAL=1 \ + CIRCLE_NODE_INDEX=0 \ + CHEF_LICENSE=accept + +ENTRYPOINT ["/bin/bash", "-l", "-c", "/usr/bin/entrypoint.sh"] diff --git a/docker_test_env/docker.rb.patch b/docker_test_env/docker.rb.patch new file mode 100644 index 00000000..34eaa73a --- /dev/null +++ b/docker_test_env/docker.rb.patch @@ -0,0 +1,11 @@ +--- /usr/local/rvm/gems/ruby-2.6.3/gems/kitchen-docker-2.3.0/lib/kitchen/driver/docker.rb 2024-04-09 10:54:16.032712772 -0400 ++++ /docker.rb 2024-04-09 10:53:25.988909160 -0400 +@@ -103,6 +103,6 @@ + state[:ssh_key] = config[:private_key] + state[:image_id] = build_image(state) unless state[:image_id] + state[:container_id] = run_container(state) unless state[:container_id] +- state[:hostname] = remote_socket? ? socket_uri.host : 'localhost' ++ state[:hostname] = ENV['KITCHEN_DOCKER_HOSTNAME'] || (remote_socket? ? socket_uri.host : 'localhost') + state[:port] = container_ssh_port(state) + wait_for_sshd(state[:hostname], nil, :port => state[:port]) if config[:wait_for_sshd] + end \ No newline at end of file diff --git a/kitchen.docker.yml b/kitchen.docker.yml index e6c565d2..6d2b5e3f 100644 --- a/kitchen.docker.yml +++ b/kitchen.docker.yml @@ -3,6 +3,12 @@ driver: name: docker use_sudo: false +provisioner: + deprecations_as_errors: true + solo_rb: + silence_deprecation_warnings: + - chef-25 + platforms: # Exclude this OS for now, due to some odd behavior with the NTP check on CircleCI systems. # See https://circleci.com/gh/DataDog/chef-datadog/19 @@ -33,6 +39,19 @@ platforms: - name: debian-8.11 driver_config: require_chef_omnibus: 14.12 + # The Debian 8 (Jessie) GPG key expired on Sat Nov 19 2022 21:01:13 GMT+0000. + # This Docker image uses gpgv wrapper that ignores key expiration date but checks package signatures. + image: 'datadog/docker-library:chef_kitchen_apt_debian_8' + - name: rocky-8 + driver_config: + platform: rhel # kitchen-docker doesn't recognize rocky otherwise + require_chef_omnibus: 16.17.4 + image: 'datadog/docker-library:chef_kitchen_systemd_rocky_8' + run_command: /root/start.sh + # workaround https://github.com/chef/chef/issues/14034 which has been + # fixed, but only for fresh Chef versions (>= 18) + provision_command: + - echo "CentOS Linux release 8" > /etc/redhat-release suites: <% @@ -59,4 +78,8 @@ suites: - ubuntu-14.04 - debian-8.11 <% end %> + <% if %w(5).include?(agent_major_version) %> + excludes: + - centos-7.7 + <% end %> <% end %> diff --git a/kitchen.yml b/kitchen.yml index 756d42b9..2f8d7ddb 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -15,12 +15,16 @@ platforms: centos-6.6 centos-7.1 debian-7.8 + debian-9.13 + debian-10.11 + rockylinux-8.5 ) chef_versions = %w( 12.7.2 - 14 - 15 + 14.10.9 16.5 + 17 + 18 ) test_platforms.product(chef_versions).each do |platform_version, chef_version| @@ -103,6 +107,19 @@ suites: bpf_debug: true enable_conntrack: true +- name: security-agent + run_list: + - recipe[datadog::dd-agent] + attributes: + datadog: &DATADOG + aptrepo: 'http://apt.datad0g.com' + aptrepo_dist: 'beta' + api_key: somenonnullapikeythats32charlong + application_key: alsonotnil + security_agent: + cws: + enabled: true + - name: dd-handler run_list: - recipe[datadog::dd-handler] @@ -385,11 +402,13 @@ suites: kafka_consumer: instances: - kafka_connect_str: localhost:19092 - zk_connect_str: localhost:2181 - zk_prefix: /0.8 consumer_groups: my_consumer: my_topic: [0, 1, 4, 12] + monitor_unlisted_consumer_groups: true + zk_connect_str: localhost:2181 + zk_prefix: /0.8 + kafka_consumer_offsets: true - name: datadog_mesos_master run_list: @@ -590,3 +609,15 @@ suites: - host: localhost port: 49112 +- name: datadog_jboss_wildfly + run_list: + - recipe[datadog::jboss_wildfly] + attributes: + datadog: + <<: *DATADOG + jboss_wildfly: + init_config: + custom_jar_paths: ["/opt/wildfly/bin/client/jboss-client.jar"] + instances: + - jmx_url: localhost:9990 + tools_jar_path: /opt/wildfly/bin/client/jboss-client.jar diff --git a/libraries/recipe_helpers.rb b/libraries/recipe_helpers.rb index 37b38150..0ec4f3fa 100644 --- a/libraries/recipe_helpers.rb +++ b/libraries/recipe_helpers.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + class Chef # Helper class for Datadog Chef recipes class Datadog @@ -7,24 +21,48 @@ class << self datadog-iot-agent ].freeze - def agent_version(node) - dd_agent_version = node['datadog']['agent_version'] - if dd_agent_version.respond_to?(:each_pair) + # This method stores a variable that is used across recipes so we needed a place to define it. + # Global variables like this are usually set in the attributes/default.rb file for users to edit them. + # We don't want this variable to be changed by the user though, hence the place. + def apt_sources_list_file + '/etc/apt/sources.list.d/datadog.list' + end + + def chef_version_ge?(version) + Gem::Requirement.new(">= #{version}").satisfied_by?(Gem::Version.new(Chef::VERSION)) + end + + def compute_version(node, attribute) + dd_version = node['datadog'][attribute] + if dd_version.respond_to?(:each_pair) platform_family = node['platform_family'] # Unless explicitly listed, treat fedora and amazon as rhel - if !dd_agent_version.include?(platform_family) && ['fedora', 'amazon'].include?(platform_family) + if !dd_version.include?(platform_family) && ['fedora', 'amazon'].include?(platform_family) platform_family = 'rhel' end - dd_agent_version = dd_agent_version[platform_family] + dd_version = dd_version[platform_family] end - if !dd_agent_version.nil? && dd_agent_version.match(/^[0-9]+\.[0-9]+\.[0-9]+((?:~|-)[^0-9\s-]+[^-\s]*)?$/) - if node['platform_family'] == 'suse' || node['platform_family'] == 'debian' - dd_agent_version = '1:' + dd_agent_version + '-1' - elsif node['platform_family'] == 'rhel' || node['platform_family'] == 'fedora' || node['platform_family'] == 'amazon' - dd_agent_version += '-1' + if !dd_version.nil? && dd_version.match(/^[0-9]+\.[0-9]+\.[0-9]+((?:~|-)[^0-9\s-]+[^-\s]*)?$/) + # For RHEL-based distros: + # - we can only add epoch and release when running Chef >= 14, as Chef < 14 + # has different yum logic that doesn't know how to work with epoch and release + # - for Chef < 14, we only add release + if %w[debian suse].include?(node['platform_family']) || + (%w[amazon fedora rhel].include?(node['platform_family']) && chef_version_ge?(14)) + dd_version = '1:' + dd_version + '-1' + elsif %w[amazon fedora rhel].include?(node['platform_family']) + dd_version += '-1' end end - dd_agent_version + dd_version + end + + def agent_version(node) + compute_version(node, 'agent_version') + end + + def fips_proxy_version(node) + compute_version(node, 'fips_proxy_version') end def agent_major_version(node) @@ -102,6 +140,10 @@ def cookbook_version(run_context) run_context.cookbook_collection['datadog'].version end + def systemd_platform?(node) + (node['platform'] == 'amazon' || node['platform_family'] == 'amazon') && node['platform_version'].to_i >= 2022 + end + def upstart_platform?(node) agent_major_version(node) > 5 && (((node['platform'] == 'amazon' || node['platform_family'] == 'amazon') && node['platform_version'].to_i != 2) || @@ -116,6 +158,9 @@ def service_provider(node) service_provider = Chef::Provider::Service.const_get(specified_provider) end service_provider + # Specific catch for Amazon Linux >= 2022 where Upstart doesn't work + elsif systemd_platform?(node) + Chef::Provider::Service::Systemd elsif upstart_platform?(node) Chef::Provider::Service::Upstart end @@ -157,18 +202,21 @@ def must_reinstall?(node) private include Chef::Mixin::ShellOut - def agent_status - return nil unless File.exist?(WIN_BIN_PATH) - shell_out("\"#{WIN_BIN_PATH}\" status").stdout.strip + def agent_get_version + return nil unless File.file?(WIN_BIN_PATH) + shell_out("\"#{WIN_BIN_PATH}\" version -n").stdout.strip end def fetch_current_version - status = agent_status - return nil if status.nil? - match_data = status.match(/^Agent \(v(.*)\)/) - - # Nightlies like 6.20.0-devel+git.38.cd7f989 fail to parse as Gem::Version because of the '+' sign - version = match_data[1].tr('+', '-') if match_data + raw_version = agent_get_version + return nil if raw_version.nil? + match_data = raw_version.match(/^Agent ([^\s]*) (- Meta: ([^\s]*) )?- Commit/) + # will fail if raw_version is empty (agent_get_version cmd fails) + version = match_data[1] if match_data + nightly_version = match_data[3] if match_data[2] + # If the Meta tag is catched, we'll add it to the version to specify the nightly version we're using + # Nightlies like 6.20.0-devel+git.38.cd7f989 fail to parse as Gem::Version because of the '+' sign so let's use '-' + version = version + '-' + nightly_version if nightly_version Gem::Version.new(version) if version end @@ -186,7 +234,7 @@ def chef_version_can_uninstall? # because they cannot correctly fetch the registry keys of 64 bits # applications for uninstallation so we are only using the downgrade # feature on chef >= to 14 - Gem::Requirement.new('>= 14').satisfied_by?(Gem::Version.new(Chef::VERSION)) + Chef::Datadog.chef_version_ge? 14 end end end diff --git a/libraries/test_helpers.rb b/libraries/test_helpers.rb index 595f846a..0e084466 100644 --- a/libraries/test_helpers.rb +++ b/libraries/test_helpers.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + class Mock class ShellCommandResult @stdout = '' diff --git a/metadata.rb b/metadata.rb index 19093c72..599d8a90 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,7 +3,7 @@ maintainer_email 'package@datadoghq.com' license 'Apache-2.0' description 'Installs/Configures datadog components' -version '4.9.0' +version '4.19.0' chef_version '>= 12.7' source_url 'https://github.com/DataDog/chef-datadog' issues_url 'https://github.com/DataDog/chef-datadog/issues' @@ -22,6 +22,31 @@ supports os end -depends 'chef_handler', '>= 1.2' -depends 'apt' # Use '< 6.0.0' with Chef < 12.9 -depends 'yum', '>= 3.0' # Use '< 5.0' with Chef < 12.14 +current_chef_version = if Chef::VERSION.instance_of? String + # For Chef < 13.1.33 Chef::VERSION was a String + Gem::Version.new(Chef::VERSION.to_f) + else + # Else Chef::VERSION is already a VersionString + Chef::VERSION + end + +if current_chef_version < Gem::Version.new(14) + # The chef_handler cookbook is shipped as part of Chef >= 14, + # so from Chef >= 14 chef_handler cookbook is deprecated. + depends 'chef_handler', '>= 1.2' +end + +# Use '< 6.0.0' with Chef < 12.9 +if current_chef_version < Gem::Version.new(12.9) + depends 'apt', '< 6.0' +else + depends 'apt' +end + +# Must be '>= 3.0' and '< 5.0' with Chef < 12.14 +# Chef allows only one constraint and '~> 3.0' means '>= 3.0' and '< 4.0' +if current_chef_version < Gem::Version.new(12.14) + depends 'yum', '~> 3.0' +else + depends 'yum', '>= 3.0' +end diff --git a/recipes/_agent6_config.rb b/recipes/_agent6_config.rb index 5bbaf09f..a9fe1b28 100644 --- a/recipes/_agent6_config.rb +++ b/recipes/_agent6_config.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: _agent6_config # -# Copyright:: 2011-2017, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/recipes/_install-fips-proxy-linux.rb b/recipes/_install-fips-proxy-linux.rb new file mode 100644 index 00000000..e0312885 --- /dev/null +++ b/recipes/_install-fips-proxy-linux.rb @@ -0,0 +1,76 @@ +# +# Cookbook:: datadog +# Recipe:: _install-fips-proxy-linux +# +# Copyright:: 2011-2015, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Install the Apt/Yum repository if enabled +include_recipe '::repository' if node['datadog']['installrepo'] + +dd_fips_proxy_version = Chef::Datadog.fips_proxy_version(node) +dd_fips_proxy_package_name = node['datadog']['fips_proxy_package_name'] + +package_action = node['datadog']['fips_proxy_package_action'] + +package_retries = node['datadog']['agent_package_retries'] +package_retry_delay = node['datadog']['agent_package_retry_delay'] + +# Install the regular package +case node['platform_family'] +when 'debian' + apt_package dd_fips_proxy_package_name do + version dd_fips_proxy_version + retries package_retries unless package_retries.nil? + retry_delay package_retry_delay unless package_retry_delay.nil? + action package_action # default is :install + options '--force-yes' if node['datadog']['fips_proxy_allow_downgrade'] + end + + apt_package 'datadog-signing-keys' do + retries package_retries unless package_retries.nil? + retry_delay package_retry_delay unless package_retry_delay.nil? + action :upgrade + end +when 'rhel', 'fedora', 'amazon' + if platform_family?('rhel') && node['platform_version'].to_i >= 8 && !platform?('amazon') || + platform_family?('fedora') && node['platform_version'].to_i >= 28 + # yum_package doesn't work on RHEL 8 and Fedora >= 28 + # dnf_package only works on RHEL 8 / Fedora >= 28 if Chef 15+ is used + dnf_package dd_fips_proxy_package_name do + version dd_fips_proxy_version + retries package_retries unless package_retries.nil? + retry_delay package_retry_delay unless package_retry_delay.nil? + action package_action # default is :install + end + else + yum_package dd_fips_proxy_package_name do + version dd_fips_proxy_version + retries package_retries unless package_retries.nil? + retry_delay package_retry_delay unless package_retry_delay.nil? + action package_action # default is :install + allow_downgrade node['datadog']['fips_proxy_allow_downgrade'] + end + end +when 'suse' + zypper_package dd_fips_proxy_package_name do # ~FC009 + version dd_fips_proxy_version + retries package_retries unless package_retries.nil? + retry_delay package_retry_delay unless package_retry_delay.nil? + action package_action # default is :install + # allow_downgrade is only suported for zypper_package since Chef Client 13.6 + allow_downgrade node['datadog']['fips_proxy_allow_downgrade'] if respond_to?(:allow_downgrade) + end +end diff --git a/recipes/_install-linux.rb b/recipes/_install-linux.rb index d27ac2b0..846835f8 100644 --- a/recipes/_install-linux.rb +++ b/recipes/_install-linux.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: _install-linux # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ # # Install the Apt/Yum repository if enabled -include_recipe 'datadog::repository' if node['datadog']['installrepo'] +include_recipe '::repository' if node['datadog']['installrepo'] dd_agent_version = Chef::Datadog.agent_version(node) dd_agent_flavor = Chef::Datadog.agent_flavor(node) @@ -38,10 +38,32 @@ action package_action # default is :install options '--force-yes' if node['datadog']['agent_allow_downgrade'] end + + apt_package 'datadog-signing-keys' do + retries package_retries unless package_retries.nil? + retry_delay package_retry_delay unless package_retry_delay.nil? + action :upgrade + end when 'rhel', 'fedora', 'amazon' - if platform_family?('rhel') && node['platform_version'].to_i >= 8 && !platform?('amazon') || - platform_family?('fedora') && node['platform_version'].to_i >= 28 - # yum_package doesn't work on RHEL 8 and Fedora >= 28 + # Centos < 7 was deprecated on agent {6,7}.52 + agent_major_version = Chef::Datadog.agent_major_version(node) + if agent_major_version.to_i >= 6 && platform_family?('rhel') && node['platform_version'].to_i < 7 + agent_minor_version = Chef::Datadog.agent_minor_version(node) + if dd_agent_version && agent_minor_version && agent_minor_version >= 52 + # Error out with a useful message when the version was pinned to an unsupported one + Chef::Log.error("Agent versions #{agent_major_version}.52 and above not supported by current OS (RHEL < 7 equivalent).") + raise + else + # Set an upper bound for the package when the version was left unpinned + # Bounds like this one need to go on the package name, they're not supported on the version field + dd_agent_flavor = "#{dd_agent_flavor} < 1:#{agent_major_version}.52.0-1" + end + end + + if (platform_family?('rhel') && node['platform_version'].to_i >= 8) || + (platform_family?('fedora') && node['platform_version'].to_i >= 28) || + (platform_family?('amazon') && node['platform_version'].to_i >= 2022) + # yum_package doesn't work on RHEL >= 8, Fedora >= 28 and AmazonLinux >=2022 # dnf_package only works on RHEL 8 / Fedora >= 28 if Chef 15+ is used dnf_package dd_agent_flavor do version dd_agent_version diff --git a/recipes/_install-windows.rb b/recipes/_install-windows.rb index 6dd51b97..92954790 100644 --- a/recipes/_install-windows.rb +++ b/recipes/_install-windows.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: _install-windows # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,9 @@ # limitations under the License. # -include_recipe 'chef_handler' +if Chef::VERSION < Gem::Version.new(14) + include_recipe 'chef_handler' +end dd_agent_flavor = Chef::Datadog.agent_flavor(node) diff --git a/recipes/active_directory.rb b/recipes/active_directory.rb index 7f5009a6..0dcf8cbc 100644 --- a/recipes/active_directory.rb +++ b/recipes/active_directory.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Active Directory # diff --git a/recipes/activemq.rb b/recipes/activemq.rb index f739c8bc..e6e17cf0 100644 --- a/recipes/activemq.rb +++ b/recipes/activemq.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor activemq # diff --git a/recipes/activemq_xml.rb b/recipes/activemq_xml.rb index 30079caa..d0c1a2b1 100644 --- a/recipes/activemq_xml.rb +++ b/recipes/activemq_xml.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor ActiveMQ XML # diff --git a/recipes/aerospike.rb b/recipes/aerospike.rb index 669c4305..1a8390b9 100644 --- a/recipes/aerospike.rb +++ b/recipes/aerospike.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Aerospike # diff --git a/recipes/airflow.rb b/recipes/airflow.rb index a84a9376..f7871858 100644 --- a/recipes/airflow.rb +++ b/recipes/airflow.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Airflow # diff --git a/recipes/amazon_msk.rb b/recipes/amazon_msk.rb index 629cd7f4..68d8528e 100644 --- a/recipes/amazon_msk.rb +++ b/recipes/amazon_msk.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Amazon Kafka # diff --git a/recipes/ambari.rb b/recipes/ambari.rb index 1c767727..1d018376 100644 --- a/recipes/ambari.rb +++ b/recipes/ambari.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Ambari # diff --git a/recipes/apache.rb b/recipes/apache.rb index ab0a54bc..0287a65f 100644 --- a/recipes/apache.rb +++ b/recipes/apache.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor apache # diff --git a/recipes/aspdotnet.rb b/recipes/aspdotnet.rb index 4c94cc5c..3b9ec09f 100644 --- a/recipes/aspdotnet.rb +++ b/recipes/aspdotnet.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor ASP.NET # diff --git a/recipes/btrfs.rb b/recipes/btrfs.rb index ff2c16ec..0c6251d3 100644 --- a/recipes/btrfs.rb +++ b/recipes/btrfs.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Btrfs # diff --git a/recipes/cacti.rb b/recipes/cacti.rb index 85de0dc1..c612a762 100644 --- a/recipes/cacti.rb +++ b/recipes/cacti.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Import cacti data # diff --git a/recipes/cassandra.rb b/recipes/cassandra.rb index 2fd2d12a..029b8c64 100644 --- a/recipes/cassandra.rb +++ b/recipes/cassandra.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Cassandra diff --git a/recipes/cassandra_nodetool.rb b/recipes/cassandra_nodetool.rb index 80cb2645..3b2fa4ec 100644 --- a/recipes/cassandra_nodetool.rb +++ b/recipes/cassandra_nodetool.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Cassandra Nodetool # diff --git a/recipes/ceph.rb b/recipes/ceph.rb index acb168ca..833bc1af 100644 --- a/recipes/ceph.rb +++ b/recipes/ceph.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Ceph # diff --git a/recipes/cilium.rb b/recipes/cilium.rb index f0b97681..81131043 100644 --- a/recipes/cilium.rb +++ b/recipes/cilium.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Cilium # diff --git a/recipes/cisco_aci.rb b/recipes/cisco_aci.rb index 9a4c8a12..5346ee3b 100644 --- a/recipes/cisco_aci.rb +++ b/recipes/cisco_aci.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Cisco ACI # diff --git a/recipes/clickhouse.rb b/recipes/clickhouse.rb index c17c8533..29e0fba8 100644 --- a/recipes/clickhouse.rb +++ b/recipes/clickhouse.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor ClickHouse # diff --git a/recipes/cloud_foundry_api.rb b/recipes/cloud_foundry_api.rb index d1ba854e..70926964 100644 --- a/recipes/cloud_foundry_api.rb +++ b/recipes/cloud_foundry_api.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Cloud Foundry API # diff --git a/recipes/cockroachdb.rb b/recipes/cockroachdb.rb index 1b3ff9ab..6b3c7bd6 100644 --- a/recipes/cockroachdb.rb +++ b/recipes/cockroachdb.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor CockroachDB # diff --git a/recipes/confluent_platform.rb b/recipes/confluent_platform.rb index 7b2af97e..7b58f488 100644 --- a/recipes/confluent_platform.rb +++ b/recipes/confluent_platform.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Confluent Platform # @@ -89,6 +103,7 @@ init_config node['datadog']['confluent_platform']['init_config'] instances node['datadog']['confluent_platform']['instances'] logs node['datadog']['confluent_platform']['logs'] + is_jmx true use_integration_template true action :add notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start'] diff --git a/recipes/consul.rb b/recipes/consul.rb index 73dd76f3..7b75ddd6 100644 --- a/recipes/consul.rb +++ b/recipes/consul.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor consul # diff --git a/recipes/couchbase.rb b/recipes/couchbase.rb index 788145b4..49cb9c6b 100644 --- a/recipes/couchbase.rb +++ b/recipes/couchbase.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor couchbase # diff --git a/recipes/couchdb.rb b/recipes/couchdb.rb index d1bc60a4..96ef49f9 100644 --- a/recipes/couchdb.rb +++ b/recipes/couchdb.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor couchDB # diff --git a/recipes/custom_log_collection.rb b/recipes/custom_log_collection.rb new file mode 100644 index 00000000..fc9b1ee2 --- /dev/null +++ b/recipes/custom_log_collection.rb @@ -0,0 +1,33 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' + +# node.default['datadog']['custom_log_collection']['logs'] = [ +# { +# 'type' => 'file', +# 'path' => '', +# 'source' => '', +# 'tags' => [ +# 'tag1:value1', +# 'tag2:value2' +# ] +# } +# ] + +datadog_monitor 'custom_log_collection' do + logs node['datadog']['custom_log_collection']['logs'] + action :add + notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start'] +end diff --git a/recipes/dd-agent.rb b/recipes/dd-agent.rb index 27672ba0..73b5073c 100644 --- a/recipes/dd-agent.rb +++ b/recipes/dd-agent.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: dd-agent # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -43,9 +43,9 @@ # Install the agent if is_windows - include_recipe 'datadog::_install-windows' + include_recipe '::_install-windows' else - include_recipe 'datadog::_install-linux' + include_recipe '::_install-linux' end if !node['datadog']['agent_enable'] && node['datadog']['enable_process_agent'] @@ -67,7 +67,7 @@ # the node's run_list and set the relevant attributes # if agent_major_version > 5 - include_recipe 'datadog::_agent6_config' + include_recipe '::_agent6_config' agent_config_dir = is_windows ? "#{ENV['ProgramData']}/Datadog" : '/etc/datadog-agent' directory agent_config_dir do if is_windows @@ -159,15 +159,23 @@ def template_vars system_probe_managed = node['datadog']['system_probe']['manage_config'] agent_version_greater_than_6_11 = agent_major_version > 5 && (agent_minor_version.nil? || agent_minor_version > 11) || agent_major_version > 6 agent_version_greater_than_6_26 = agent_major_version > 5 && (agent_minor_version.nil? || agent_minor_version > 26) +agent_version_greater_than_6_49 = agent_major_version > 5 && (agent_minor_version.nil? || agent_minor_version > 49) # System probe requires at least agent 6.12 on Linux or 6.27 on Windows, before that it was called the network-tracer or unsupported. system_probe_supported = (agent_version_greater_than_6_11 && !is_windows) || (agent_version_greater_than_6_26 && is_windows) # system-probe is a dependency of the agent on Linux or Windows -include_recipe 'datadog::system-probe' if system_probe_managed && system_probe_supported +include_recipe '::system-probe' if system_probe_managed && system_probe_supported + +# Security Agent requires at least agent 6.27 on Linux or 6.50 on Windows, before that it was unsupported. +security_agent_managed = node['datadog']['security_agent']['cws']['enabled'] || (!is_windows && node['datadog']['security_agent']['cspm']['enabled']) +security_agent_supported = (agent_version_greater_than_6_26 && !is_windows) || (agent_version_greater_than_6_49 && is_windows) + +# security-agent is a dependency of the agent on Linux or Windows +include_recipe '::security-agent' if security_agent_managed && security_agent_supported # Installation metadata to let know the agent about installation method and its version -include_recipe 'datadog::install_info' +include_recipe '::install_info' # Install integration packages -include_recipe 'datadog::integrations' unless is_windows +include_recipe '::integrations' unless is_windows diff --git a/recipes/dd-fips-proxy.rb b/recipes/dd-fips-proxy.rb new file mode 100644 index 00000000..5b70200a --- /dev/null +++ b/recipes/dd-fips-proxy.rb @@ -0,0 +1,61 @@ +# +# Cookbook:: datadog +# Recipe:: dd-fips-proxy +# +# Copyright:: 2011-2015, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'yaml' # Our erb templates need this + +is_windows = platform_family?('windows') + +# Install the fips-proxy +if is_windows + raise 'Windows currently unsupported for the datadog FIPS proxy.' +else + include_recipe '::_install-fips-proxy-linux' +end + +# Set the Datadog FIPS proxy service enable or disable +fips_proxy_enable = node['datadog']['fips_proxy_enable'] ? :enable : :disable +# Set the Datadog FIPS proxy service startup action +fips_proxy_start = node['datadog']['fips_proxy_start'] ? :start : :stop + +# Common configuration +service_provider = Chef::Datadog.service_provider(node) + +service_name = 'datadog-fips-proxy' + +file '/etc/datadog-fips-proxy/datadog-fips-proxy.cfg' do + owner 'root' + group 'root' + mode '0766' + content lazy { ::File.open('/etc/datadog-fips-proxy/datadog-fips-proxy.cfg.example').read } + not_if { ::File.exist?('/etc/datadog-fips-proxy/datadog-fips-proxy.cfg') } + notifies :restart, 'service[datadog-fips-proxy]' if node['datadog']['fips_proxy_start'] + action :create +end + +service 'datadog-fips-proxy' do + service_name service_name + action [fips_proxy_enable, fips_proxy_start] + provider service_provider unless service_provider.nil? + supports :restart => true, :status => true, :start => true, :stop => true + + # HACK: the restart can fail when we hit systemd's restart limits (by default, 5 starts every 10 seconds) + # To workaround this, retry once after 5 seconds, and a second time after 10 seconds + retries 2 + retry_delay 5 +end diff --git a/recipes/dd-handler.rb b/recipes/dd-handler.rb index f009ba1a..a95ae468 100644 --- a/recipes/dd-handler.rb +++ b/recipes/dd-handler.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: dd-handler # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/recipes/ddtrace-ruby.rb b/recipes/ddtrace-ruby.rb index e00a1453..95da742b 100644 --- a/recipes/ddtrace-ruby.rb +++ b/recipes/ddtrace-ruby.rb @@ -2,6 +2,19 @@ # Cookbook:: datadog # Recipe:: ddtrace-ruby.rb # +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. gem_package 'ddtrace' do version node['datadog']['ddtrace_gem_version'] diff --git a/recipes/default.rb b/recipes/default.rb index c1b693b4..ee50110b 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: default # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/recipes/directory.rb b/recipes/directory.rb index 30c7fd63..5629ca4e 100644 --- a/recipes/directory.rb +++ b/recipes/directory.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor files in a directory # diff --git a/recipes/disk.rb b/recipes/disk.rb index 778c9504..1d5e6da7 100644 --- a/recipes/disk.rb +++ b/recipes/disk.rb @@ -2,6 +2,20 @@ # Cookbook:: datadog # Recipe:: disk # +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# # This recipe exists to apply (optional) configuration to the disk integration # This recipe does not need to be included to use the disk integration, # but it allows you to override some defaults that the disk integration @@ -9,7 +23,7 @@ # For more information on the integration itself, see: # https://docs.datadoghq.com/integrations/disk/ -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' # example configuration: # node['datadog']['disk']['instances'] = [ diff --git a/recipes/dns_check.rb b/recipes/dns_check.rb index 23dcbb1b..75129aa5 100644 --- a/recipes/dns_check.rb +++ b/recipes/dns_check.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor dns # diff --git a/recipes/docker.rb b/recipes/docker.rb index 6ceaeb35..f9ca9a15 100644 --- a/recipes/docker.rb +++ b/recipes/docker.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: docker # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' # The docker check is deprecated in agent version 5.x. # Please use the docker_daemon check instead. diff --git a/recipes/docker_daemon.rb b/recipes/docker_daemon.rb index 9b357859..39d2f36a 100644 --- a/recipes/docker_daemon.rb +++ b/recipes/docker_daemon.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: docker_daemon # -# Copyright:: 2011-2016, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' # The docker_daemon check no longer exists in agent version 6.x. # Please use the docker check instead. diff --git a/recipes/dogstatsd-ruby.rb b/recipes/dogstatsd-ruby.rb index 50596a13..a6471d75 100644 --- a/recipes/dogstatsd-ruby.rb +++ b/recipes/dogstatsd-ruby.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: dogstatsd-ruby # -# Copyright:: 2013-2015, Datadog +# Copyright:: 2013-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/recipes/dotnetclr.rb b/recipes/dotnetclr.rb index ce436327..0465b43f 100644 --- a/recipes/dotnetclr.rb +++ b/recipes/dotnetclr.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor .NET CLR # diff --git a/recipes/druid.rb b/recipes/druid.rb index 10f85dfe..3fb33f81 100644 --- a/recipes/druid.rb +++ b/recipes/druid.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Druid # diff --git a/recipes/elasticsearch.rb b/recipes/elasticsearch.rb index 1a97999c..84ec3263 100644 --- a/recipes/elasticsearch.rb +++ b/recipes/elasticsearch.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor elasticsearch # diff --git a/recipes/envoy.rb b/recipes/envoy.rb index e118eab0..0a26d4dd 100644 --- a/recipes/envoy.rb +++ b/recipes/envoy.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Envoy # diff --git a/recipes/etcd.rb b/recipes/etcd.rb index 70da28fb..2b68f9b2 100644 --- a/recipes/etcd.rb +++ b/recipes/etcd.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor etcd # diff --git a/recipes/flink.rb b/recipes/flink.rb index 368be6d2..6e30e3ea 100644 --- a/recipes/flink.rb +++ b/recipes/flink.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor flink # diff --git a/recipes/fluentd.rb b/recipes/fluentd.rb index 5d7c4808..2f2cfa20 100644 --- a/recipes/fluentd.rb +++ b/recipes/fluentd.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor fluentd # diff --git a/recipes/gearmand.rb b/recipes/gearmand.rb new file mode 100644 index 00000000..75628c16 --- /dev/null +++ b/recipes/gearmand.rb @@ -0,0 +1,53 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' + +# All attributes are optional. +# node.default['datadog']['gearmand']['instances'] = [ +# { +# # Defaults to 127.0.0.1 if not set +# 'server' => '127.0.0.1', +# # Defaults to 4730 if not set +# 'port' => '4730', +# 'tasks' => [ +# 'TASK_1', +# 'TASK_2', +# ], +# 'tags' => [ +# ':', +# ':' +# ], +# 'service' => '', +# # Defaults to 15 if not set +# 'min_collection_interval' => 60, +# # Defaults to false if not set +# 'empty_default_hostname' => true, +# 'metric_patterns' => { +# 'include' => [ +# '' +# ], +# 'exclude' => [ +# '' +# ] +# } +# } +# ] + +datadog_monitor 'gearmand' do + instances node['datadog']['gearmand']['instances'] + logs node['datadog']['gearmand']['logs'] + action :add + notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start'] +end diff --git a/recipes/gitlab.rb b/recipes/gitlab.rb index f5bf48e9..800c4645 100644 --- a/recipes/gitlab.rb +++ b/recipes/gitlab.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Gitlab # diff --git a/recipes/gitlab_runner.rb b/recipes/gitlab_runner.rb index 42a1e036..9b020862 100644 --- a/recipes/gitlab_runner.rb +++ b/recipes/gitlab_runner.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Gitlab Runner # diff --git a/recipes/go-metro.rb b/recipes/go-metro.rb index 1e530368..9c1e3e6d 100644 --- a/recipes/go-metro.rb +++ b/recipes/go-metro.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Go-Metro (TCP RTT) Integration: Passively monitor TCP Round Trip Time # between the monitored host and others nodes on the network diff --git a/recipes/go_expvar.rb b/recipes/go_expvar.rb index f15f299a..18a537f9 100644 --- a/recipes/go_expvar.rb +++ b/recipes/go_expvar.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Go metrics exported via expvar # node['datadog']['go_expvar']['instances'] = [ diff --git a/recipes/gunicorn.rb b/recipes/gunicorn.rb index bbab3405..4c810602 100644 --- a/recipes/gunicorn.rb +++ b/recipes/gunicorn.rb @@ -2,6 +2,19 @@ # Cookbook:: datadog # Recipe:: gunicorn # +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # Monitor gunicorn # @@ -23,7 +36,7 @@ # # - proc_name: my_web_app -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' datadog_monitor 'gunicorn' do instances node['datadog']['gunicorn']['instances'] diff --git a/recipes/haproxy.rb b/recipes/haproxy.rb index dcb37440..416cd530 100644 --- a/recipes/haproxy.rb +++ b/recipes/haproxy.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor haproxy diff --git a/recipes/hazelcast.rb b/recipes/hazelcast.rb index d147593b..f5dd87f8 100644 --- a/recipes/hazelcast.rb +++ b/recipes/hazelcast.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Hazelcast # @@ -99,6 +113,7 @@ init_config node['datadog']['hazelcast']['init_config'] instances node['datadog']['hazelcast']['instances'] logs node['datadog']['hazelcast']['logs'] + is_jmx true use_integration_template true action :add notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start'] diff --git a/recipes/hdfs.rb b/recipes/hdfs.rb index 398454ef..2265e6f9 100644 --- a/recipes/hdfs.rb +++ b/recipes/hdfs.rb @@ -2,6 +2,19 @@ # Cookbook:: datadog # Recipe:: hdfs # +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # Monitor hdfs # @@ -22,7 +35,7 @@ # } # ] -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' datadog_monitor 'hdfs' do instances node['datadog']['hdfs']['instances'] diff --git a/recipes/hdfs_datanode.rb b/recipes/hdfs_datanode.rb index 5b4cebd5..4df88bb2 100644 --- a/recipes/hdfs_datanode.rb +++ b/recipes/hdfs_datanode.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor HDFS Datanode # diff --git a/recipes/hdfs_namenode.rb b/recipes/hdfs_namenode.rb index 2ed896d0..a7895616 100644 --- a/recipes/hdfs_namenode.rb +++ b/recipes/hdfs_namenode.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor HDFS Namenode # diff --git a/recipes/hive.rb b/recipes/hive.rb index 08a52ced..da2eaceb 100644 --- a/recipes/hive.rb +++ b/recipes/hive.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Hive # @@ -89,6 +103,7 @@ init_config node['datadog']['hive']['init_config'] instances node['datadog']['hive']['instances'] logs node['datadog']['hive']['logs'] + is_jmx true use_integration_template true action :add notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start'] diff --git a/recipes/hivemq.rb b/recipes/hivemq.rb index 8e254914..56f3e369 100644 --- a/recipes/hivemq.rb +++ b/recipes/hivemq.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor HiveMQ # @@ -89,6 +103,7 @@ init_config node['datadog']['hivemq']['init_config'] instances node['datadog']['hivemq']['instances'] logs node['datadog']['hivemq']['logs'] + is_jmx true use_integration_template true action :add notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start'] diff --git a/recipes/http_check.rb b/recipes/http_check.rb index 0ce00286..8828fa71 100644 --- a/recipes/http_check.rb +++ b/recipes/http_check.rb @@ -1,7 +1,21 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Build a data structure with configuration. -# @see http://docs.datadoghq.com/guides/network_checks/ +# @see https://docs.datadoghq.com/integrations/http_check/ # @example # node.override['datadog']['http_check']['instances'] = [ # { diff --git a/recipes/hyperv.rb b/recipes/hyperv.rb index b54f0566..4f89c7df 100644 --- a/recipes/hyperv.rb +++ b/recipes/hyperv.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor HyperV # diff --git a/recipes/ibm_mq.rb b/recipes/ibm_mq.rb index a394d6c3..da268e79 100644 --- a/recipes/ibm_mq.rb +++ b/recipes/ibm_mq.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor IBM MQ # diff --git a/recipes/ignite.rb b/recipes/ignite.rb index a785ecd2..8da655bc 100644 --- a/recipes/ignite.rb +++ b/recipes/ignite.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Ignite # @@ -89,6 +103,7 @@ init_config node['datadog']['ignite']['init_config'] instances node['datadog']['ignite']['instances'] logs node['datadog']['ignite']['logs'] + is_jmx true use_integration_template true action :add notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start'] diff --git a/recipes/iis.rb b/recipes/iis.rb index 51440c38..8c1a7dd4 100644 --- a/recipes/iis.rb +++ b/recipes/iis.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Integrate IIS metrics # diff --git a/recipes/install_info.rb b/recipes/install_info.rb index 957c9b48..09f68da2 100644 --- a/recipes/install_info.rb +++ b/recipes/install_info.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: install_info # -# Copyright:: 2011-2020, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/recipes/integrations.rb b/recipes/integrations.rb index 7a8abbde..1365bad7 100644 --- a/recipes/integrations.rb +++ b/recipes/integrations.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: integrations # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ # limitations under the License. # -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' # Install all specified integrations # example: diff --git a/recipes/istio.rb b/recipes/istio.rb index 73ef6754..8283de71 100644 --- a/recipes/istio.rb +++ b/recipes/istio.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Istio # diff --git a/recipes/jboss_wildfly.rb b/recipes/jboss_wildfly.rb index 8f06edfd..6233e763 100644 --- a/recipes/jboss_wildfly.rb +++ b/recipes/jboss_wildfly.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor JBoss/WildFly # @@ -89,6 +103,7 @@ init_config node['datadog']['jboss_wildfly']['init_config'] instances node['datadog']['jboss_wildfly']['instances'] logs node['datadog']['jboss_wildfly']['logs'] + is_jmx true use_integration_template true action :add notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start'] diff --git a/recipes/jenkins.rb b/recipes/jenkins.rb index 3011296a..54db7a96 100644 --- a/recipes/jenkins.rb +++ b/recipes/jenkins.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Integrate jenkins builds # diff --git a/recipes/jmx.rb b/recipes/jmx.rb index 7f76e686..02f76d30 100644 --- a/recipes/jmx.rb +++ b/recipes/jmx.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Build a data structure with configuration. # @see https://github.com/DataDog/dd-agent/blob/master/conf.d/jmx.yaml.example JMX Example diff --git a/recipes/kafka.rb b/recipes/kafka.rb index 0018d010..aa446dd7 100644 --- a/recipes/kafka.rb +++ b/recipes/kafka.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Kafka # diff --git a/recipes/kafka_consumer.rb b/recipes/kafka_consumer.rb index 3878fea3..be3f3409 100644 --- a/recipes/kafka_consumer.rb +++ b/recipes/kafka_consumer.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Kafka # @@ -6,8 +20,18 @@ # node.datadog.kafka_consumer.instances = [ # { # :kafka_connect_str => "localhost:19092", +# :consumer_groups => { +# :my_consumer => { +# :my_topic => [, , , ] +# } , +# # optional -if consumer_groups is set do false no matter of it's set to true or not. +# # false is the default configuration, but since there is a dependency on consumer_groups +# # it will be added to conf.yaml as false. +# :monitor_unlisted_consumer_groups >> true, # :zk_connect_str => "localhost:2181", -# :zk_prefix => "/0.8" +# :zk_prefix => "/0.8", +# # optional -if it's set to false it will no added to conf.yaml because false is default. +# :kafka_consumer_offsets => true # } # ] diff --git a/recipes/kong.rb b/recipes/kong.rb index d7892581..a6722eeb 100644 --- a/recipes/kong.rb +++ b/recipes/kong.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Kong # diff --git a/recipes/kube_apiserver_metrics.rb b/recipes/kube_apiserver_metrics.rb index a6481211..21266932 100644 --- a/recipes/kube_apiserver_metrics.rb +++ b/recipes/kube_apiserver_metrics.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Kubernetes API server metrics # diff --git a/recipes/kubernetes.rb b/recipes/kubernetes.rb index 838ba32b..b1bfff5b 100644 --- a/recipes/kubernetes.rb +++ b/recipes/kubernetes.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor kubernetes # diff --git a/recipes/kyototycoon.rb b/recipes/kyototycoon.rb index c65f5547..cfd109c3 100644 --- a/recipes/kyototycoon.rb +++ b/recipes/kyototycoon.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Integrate Kyoto Tycoon metrics into Datadog # diff --git a/recipes/lighttpd.rb b/recipes/lighttpd.rb index ca09665b..c0dfde8f 100644 --- a/recipes/lighttpd.rb +++ b/recipes/lighttpd.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' datadog_monitor 'lighttpd' do instances node['datadog']['lighttpd']['instances'] diff --git a/recipes/mapreduce.rb b/recipes/mapreduce.rb index 9255dcdd..e6dd8cd1 100644 --- a/recipes/mapreduce.rb +++ b/recipes/mapreduce.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor MapReduce # diff --git a/recipes/marathon.rb b/recipes/marathon.rb index feebadcb..146e66d8 100644 --- a/recipes/marathon.rb +++ b/recipes/marathon.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Marathon # diff --git a/recipes/marklogic.rb b/recipes/marklogic.rb index 0884716c..5002046b 100644 --- a/recipes/marklogic.rb +++ b/recipes/marklogic.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor MarkLogic # diff --git a/recipes/memcache.rb b/recipes/memcache.rb index 4cf05f97..acd68a01 100644 --- a/recipes/memcache.rb +++ b/recipes/memcache.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Integrate memcache metrics into Datadog # diff --git a/recipes/mesos_master.rb b/recipes/mesos_master.rb index 6adda9bc..c66a1b03 100644 --- a/recipes/mesos_master.rb +++ b/recipes/mesos_master.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: mesos # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' # Build a data structure with configuration. # @example diff --git a/recipes/mesos_slave.rb b/recipes/mesos_slave.rb index fba1de03..15e15e91 100644 --- a/recipes/mesos_slave.rb +++ b/recipes/mesos_slave.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: mesos_slave # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' # Build a data structure with configuration. # @example diff --git a/recipes/mongo.rb b/recipes/mongo.rb index 664a4917..d8766dff 100644 --- a/recipes/mongo.rb +++ b/recipes/mongo.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor mongo # diff --git a/recipes/mysql.rb b/recipes/mysql.rb index 244a515f..90d7f15f 100644 --- a/recipes/mysql.rb +++ b/recipes/mysql.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor mysql # diff --git a/recipes/network.rb b/recipes/network.rb index b6695d3a..6cfa15ce 100644 --- a/recipes/network.rb +++ b/recipes/network.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor network # diff --git a/recipes/nfsstat.rb b/recipes/nfsstat.rb index 984c0646..36c971fd 100644 --- a/recipes/nfsstat.rb +++ b/recipes/nfsstat.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Nfsstat # diff --git a/recipes/nginx.rb b/recipes/nginx.rb index 96ed60ab..b1bae733 100644 --- a/recipes/nginx.rb +++ b/recipes/nginx.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor nginx # diff --git a/recipes/nginx_ingress_controller.rb b/recipes/nginx_ingress_controller.rb index 221430e3..9c37fa68 100644 --- a/recipes/nginx_ingress_controller.rb +++ b/recipes/nginx_ingress_controller.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor nginx-ingress-controller # diff --git a/recipes/ntp.rb b/recipes/ntp.rb index 436b7f23..017a6ae0 100644 --- a/recipes/ntp.rb +++ b/recipes/ntp.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Build a data structure with configuration. # @note NTP check is enabled by default since datadog-agent 5.3.0. diff --git a/recipes/openmetrics.rb b/recipes/openmetrics.rb index ddcc8cd3..50d197fe 100644 --- a/recipes/openmetrics.rb +++ b/recipes/openmetrics.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor OpenMetrics # diff --git a/recipes/pdh_check.rb b/recipes/pdh_check.rb index 82920e14..9e1884fe 100644 --- a/recipes/pdh_check.rb +++ b/recipes/pdh_check.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor PDH # diff --git a/recipes/pgbouncer.rb b/recipes/pgbouncer.rb index 53706f89..2aa152a4 100644 --- a/recipes/pgbouncer.rb +++ b/recipes/pgbouncer.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: pgbouncer # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' # Build a data structure with configuration. # @see https://github.com/DataDog/integrations-core/blob/master/pgbouncer/conf.yaml.example Pgbouncer Example diff --git a/recipes/php_fpm.rb b/recipes/php_fpm.rb index f24c4808..5312027c 100644 --- a/recipes/php_fpm.rb +++ b/recipes/php_fpm.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Build a data structure with configuration. # @see https://github.com/DataDog/integrations-core/blob/master/php_fpm/conf.yaml.example PHP-FPM Example diff --git a/recipes/postfix.rb b/recipes/postfix.rb index 3453a09c..b01d889f 100644 --- a/recipes/postfix.rb +++ b/recipes/postfix.rb @@ -2,6 +2,19 @@ # Cookbook:: datadog # Recipe:: postfix # +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # Monitor postfix # @@ -23,7 +36,7 @@ # ] # -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' include_recipe 'sudo' # ~FC007 uses `suggests` postfix_instances = Array(node['datadog']['postfix']['instances']) diff --git a/recipes/postgres.rb b/recipes/postgres.rb index 908bb0dd..550cdb15 100644 --- a/recipes/postgres.rb +++ b/recipes/postgres.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Build a data structure with configuration. # @see https://github.com/DataDog/integrations-core/blob/master/postgres/conf.yaml.example PostgreSQL Example diff --git a/recipes/process.rb b/recipes/process.rb index 87f57e1a..1c7363c8 100644 --- a/recipes/process.rb +++ b/recipes/process.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor processes # diff --git a/recipes/proxysql.rb b/recipes/proxysql.rb index 911941e6..75552fc7 100644 --- a/recipes/proxysql.rb +++ b/recipes/proxysql.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor ProxySQL # diff --git a/recipes/rabbitmq.rb b/recipes/rabbitmq.rb index b398088b..b357e869 100644 --- a/recipes/rabbitmq.rb +++ b/recipes/rabbitmq.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Integrate rabbitmq metrics into Datadog # diff --git a/recipes/redisdb.rb b/recipes/redisdb.rb index 9c2cc379..926b420c 100644 --- a/recipes/redisdb.rb +++ b/recipes/redisdb.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Build a data structure with configuration. # @see https://github.com/DataDog/integrations-core/blob/master/redisdb/conf.yaml.example RedisDB Example diff --git a/recipes/remove-dd-agent.rb b/recipes/remove-dd-agent.rb index 4e7755c8..3eacb6e5 100644 --- a/recipes/remove-dd-agent.rb +++ b/recipes/remove-dd-agent.rb @@ -1,13 +1,52 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Run this recipe to completely remove the Datadog Agent # On Windows, this recipe works only with Chef >= 12.6 +# Importing apt_sources_list_file variable from recipe_helpers.rb +apt_sources_list_file = Chef::Datadog.apt_sources_list_file + case node['os'] when 'linux' + # First remove the datadog-agent package package 'datadog-agent' do action :purge end + + # Then remove the installation files (depending on the OS: sources_list file, datadog-signing-keys package...) + case node['platform_family'] + when 'amazon', 'rhel', 'fedora' # 'rhel' includes redhat, centos, rocky, scientific and almalinux + yum_repository 'datadog' do + action :remove + end + when 'debian' # 'debian' includes debian and ubuntu + apt_package 'datadog-signing-keys' do + action :purge + end + file apt_sources_list_file do + action :delete + end + when 'suse' + zypper_repository 'datadog' do + action :remove + end + end + when 'windows' + # Remove the datadog-agent package (no need to remove other files as for Linux) package 'Datadog Agent' do action :remove end diff --git a/recipes/repository.rb b/recipes/repository.rb index 37a519cf..45eb49e7 100644 --- a/recipes/repository.rb +++ b/recipes/repository.rb @@ -1,7 +1,8 @@ # # Cookbook:: datadog # Recipe:: repository -# Copyright:: 2013-2015, Datadog +# +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -26,17 +27,34 @@ agent_major_version = Chef::Datadog.agent_major_version(node) +# DATADOG_APT_KEY_CURRENT always contains the key that is used to sign repodata and latest packages # A2923DFF56EDA6E76E55E492D3A80E30382E94DE expires in 2022 # D75CEA17048B9ACBF186794B32637D44F14F620E expires in 2032 -apt_gpg_key = 'D75CEA17048B9ACBF186794B32637D44F14F620E' -other_apt_gpg_keys = ['A2923DFF56EDA6E76E55E492D3A80E30382E94DE'] +# 5F1E256061D813B125E156E8E6266D4AC0962C7D expires in 2028 +# D18886567EABAD8B2D2526900D826EB906462314 expires in 2033 +apt_gpg_keys = { + 'DATADOG_APT_KEY_CURRENT.public' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_CURRENT.public', + 'D18886567EABAD8B2D2526900D826EB906462314' => 'https://keys.datadoghq.com/DATADOG_APT_KEY_06462314.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', +} +apt_trusted_d_keyring = '/etc/apt/trusted.gpg.d/datadog-archive-keyring.gpg' +apt_usr_share_keyring = '/usr/share/keyrings/datadog-archive-keyring.gpg' +# Importing apt_sources_list_file variable from recipe_helpers.rb +apt_sources_list_file = Chef::Datadog.apt_sources_list_file +apt_repo_uri = 'https://apt.datadoghq.com' # DATADOG_RPM_KEY_CURRENT always contains the key that is used to sign repodata and latest packages # DATADOG_RPM_KEY_E09422B3.public expires in 2022 # DATADOG_RPM_KEY_FD4BF915.public expires in 2024 +# DATADOG_RPM_KEY_B01082D3.public expires in 2028 +# DATADOG_RPM_KEY_4F09D16B.public expires in 2033 rpm_gpg_keys = [['DATADOG_RPM_KEY_CURRENT.public', 'current', ''], - ['DATADOG_RPM_KEY_E09422B3.public', 'e09422b3', 'A4C0 B90D 7443 CF6E 4E8A A341 F106 8E14 E094 22B3'], - ['DATADOG_RPM_KEY_FD4BF915.public', 'fd4bf915', 'C655 9B69 0CA8 82F0 23BD F3F6 3F4D 1729 FD4B F915']] + ['DATADOG_RPM_KEY_4F09D16B.public', '4f09d16b', '2416 A377 57B1 BB02 68B3 634B 52AF C599 4F09 D16B'], + ['DATADOG_RPM_KEY_B01082D3.public', 'b01082d3', '7408 BFD5 6BC5 BF0C 361A AAE8 5D88 EEA3 B010 82D3'], + ['DATADOG_RPM_KEY_FD4BF915.public', 'fd4bf915', 'C655 9B69 0CA8 82F0 23BD F3F6 3F4D 1729 FD4B F915'], + ['DATADOG_RPM_KEY_E09422B3.public', 'e09422b3', 'A4C0 B90D 7443 CF6E 4E8A A341 F106 8E14 E094 22B3']] # Local file name of the key rpm_gpg_keys_name = 0 @@ -45,15 +63,83 @@ # Space delimited full fingerprint rpm_gpg_keys_full_fingerprint = 2 +# This method deletes an RPM GPG key if it is installed +def remove_rpm_gpg_key(rpm_gpg_key_full_fingerprint) + execute "rpm-remove old gpg key #{rpm_gpg_key_full_fingerprint}" do + command "rpm --erase gpg-pubkey-#{rpm_gpg_key_full_fingerprint}" + only_if "rpm -q gpg-pubkey-#{rpm_gpg_key_full_fingerprint}" + action :run + end +end + +def warn_deprecated_yumrepo_gpgkey + log 'yum deprecated parameters warning' do + level :warn + message 'Attribute "yumrepo_gpgkey" is deprecated since version 4.16.0' + only_if { + !node['datadog']['yumrepo_gpgkey'].nil? + } + end +end + case node['platform_family'] when 'debian' - apt_update 'update' + log 'apt deprecated parameters warning' do + level :warn + message 'Attributes "aptrepo_use_backup_keyserver", "aptrepo_keyserver" and "aptrepo_backup_keyserver" are deprecated since version 4.11.0' + only_if { + !node['datadog']['aptrepo_use_backup_keyserver'].nil? || !node['datadog']['aptrepo_keyserver'].nil? || !node['datadog']['aptrepo_backup_keyserver'].nil? + } + end + + apt_update 'update' do + ignore_failure true + end package 'install-apt-transport-https' do package_name 'apt-transport-https' action :install end + package 'install-gnupg' do + package_name 'gnupg' + action :install + end + + file apt_usr_share_keyring do + action :create_if_missing + content '' + mode '0644' + end + + apt_gpg_keys.each do |key_fingerprint, key_url| + # Download the APT key + key_local_path = ::File.join(Chef::Config[:file_cache_path], key_fingerprint) + # By default, remote_file will use `If-Modified-Since` header to see if the file + # was modified remotely, so this works fine for the "current" key + remote_file "remote_file_#{key_fingerprint}" do + path key_local_path + source key_url + notifies :run, "execute[import apt datadog key #{key_fingerprint}]", :immediately + end + + # Import the APT key + execute "import apt datadog key #{key_fingerprint}" do + command "/bin/cat #{key_local_path} | 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:" + not_if "/usr/bin/gpg --no-default-keyring --keyring #{apt_usr_share_keyring} --list-keys --with-fingerprint --with-colons | grep \ + $(cat #{key_local_path} | gpg --with-colons --with-fingerprint 2>/dev/null | grep 'fpr:' | sed 's|^fpr||' | tr -d ':')" + action :nothing + end + end + + remote_file apt_trusted_d_keyring do + action :create + mode '0644' + source "file://#{apt_usr_share_keyring}" + only_if { (platform?('ubuntu') && node['platform_version'].to_i < 16) || (platform?('debian') && node['platform_version'].to_i < 9) } + end + case agent_major_version when 7 components = ['7'] @@ -73,33 +159,46 @@ end end + retries = node['datadog']['aptrepo_retries'] - keyserver = node['datadog']['aptrepo_use_backup_keyserver'] ? node['datadog']['aptrepo_backup_keyserver'] : node['datadog']['aptrepo_keyserver'] + # Add APT repositories - apt_repository 'datadog' do - keyserver keyserver - key apt_gpg_key - uri node['datadog']['aptrepo'] - distribution node['datadog']['aptrepo_dist'] - components components - action :add + # Chef's apt_repository resource doesn't allow specifying the signed-by option and we can't pass + # it in uri, as that would make it fail parsing, hence we use the file and apt_update resources. + apt_update 'datadog' do retries retries + ignore_failure true # this is exactly what apt_repository does + action :nothing end - # Previous versions of the cookbook could create these repo files, make sure we remove it now - apt_repository 'datadog-beta' do - action :remove - end + deb_repo_with_options = if node['datadog']['aptrepo'].nil? + "[signed-by=#{apt_usr_share_keyring}] #{apt_repo_uri}" + else + node['datadog']['aptrepo'] + end - apt_repository 'datadog_apt_A2923DFF56EDA6E76E55E492D3A80E30382E94DE' do - action :remove + file apt_sources_list_file do + action :create + owner 'root' + group 'root' + mode '0644' + content "deb #{deb_repo_with_options} #{node['datadog']['aptrepo_dist']} #{components.compact.join(' ')}" + notifies :update, 'apt_update[datadog]', :immediately end - apt_repository 'datadog_apt_D75CEA17048B9ACBF186794B32637D44F14F620E' do - action :remove + # Previous versions of the cookbook could create these repo files, make sure we remove it now + ['datadog-beta', + 'datadog_apt_D75CEA17048B9ACBF186794B32637D44F14F620E', + 'datadog_apt_A2923DFF56EDA6E76E55E492D3A80E30382E94DE'].each do |repo| + apt_repository repo do + action :remove + end end when 'rhel', 'fedora', 'amazon' + # The yumrepo_gpgkey parameter was removed because the DATADOG_RPM_KEY.public (4172a230) is not used anymore + warn_deprecated_yumrepo_gpgkey() + # gnupg is required to check the downloaded key's fingerprint package 'gnupg' do action :install @@ -132,6 +231,26 @@ end end + # The DATADOG_RPM_KEY.public (4172a230) is not used anymore, it should be deleted if present + remove_rpm_gpg_key('4172a230-55dd14f6') + + # When the user has set yumrepo_repo_gpgcheck explicitly, we respect that. + # Otherwise, we turn on repo_gpgcheck by default when both: + # * We're not running on RHEL/CentOS 5 or older + # * User has not overriden the default yumrepo + # * System is not RHEL/CentOS 8.1 (repo_gpgcheck doesn't work there because + # of https://bugzilla.redhat.com/show_bug.cgi?id=1792506 + repo_gpgcheck = if node['datadog']['yumrepo_repo_gpgcheck'].nil? + if !node['datadog']['yumrepo'].nil? || (platform_family?('rhel') && node['platform_version'].to_i < 6) || + (platform?('centos', 'redhat') && node['platform_version'].to_f >= 8.1 && node['platform_version'].to_f < 8.2) + false + else + true + end + else + node['datadog']['yumrepo_repo_gpgcheck'] + end + if !node['datadog']['yumrepo'].nil? baseurl = node['datadog']['yumrepo'] else @@ -142,6 +261,7 @@ baseurl = "https://yum.datadoghq.com/stable/#{agent_major_version}/#{node['kernel']['machine']}/" when 5 baseurl = "#{yum_protocol_a5}://yum.datadoghq.com/rpm/#{yum_a5_architecture_map[node['kernel']['machine']]}/" + repo_gpgcheck = false else Chef::Log.error("agent_major_version '#{agent_major_version}' not supported.") end @@ -154,9 +274,6 @@ yumrepo_gpgkeys.push(node['datadog']["yumrepo_gpgkey_new_#{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}"]) end end - # yum/dnf go through entries in the order in which they're set in the repofile; - # add the old key last so it doesn't get imported at all if a newer key can be used - yumrepo_gpgkeys.push(node['datadog']['yumrepo_gpgkey']) if agent_major_version < 7 yum_repository 'datadog' do description 'datadog' @@ -166,9 +283,13 @@ proxy_password node['datadog']['yumrepo_proxy_password'] gpgkey yumrepo_gpgkeys gpgcheck true + repo_gpgcheck repo_gpgcheck action :create end when 'suse' + # The yumrepo_gpgkey parameter was removed because the DATADOG_RPM_KEY.public (4172a230) is not used anymore + warn_deprecated_yumrepo_gpgkey() + # Import new RPM key rpm_gpg_keys.each do |rpm_gpg_key| next unless node['datadog']["yumrepo_gpgkey_new_#{rpm_gpg_key[rpm_gpg_keys_short_fingerprint]}"] @@ -193,21 +314,8 @@ end end - # Now the old key is mostly hard-coded - old_key_local_path = ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY.public') - remote_file 'DATADOG_RPM_KEY.public' do - path old_key_local_path - source node['datadog']['yumrepo_gpgkey'] - not_if 'rpm -q gpg-pubkey-4172a230' # (key already imported) - notifies :run, 'execute[rpm-import datadog key 4172a230]', :immediately - end - - # Import key if fingerprint matches - execute 'rpm-import datadog key 4172a230' do - command "rpm --import #{old_key_local_path}" - only_if "gpg --dry-run --quiet --with-fingerprint #{old_key_local_path} | grep '60A3 89A4 4A0C 32BA E3C0 3F0B 069B 56F5 4172 A230' || gpg --dry-run --import --import-options import-show #{old_key_local_path} | grep '60A389A44A0C32BAE3C03F0B069B56F54172A230'" - action :nothing - end + # The DATADOG_RPM_KEY.public (4172a230) is not used anymore, it should be deleted if present + remove_rpm_gpg_key('4172a230-55dd14f6') if !node['datadog']['yumrepo_suse'].nil? baseurl = node['datadog']['yumrepo_suse'] @@ -226,9 +334,12 @@ zypper_repository 'datadog' do description 'datadog' baseurl baseurl - gpgkey agent_major_version < 6 ? node['datadog']['yumrepo_gpgkey'] : node['datadog']['yumrepo_gpgkey_new_current'] + gpgkey node['datadog']['yumrepo_gpgkey_new_current'] gpgautoimportkeys false gpgcheck false + # zypper has no repo_gpgcheck option, but it does repodata signature checks + # by default (when the repomd.xml.asc file is present) which users have + # to actually disable system-wide, so we are fine not setting it explicitly action :create end end diff --git a/recipes/rethinkdb.rb b/recipes/rethinkdb.rb index 00a3c3f9..ad9253cb 100644 --- a/recipes/rethinkdb.rb +++ b/recipes/rethinkdb.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor RethinkDB # diff --git a/recipes/riak.rb b/recipes/riak.rb index f7fd3532..970c158f 100644 --- a/recipes/riak.rb +++ b/recipes/riak.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Riak # diff --git a/recipes/security-agent.rb b/recipes/security-agent.rb new file mode 100644 index 00000000..7f4564f6 --- /dev/null +++ b/recipes/security-agent.rb @@ -0,0 +1,85 @@ +# +# Cookbook:: datadog +# Recipe:: security-agent +# +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +is_windows = platform_family?('windows') + +# Set the correct agent startup action +security_agent_start = node['datadog']['agent_start'] && node['datadog']['agent_enable'] ? :start : :stop + +# +# Configures security-agent agent +security_agent_config_file = + if is_windows + 'C:/ProgramData/Datadog/security-agent.yaml' + else + '/etc/datadog-agent/security-agent.yaml' + end + +template security_agent_config_file do + runtime_security_extra_config = {} + if node['datadog']['extra_config'] && node['datadog']['extra_config']['security_agent'] && node['datadog']['extra_config']['security_agent']['runtime_security_config'] + node['datadog']['extra_config']['security_agent']['runtime_security_config'].each do |k, v| + next if v.nil? + runtime_security_extra_config[k] = v + end + end + + compliance_extra_config = {} + if node['datadog']['extra_config'] && node['datadog']['extra_config']['security_agent'] && node['datadog']['extra_config']['security_agent']['compliance_config'] + node['datadog']['extra_config']['security_agent']['compliance_config'].each do |k, v| + next if v.nil? + compliance_extra_config[k] = v + end + end + + source 'security-agent.yaml.erb' + variables( + runtime_security_enabled: node['datadog']['security_agent']['cws']['enabled'], + runtime_security_extra_config: runtime_security_extra_config, + compliance_enabled: node['datadog']['security_agent']['cspm']['enabled'], + compliance_extra_config: compliance_extra_config + ) + + unless is_windows + owner 'root' + group 'dd-agent' + mode '640' + end + + notifies :restart, 'service[datadog-agent-security]', :delayed +end + +# Common configuration +service_provider = Chef::Datadog.service_provider(node) + +service_name = is_windows ? 'datadog-security-agent' : 'datadog-agent-security' + +service 'datadog-agent-security' do + service_name service_name + action [security_agent_start] + provider service_provider unless service_provider.nil? + if is_windows + supports :restart => true, :start => true, :stop => true + restart_command "powershell restart-service #{service_name} -Force" + stop_command "powershell stop-service #{service_name} -Force" + else + supports :restart => true, :status => true, :start => true, :stop => true + end + subscribes :restart, "template[#{security_agent_config_file}]", :delayed +end \ No newline at end of file diff --git a/recipes/sidekiq.rb b/recipes/sidekiq.rb index 8abe9369..1638a262 100644 --- a/recipes/sidekiq.rb +++ b/recipes/sidekiq.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Sidekiq # diff --git a/recipes/snmp.rb b/recipes/snmp.rb index 9ee718af..c4edc659 100644 --- a/recipes/snmp.rb +++ b/recipes/snmp.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # see example configuration file here: # https://github.com/DataDog/integrations-core/blob/master/snmp/conf.yaml.example diff --git a/recipes/solr.rb b/recipes/solr.rb index 29d4c0b7..1f145049 100644 --- a/recipes/solr.rb +++ b/recipes/solr.rb @@ -1,7 +1,21 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor solr -# @see https://github.com/DataDog/integrations-core/blob/master/solr/conf.yaml.example Solr Example +# @see https://github.com/DataDog/integrations-core/blob/master/solr/datadog_checks/solr/data/conf.yaml.example Solr Example # @example # diff --git a/recipes/spark.rb b/recipes/spark.rb index 0c9f9c7b..bf9b7aab 100644 --- a/recipes/spark.rb +++ b/recipes/spark.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Spark # diff --git a/recipes/sqlserver.rb b/recipes/sqlserver.rb index 5b29f354..d8c767bd 100644 --- a/recipes/sqlserver.rb +++ b/recipes/sqlserver.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # see example configuration file here: # https://github.com/DataDog/integrations-core/blob/master/sqlserver/conf.yaml.example diff --git a/recipes/squid.rb b/recipes/squid.rb index a571aef3..f43f7272 100644 --- a/recipes/squid.rb +++ b/recipes/squid.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Squid # diff --git a/recipes/ssh_check.rb b/recipes/ssh_check.rb index 269924d3..c1c5a473 100644 --- a/recipes/ssh_check.rb +++ b/recipes/ssh_check.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor SSH connectivity # @@ -6,7 +20,7 @@ # up the following attributes at some point in your Chef run, in either a role # or another cookbook. # -# node['datadog']['ssh_check']['instances'] = [ +# node.default['datadog']['ssh_check']['instances'] = [ # { # 'host' => '1.2.3.4', # required for each instance # 'username' => 'user', # required for each instance @@ -15,6 +29,7 @@ # 'sftp_check' => true, # optional, defaults to true # 'private_key_file' => '/path/to/key', # optional # 'add_missing_keys' => false, # optional, defaults to false +# 'min_collection_interval' => 300, # optional, defaults to 15 # 'tags' => [node.chef_environment] # optional # } # ] diff --git a/recipes/statsd.rb b/recipes/statsd.rb index 3506e1b1..06a1e820 100644 --- a/recipes/statsd.rb +++ b/recipes/statsd.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor StatsD # diff --git a/recipes/supervisord.rb b/recipes/supervisord.rb index b4c66d77..d27c19fd 100644 --- a/recipes/supervisord.rb +++ b/recipes/supervisord.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: supervisord # -# Copyright:: 2011-2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' # Build a data structure with configuration. # @see https://github.com/DataDog/integrations-core/blob/master/supervisord/conf.yaml.example Supervisord Example diff --git a/recipes/system-probe.rb b/recipes/system-probe.rb index 155b4724..fafe4792 100644 --- a/recipes/system-probe.rb +++ b/recipes/system-probe.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: system-probe # -# Copyright:: 2011-2019, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,8 +20,12 @@ is_windows = platform_family?('windows') # Set the correct agent startup action -sysprobe_enabled = node['datadog']['system_probe']['enabled'] || node['datadog']['system_probe']['network_enabled'] -sysprobe_agent_start = sysprobe_enabled ? :start : :stop +npm_enabled = node['datadog']['system_probe']['network_enabled'] +usm_enabled = node['datadog']['system_probe']['service_monitoring_enabled'] +cws_enabled = node['datadog']['security_agent']['cws']['enabled'] +sysprobe_enabled = node['datadog']['system_probe']['enabled'] || npm_enabled || usm_enabled || cws_enabled + +sysprobe_agent_start = sysprobe_enabled && node['datadog']['agent_start'] && node['datadog']['agent_enable'] ? :start : :stop # # Configures system-probe agent @@ -43,6 +47,14 @@ end end + runtime_security_extra_config = {} + if node['datadog']['extra_config'] && node['datadog']['extra_config']['security_agent'] && node['datadog']['extra_config']['security_agent']['runtime_security_config'] + node['datadog']['extra_config']['security_agent']['runtime_security_config'].each do |k, v| + next if v.nil? + runtime_security_extra_config[k] = v + end + end + source 'system_probe.yaml.erb' variables( enabled: node['datadog']['system_probe']['enabled'], @@ -50,14 +62,12 @@ debug_port: node['datadog']['system_probe']['debug_port'], bpf_debug: node['datadog']['system_probe']['bpf_debug'], enable_conntrack: node['datadog']['system_probe']['enable_conntrack'], - extra_config: extra_config + system_probe_extra_config: extra_config, + runtime_security_enabled: cws_enabled, + runtime_security_extra_config: runtime_security_extra_config ) - if is_windows - owner 'Administrators' - rights :full_control, 'Administrators' - inherits false - else + unless is_windows owner 'root' group 'dd-agent' mode '640' @@ -66,6 +76,7 @@ notifies :restart, 'service[datadog-agent-sysprobe]', :delayed if sysprobe_enabled # since process-agent collects network info through system-probe, enabling system-probe should also restart process-agent notifies :restart, 'service[datadog-agent]', :delayed if sysprobe_enabled + notifies :restart, 'service[datadog-agent-security]', :delayed if cws_enabled # System probe is not enabled and the file doesn't exists, don't create it not_if { !sysprobe_enabled && !system_probe_config_file_exists } @@ -87,6 +98,5 @@ else supports :restart => true, :status => true, :start => true, :stop => true end - supports :restart => true, :status => true, :start => true, :stop => true subscribes :restart, "template[#{system_probe_config_file}]", :delayed if sysprobe_enabled end diff --git a/recipes/system_core.rb b/recipes/system_core.rb index 1a9077a7..602e2b38 100644 --- a/recipes/system_core.rb +++ b/recipes/system_core.rb @@ -2,7 +2,7 @@ # Cookbook:: datadog # Recipe:: system_core # -# Copyright:: 2015, Datadog +# Copyright:: 2011-Present, Datadog # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,6 +16,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' datadog_monitor 'system_core' diff --git a/recipes/system_swap.rb b/recipes/system_swap.rb index 6a1800bd..60c91778 100644 --- a/recipes/system_swap.rb +++ b/recipes/system_swap.rb @@ -2,6 +2,20 @@ # Cookbook:: datadog # Recipe:: system_swap # -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' datadog_monitor 'system_swap' diff --git a/recipes/systemd.rb b/recipes/systemd.rb index 4373e26f..c0148f56 100644 --- a/recipes/systemd.rb +++ b/recipes/systemd.rb @@ -1,13 +1,28 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Systemd -# +# It works for all unit types like targets, services, sockets, devices, mounts, automounts, swaps, paths, timers, snapshots, slices, scopes, busnames # node.default['datadog']['systemd']['instances'] = [ # { # 'unit_names' => [ # 'myservice1.service', # 'myservice2.service', -# 'mysocket.socket' +# 'mysocket.socket', +# 'mytimer.timer' # ], # 'substate_status_mapping' => [ # 'services' => [ @@ -28,6 +43,12 @@ # 'running' => 'ok', # 'exited' => 'critical' # } +# ], +# 'timers' => [ +# 'mytimer' => { +# 'running' => 'ok', +# 'exited' => 'critical' +# } # ] # ], # 'tags' => [ diff --git a/recipes/tcp_check.rb b/recipes/tcp_check.rb index 429cadc0..c19a52c4 100644 --- a/recipes/tcp_check.rb +++ b/recipes/tcp_check.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor tcp # @see http://docs.datadoghq.com/guides/network_checks/ diff --git a/recipes/teamcity.rb b/recipes/teamcity.rb index 192ebba6..1e4f4b02 100644 --- a/recipes/teamcity.rb +++ b/recipes/teamcity.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Teamcity # diff --git a/recipes/tenable.rb b/recipes/tenable.rb index c9614f12..6cebf5a3 100644 --- a/recipes/tenable.rb +++ b/recipes/tenable.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Tenable # diff --git a/recipes/tls.rb b/recipes/tls.rb index 7554cb34..2e8245b7 100644 --- a/recipes/tls.rb +++ b/recipes/tls.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor TLS # diff --git a/recipes/tokumx.rb b/recipes/tokumx.rb index ad88d975..264db6f9 100644 --- a/recipes/tokumx.rb +++ b/recipes/tokumx.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor tokumx # diff --git a/recipes/tomcat.rb b/recipes/tomcat.rb index f1eb2738..4898cfdf 100644 --- a/recipes/tomcat.rb +++ b/recipes/tomcat.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor tomcat # diff --git a/recipes/twistlock.rb b/recipes/twistlock.rb index 61870140..1f6bfd6e 100644 --- a/recipes/twistlock.rb +++ b/recipes/twistlock.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Twistlock # diff --git a/recipes/varnish.rb b/recipes/varnish.rb index 123e2501..78a698c4 100644 --- a/recipes/varnish.rb +++ b/recipes/varnish.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Varnish # diff --git a/recipes/vault.rb b/recipes/vault.rb index 49dfa3cf..57dbd158 100644 --- a/recipes/vault.rb +++ b/recipes/vault.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor vault # diff --git a/recipes/vertica.rb b/recipes/vertica.rb index cf049aae..51b0cf3f 100644 --- a/recipes/vertica.rb +++ b/recipes/vertica.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Vertica # diff --git a/recipes/vsphere.rb b/recipes/vsphere.rb index 7f4415d4..b71f73f6 100644 --- a/recipes/vsphere.rb +++ b/recipes/vsphere.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor vSphere # diff --git a/recipes/weblogic.rb b/recipes/weblogic.rb new file mode 100644 index 00000000..4ea153f7 --- /dev/null +++ b/recipes/weblogic.rb @@ -0,0 +1,44 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' + +# Monitor weblogic +# +# Assuming you have 2 instances "test" and "prod", +# one with and one without authentication +# you need to set up the following attributes +# node.datadog.weblogic.instances = [ +# { +# :host => "localhost", +# :port => "9090", +# :name => "prod", +# :username => "username", +# :password => "secret" +# }, +# { +# :host => "localhost", +# :port => "9091", +# :name => "test" +# } +# ] + +datadog_monitor 'weblogic' do + init_config node['datadog']['weblogic']['init_config'] + instances node['datadog']['weblogic']['instances'] + logs node['datadog']['weblogic']['logs'] + use_integration_template true + action :add + notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start'] +end diff --git a/recipes/win32_event_log.rb b/recipes/win32_event_log.rb index 3c970626..846c935f 100644 --- a/recipes/win32_event_log.rb +++ b/recipes/win32_event_log.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor the Windows Event Log # @see https://github.com/DataDog/integrations-core/blob/master/win32_event_log/datadog_checks/win32_event_log/data/conf.yaml.example for details diff --git a/recipes/windows_service.rb b/recipes/windows_service.rb index 10aa05e0..ad9e9a71 100644 --- a/recipes/windows_service.rb +++ b/recipes/windows_service.rb @@ -2,6 +2,19 @@ # Cookbook:: datadog # Recipe:: windows_service # +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # Example windows_service.yaml file: # @@ -53,7 +66,7 @@ # ] # } -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' datadog_monitor 'windows_service' do instances node['datadog']['windows_service']['instances'] diff --git a/recipes/wmi_check.rb b/recipes/wmi_check.rb index 5dedbb90..64dfd582 100644 --- a/recipes/wmi_check.rb +++ b/recipes/wmi_check.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # see example configuration file here: # https://github.com/DataDog/integrations-core/blob/master/wmi_check/conf.yaml.example diff --git a/recipes/yarn.rb b/recipes/yarn.rb index 11f41c7e..2161d8c3 100644 --- a/recipes/yarn.rb +++ b/recipes/yarn.rb @@ -1,4 +1,18 @@ -include_recipe 'datadog::dd-agent' +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe '::dd-agent' # Monitor Yarn # diff --git a/recipes/zookeeper.rb b/recipes/zookeeper.rb index 0cbb1555..637e32e5 100644 --- a/recipes/zookeeper.rb +++ b/recipes/zookeeper.rb @@ -2,8 +2,21 @@ # Cookbook:: datadog # Recipe:: zookeeper # +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. -include_recipe 'datadog::dd-agent' +include_recipe '::dd-agent' datadog_monitor 'zk' do instances node['datadog']['zookeeper']['instances'] diff --git a/resources/integration.rb b/resources/integration.rb index bd7c7895..6747c8cf 100644 --- a/resources/integration.rb +++ b/resources/integration.rb @@ -1,9 +1,29 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Install/remove a Datadog integration # This resource basically wraps the datadog-agent integration command to be able # to install and remove integrations from a Chef recipe. # The datadog_resource must be used on a system where the datadog-agent has # already been setup. +# enable unified mode on specific Chef versions. +# See CHEF-33 Deprecation warning: +# https://docs.chef.io/deprecations_unified_mode/ + +unified_mode true if respond_to?(:unified_mode) + default_action :install property :property_name, String, name_property: true @@ -27,6 +47,7 @@ output = shell_out("#{agent_exe_filepath} integration show -q #{new_resource.property_name}").stdout output.strip == new_resource.version } + notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start'] end end @@ -46,6 +67,7 @@ output = shell_out("#{agent_exe_filepath} integration show -q #{new_resource.property_name}").stdout output.strip.empty? } + notifies :restart, 'service[datadog-agent]' if node['datadog']['agent_start'] end end diff --git a/resources/monitor.rb b/resources/monitor.rb index a8a181f3..2c930126 100644 --- a/resources/monitor.rb +++ b/resources/monitor.rb @@ -1,5 +1,25 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Configure a service via its yaml file +# enable unified mode on specific Chef versions. +# See CHEF-33 Deprecation warning: +# https://docs.chef.io/deprecations_unified_mode/ + +unified_mode true if respond_to?(:unified_mode) + require 'yaml' # Our erb templates need this default_action :add @@ -13,6 +33,7 @@ property :instances, Array, required: false, default: [] property :version, [Integer, nil], required: false, default: nil property :use_integration_template, [TrueClass, FalseClass], required: false, default: false +property :is_jmx, [TrueClass, FalseClass], required: false, default: false property :logs, [Array, nil], required: false, default: [] action :add do @@ -54,8 +75,14 @@ source "#{new_resource.name}.yaml.erb" end + init_config = new_resource.init_config + if new_resource.is_jmx + init_config ||= {} + init_config = init_config.merge({ 'is_jmx' => true, 'collect_default_metrics' => true }) + end + variables( - init_config: new_resource.init_config, + init_config: init_config, instances: new_resource.instances, version: new_resource.version, logs: new_resource.logs diff --git a/spec/dd-agent_spec.rb b/spec/dd-agent_spec.rb index ad877c0e..7c41e884 100644 --- a/spec/dd-agent_spec.rb +++ b/spec/dd-agent_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'spec_helper' require 'digest' @@ -26,6 +40,18 @@ def set_env_var(name, value) it_behaves_like 'rhellions datadog-agent' end +shared_examples_for 'rhellions no version set rhel<7' do + it_behaves_like 'common linux resources' + + it_behaves_like 'rhellions datadog-agent rhel<7' +end + +shared_examples_for 'rhellions dnf no version set' do + it_behaves_like 'common linux resources' + + it_behaves_like 'rhellions dnf datadog-agent' +end + shared_examples_for 'version set below 4.x' do it_behaves_like 'common linux resources v5' end @@ -57,7 +83,7 @@ def set_env_var(name, value) cached(:chef_run) do ChefSpec::SoloRunner.new( :platform => 'debian', - :version => '7.11' + :version => '8.11' ) do |node| node.normal['datadog'] = { 'api_key' => 'somethingnotnil' } node.normal['languages'] = { 'python' => { 'version' => '2.7.5+' } } @@ -83,11 +109,11 @@ def set_env_var(name, value) it_behaves_like 'debianoids no version set' end - context 'on RedHat-family distro above 6.x' do + context 'on RedHat-family distro above 7.x' do cached(:chef_run) do ChefSpec::SoloRunner.new( :platform => 'centos', - :version => '6.9' + :version => '7.7' ) do |node| node.normal['datadog'] = { 'api_key' => 'somethingnotnil' } node.normal['languages'] = { 'python' => { 'version' => '2.6.2' } } @@ -98,11 +124,11 @@ def set_env_var(name, value) it_behaves_like 'rhellions no version set' end - context 'on CentOS 5.11 distro' do + context 'on CentOS < 7 distro' do cached(:chef_run) do ChefSpec::SoloRunner.new( :platform => 'centos', - :version => '5.11' + :version => '6.10' ) do |node| node.normal['datadog'] = { 'api_key' => 'somethingnotnil' } node.normal['languages'] = { 'python' => { 'version' => '2.4.3' } } @@ -110,14 +136,14 @@ def set_env_var(name, value) end it_behaves_like 'repo recipe' - it_behaves_like 'rhellions no version set' + it_behaves_like 'rhellions no version set rhel<7' end context 'on Fedora distro' do cached(:chef_run) do ChefSpec::SoloRunner.new( :platform => 'fedora', - :version => '26' + :version => '31' ) do |node| node.normal['datadog'] = { 'api_key' => 'somethingnotnil' } node.normal['languages'] = { 'python' => { 'version' => '2.7.9' } } @@ -125,7 +151,37 @@ def set_env_var(name, value) end it_behaves_like 'repo recipe' - it_behaves_like 'rhellions no version set' + it_behaves_like 'rhellions dnf no version set' + end + + context 'on AlmaLinux distro', if: min_chef_version('17.0.69') do + cached(:chef_run) do + ChefSpec::SoloRunner.new( + :platform => 'almalinux', + :version => '8' + ) do |node| + node.normal['datadog'] = { 'api_key' => 'somethingnotnil' } + node.normal['languages'] = { 'python' => { 'version' => '2.7.9' } } + end.converge described_recipe + end + + it_behaves_like 'repo recipe' + it_behaves_like 'rhellions dnf no version set' + end + + context 'on Rocky Linux distro', if: min_chef_version('17.1.35') do + cached(:chef_run) do + ChefSpec::SoloRunner.new( + :platform => 'rocky', + :version => '8' + ) do |node| + node.normal['datadog'] = { 'api_key' => 'somethingnotnil' } + node.normal['languages'] = { 'python' => { 'version' => '2.7.9' } } + end.converge described_recipe + end + + it_behaves_like 'repo recipe' + it_behaves_like 'rhellions dnf no version set' end context 'on Windows' do @@ -414,7 +470,7 @@ def set_env_var(name, value) cached(:chef_run) do ChefSpec::SoloRunner.new( :platform => 'fedora', - :version => '26' + :version => '31' ) do |node| node.normal['datadog'] = { 'agent_major_version' => 6, @@ -427,14 +483,14 @@ def set_env_var(name, value) end.converge described_recipe end - it_behaves_like 'rhellions datadog-agent' + it_behaves_like 'rhellions dnf datadog-agent' end context 'when rhel' do cached(:chef_run) do ChefSpec::SoloRunner.new( :platform => 'redhat', - :version => '6.10' + :version => '7.7' ) do |node| node.normal['datadog'] = { 'agent_major_version' => 6, @@ -523,7 +579,7 @@ def set_env_var(name, value) cached(:chef_run) do ChefSpec::SoloRunner.new( :platform => 'fedora', - :version => '26' + :version => '31' ) do |node| node.normal['datadog'] = { 'agent_major_version' => 5, @@ -537,7 +593,7 @@ def set_env_var(name, value) end.converge described_recipe end - it_behaves_like 'rhellions datadog-agent v5' + it_behaves_like 'rhellions dnf datadog-agent v5' end context 'when rhel' do @@ -864,7 +920,7 @@ def set_env_var(name, value) cached(:chef_run) do ChefSpec::SoloRunner.new( platform: 'centos', - version: '6.9' + version: '7.7' ) do |node| node.normal['datadog'] = { 'api_key' => 'somethingnotnil' } node.normal['languages'] = { 'python' => { 'version' => '2.6.2' } } @@ -909,7 +965,7 @@ def set_env_var(name, value) cached(:chef_run) do ChefSpec::SoloRunner.new( platform: 'centos', - version: '6.9' + version: '7.7' ) do |node| node.normal['datadog'] = { 'api_key' => 'somethingnotnil', @@ -1060,6 +1116,7 @@ def set_env_var(name, value) log_file: "/var/log/datadog/agent.log" log_level: "INFO" dogstatsd_non_local_traffic: false + dogstatsd_port: 8125 apm_config: apm_non_local_traffic: false process_config: @@ -1120,6 +1177,7 @@ def set_env_var(name, value) hostname: "chef-nodename" log_level: "INFO" dogstatsd_non_local_traffic: false + dogstatsd_port: 8125 apm_config: apm_non_local_traffic: false process_config: @@ -1181,6 +1239,7 @@ def set_env_var(name, value) log_file: "/var/log/datadog/agent.log" log_level: "INFO" dogstatsd_non_local_traffic: false + dogstatsd_port: 8125 apm_config: apm_non_local_traffic: false process_config: @@ -1238,6 +1297,7 @@ def set_env_var(name, value) log_file: "/var/log/datadog/agent.log" log_level: "INFO" dogstatsd_non_local_traffic: false + dogstatsd_port: 8125 apm_config: apm_non_local_traffic: false process_config: @@ -1397,7 +1457,7 @@ def set_env_var(name, value) let(:chef_run) do ChefSpec::SoloRunner.new( platform: 'fedora', - version: '27' + version: '32' ) do |node| node.normal['datadog'] = { 'api_key' => 'somethingnotnil', @@ -1406,7 +1466,11 @@ def set_env_var(name, value) end.converge described_recipe end it 'installs the full version' do - expect(chef_run).to install_yum_package('datadog-agent').with_version('6.16.0-1') + if Chef::Datadog.chef_version_ge? 14 + expect(chef_run).to install_dnf_package('datadog-agent').with_version('1:6.16.0-1') + else + expect(chef_run).to install_dnf_package('datadog-agent').with_version('6.16.0-1') + end end end end @@ -1415,7 +1479,7 @@ def set_env_var(name, value) context 'add custom monitor A5' do let(:chef_run) do ChefSpec::SoloRunner.new( - platform: 'fedora', version: '27', + platform: 'fedora', version: '32', step_into: ['datadog_monitor'] ) do |node| node.normal['datadog'] = { @@ -1431,7 +1495,7 @@ def set_env_var(name, value) context 'add custom monitor A7' do let(:chef_run) do ChefSpec::SoloRunner.new( - platform: 'fedora', version: '27', + platform: 'fedora', version: '32', step_into: ['datadog_monitor'] ) do |node| node.normal['datadog'] = { @@ -1450,7 +1514,7 @@ def set_env_var(name, value) context 'remove custom monitor A5' do let(:chef_run) do ChefSpec::SoloRunner.new( - platform: 'fedora', version: '27', + platform: 'fedora', version: '32', step_into: ['datadog_monitor'] ) do |node| node.normal['datadog'] = { @@ -1466,7 +1530,7 @@ def set_env_var(name, value) context 'remove custom monitor A7' do let(:chef_run) do ChefSpec::SoloRunner.new( - platform: 'fedora', version: '27', + platform: 'fedora', version: '32', step_into: ['datadog_monitor'] ) do |node| node.normal['datadog'] = { diff --git a/spec/dd-handler_spec.rb b/spec/dd-handler_spec.rb index 23738894..70367641 100644 --- a/spec/dd-handler_spec.rb +++ b/spec/dd-handler_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'spec_helper' shared_examples 'a chef-handler-datadog installer' do |version| diff --git a/spec/default_spec.rb b/spec/default_spec.rb index f1148650..73dbeab0 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'spec_helper' describe 'datadog::default' do diff --git a/spec/integrations/activemq_spec.rb b/spec/integrations/activemq_spec.rb index 22acdfbc..3fb4d5c8 100644 --- a/spec/integrations/activemq_spec.rb +++ b/spec/integrations/activemq_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::activemq' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/cassandra_spec.rb b/spec/integrations/cassandra_spec.rb index c5c5e38b..b9ec78af 100644 --- a/spec/integrations/cassandra_spec.rb +++ b/spec/integrations/cassandra_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::cassandra' do context 'version 1 (default)' do expected_yaml = <<-EOF diff --git a/spec/integrations/couchbase_spec.rb b/spec/integrations/couchbase_spec.rb index 880dc136..505d1d79 100644 --- a/spec/integrations/couchbase_spec.rb +++ b/spec/integrations/couchbase_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::couchbase' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/directory_spec.rb b/spec/integrations/directory_spec.rb index dc7af6ba..105ff1ba 100644 --- a/spec/integrations/directory_spec.rb +++ b/spec/integrations/directory_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::directory' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/disk_spec.rb b/spec/integrations/disk_spec.rb index a532020c..c508f76e 100644 --- a/spec/integrations/disk_spec.rb +++ b/spec/integrations/disk_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::disk' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/dns_check_spec.rb b/spec/integrations/dns_check_spec.rb index a4ad4295..01e0c4f4 100644 --- a/spec/integrations/dns_check_spec.rb +++ b/spec/integrations/dns_check_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::dns_check' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/docker_daemon_spec.rb b/spec/integrations/docker_daemon_spec.rb index aaeeb4a4..a4c21218 100644 --- a/spec/integrations/docker_daemon_spec.rb +++ b/spec/integrations/docker_daemon_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::docker_daemon' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/elasticsearch_spec.rb b/spec/integrations/elasticsearch_spec.rb index bb554741..e88af43b 100644 --- a/spec/integrations/elasticsearch_spec.rb +++ b/spec/integrations/elasticsearch_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::elasticsearch' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/etcd_spec.rb b/spec/integrations/etcd_spec.rb index 7f50f937..7ccef1b6 100644 --- a/spec/integrations/etcd_spec.rb +++ b/spec/integrations/etcd_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::etcd' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/gearmand_spec.rb b/spec/integrations/gearmand_spec.rb new file mode 100644 index 00000000..1e0c2654 --- /dev/null +++ b/spec/integrations/gearmand_spec.rb @@ -0,0 +1,96 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +describe 'datadog::gearmand' do + expected_yaml = <<-EOF + logs: + + instances: + - server: 127.0.0.1 + port: 4730 + tasks: + - TASK_1 + - TASK_2 + tags: + - : + - : + service: + min_collection_interval: 60 + empty_default_hostname: true + metric_patterns: + include: + - + exclude: + - + + init_config: + # No init_config details needed + EOF + + cached(:chef_run) do + ChefSpec::SoloRunner.new( + platform: 'ubuntu', + version: '16.04', + step_into: ['datadog_monitor'] + ) do |node| + node.automatic['languages'] = { 'python' => { 'version' => '2.7.2' } } + node.normal['datadog'] = { + api_key: 'someapikey', + gearmand: { + instances: [ + { + server: '127.0.0.1', + port: '4730', + tasks: [ + 'TASK_1', + 'TASK_2', + ], + tags: [ + ':', + ':' + ], + service: '', + # Defaults to 15 if not set + min_collection_interval: 60, + # Defaults to false if not set + empty_default_hostname: true, + metric_patterns: { + include: [ + '' + ], + exclude: [ + '' + ] + } + } + ] + } + } + end.converge(described_recipe) + end + + subject { chef_run } + + it_behaves_like 'datadog-agent' + + it { is_expected.to include_recipe('datadog::dd-agent') } + + it { is_expected.to add_datadog_monitor('gearmand') } + + it 'renders expected YAML config file' do + expect(chef_run).to(render_file('/etc/datadog-agent/conf.d/gearmand.d/conf.yaml').with_content { |content| + expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json) + }) + end +end diff --git a/spec/integrations/go-metro_spec.rb b/spec/integrations/go-metro_spec.rb index b98c9823..ae4278b4 100644 --- a/spec/integrations/go-metro_spec.rb +++ b/spec/integrations/go-metro_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::go-metro' do context 'with default init_config and libcap package on RHEL7' do expected_yaml = <<-EOF diff --git a/spec/integrations/go_expvar_spec.rb b/spec/integrations/go_expvar_spec.rb index 7669f12f..5177269d 100644 --- a/spec/integrations/go_expvar_spec.rb +++ b/spec/integrations/go_expvar_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::go_expvar' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/gunicorn_spec.rb b/spec/integrations/gunicorn_spec.rb index 00901523..3a3890be 100644 --- a/spec/integrations/gunicorn_spec.rb +++ b/spec/integrations/gunicorn_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::gunicorn' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/hive_spec.rb b/spec/integrations/hive_spec.rb new file mode 100644 index 00000000..4693d522 --- /dev/null +++ b/spec/integrations/hive_spec.rb @@ -0,0 +1,57 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +describe 'datadog::hive' do + expected_yaml = <<-EOF + logs: ~ + init_config: + is_jmx: true + collect_default_metrics: true + instances: + - host: localhost + EOF + + cached(:chef_run) do + ChefSpec::SoloRunner.new( + platform: 'ubuntu', + version: '16.04', + step_into: ['datadog_monitor'] + ) do |node| + node.normal['datadog'] = { + api_key: 'someapikey', + hive: { + instances: [ + { + host: 'localhost', + } + ] + } + } + end.converge(described_recipe) + end + + subject { chef_run } + + it_behaves_like 'datadog-agent' + + it { is_expected.to include_recipe('datadog::dd-agent') } + + it { is_expected.to add_datadog_monitor('hive') } + + it 'renders expected YAML config file' do + expect(chef_run).to(render_file('/etc/datadog-agent/conf.d/hive.d/conf.yaml').with_content { |content| + expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json) + }) + end +end diff --git a/spec/integrations/iis_spec.rb b/spec/integrations/iis_spec.rb index 7b77d74e..51a4dbcf 100644 --- a/spec/integrations/iis_spec.rb +++ b/spec/integrations/iis_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::iis' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/integration_spec.rb b/spec/integrations/integration_spec.rb index 3b223135..6f4bd768 100644 --- a/spec/integrations/integration_spec.rb +++ b/spec/integrations/integration_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'chefspec' require_relative '../../libraries/test_helpers' diff --git a/spec/integrations/integrations_spec.rb b/spec/integrations/integrations_spec.rb index d01c882e..9b83e04d 100644 --- a/spec/integrations/integrations_spec.rb +++ b/spec/integrations/integrations_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::integrations' do expected_yaml = <<-EOF instances: diff --git a/spec/integrations/jmx_spec.rb b/spec/integrations/jmx_spec.rb index 61a71a31..3bff6718 100644 --- a/spec/integrations/jmx_spec.rb +++ b/spec/integrations/jmx_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::jmx' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/kafka_consumer_spec.rb b/spec/integrations/kafka_consumer_spec.rb new file mode 100644 index 00000000..9e87d2c3 --- /dev/null +++ b/spec/integrations/kafka_consumer_spec.rb @@ -0,0 +1,77 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +describe 'datadog::kafka_consumer' do + expected_yaml = <<-EOF + logs: + + instances: + - kafka_connect_str: localhost:19092 + consumer_groups: + my_consumer: + my_topic: [0, 1, 4, 12] + monitor_unlisted_consumer_groups: false + zk_connect_str: localhost:2181 + zk_prefix: /0.8 + kafka_consumer_offsets: true + + init_config: + # The Kafka Consumer check does not require any init_config + EOF + + cached(:chef_run) do + ChefSpec::SoloRunner.new( + platform: 'ubuntu', + version: '16.04', + step_into: ['datadog_monitor'] + ) do |node| + node.automatic['languages'] = { python: { version: '2.7.2' } } + + node.normal['datadog'] = { + api_key: 'someapikey', + kafka_consumer: { + instances: [ + { + kafka_connect_str: 'localhost:19092', + consumer_groups: { + my_consumer: { + my_topic: [0, 1, 4, 12] + } + }, + monitor_unlisted_consumer_groups: false, + zk_connect_str: 'localhost:2181', + password: 'localhost:2181', + zk_prefix: '/0.8', + kafka_consumer_offsets: true + } + ] + } + } + end.converge(described_recipe) + end + + subject { chef_run } + + it_behaves_like 'datadog-agent' + + it { is_expected.to include_recipe('datadog::dd-agent') } + + it { is_expected.to add_datadog_monitor('kafka_consumer') } + + it 'renders expected YAML config file' do + expect(chef_run).to(render_file('/etc/datadog-agent/conf.d/kafka_consumer.d/conf.yaml').with_content { |content| + expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json) + }) + end +end diff --git a/spec/integrations/kafka_spec.rb b/spec/integrations/kafka_spec.rb index c65e1333..49990996 100644 --- a/spec/integrations/kafka_spec.rb +++ b/spec/integrations/kafka_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::kafka' do context 'version 1 (default)' do expected_yaml = <<-EOF diff --git a/spec/integrations/kubernetes_spec.rb b/spec/integrations/kubernetes_spec.rb index 3cdcb14b..59e839ac 100644 --- a/spec/integrations/kubernetes_spec.rb +++ b/spec/integrations/kubernetes_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::kubernetes' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/mesos_master_spec.rb b/spec/integrations/mesos_master_spec.rb index 18b72f29..6106b48e 100644 --- a/spec/integrations/mesos_master_spec.rb +++ b/spec/integrations/mesos_master_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::mesos_master' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/mesos_slave_spec.rb b/spec/integrations/mesos_slave_spec.rb index a86098fd..bc04fb15 100644 --- a/spec/integrations/mesos_slave_spec.rb +++ b/spec/integrations/mesos_slave_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::mesos_slave' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/mongo_spec.rb b/spec/integrations/mongo_spec.rb index ff2ffb26..e86b72fd 100644 --- a/spec/integrations/mongo_spec.rb +++ b/spec/integrations/mongo_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::mongo' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/nginx_spec.rb b/spec/integrations/nginx_spec.rb index 3c09907b..e4fd6a7a 100644 --- a/spec/integrations/nginx_spec.rb +++ b/spec/integrations/nginx_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::nginx' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/php_fpm_spec.rb b/spec/integrations/php_fpm_spec.rb index 07456994..3064b317 100644 --- a/spec/integrations/php_fpm_spec.rb +++ b/spec/integrations/php_fpm_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::php_fpm' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/postfix_spec.rb b/spec/integrations/postfix_spec.rb index 4578a426..fdf918f4 100644 --- a/spec/integrations/postfix_spec.rb +++ b/spec/integrations/postfix_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::postfix' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/postgres_spec.rb b/spec/integrations/postgres_spec.rb index c9d981df..bf55b51b 100644 --- a/spec/integrations/postgres_spec.rb +++ b/spec/integrations/postgres_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::postgres' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/rabbitmq_spec.rb b/spec/integrations/rabbitmq_spec.rb index d1d82ccc..04f2d7d6 100644 --- a/spec/integrations/rabbitmq_spec.rb +++ b/spec/integrations/rabbitmq_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::rabbitmq' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/redis_spec.rb b/spec/integrations/redis_spec.rb index 3800767e..402d8d94 100644 --- a/spec/integrations/redis_spec.rb +++ b/spec/integrations/redis_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::redisdb' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/snmp_spec.rb b/spec/integrations/snmp_spec.rb index 16439b79..bcba89e2 100644 --- a/spec/integrations/snmp_spec.rb +++ b/spec/integrations/snmp_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::snmp' do context 'config snmp v1 - v2' do expected_yaml = <<-EOF diff --git a/spec/integrations/solr_spec.rb b/spec/integrations/solr_spec.rb index 0b32e7cd..4dfa6a1f 100644 --- a/spec/integrations/solr_spec.rb +++ b/spec/integrations/solr_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::solr' do expected_yaml = <<-EOF logs: ~ @@ -13,6 +27,7 @@ newTag: test init_config: + collect_default_metrics: true conf: - include: type: searcher @@ -77,6 +92,7 @@ avgRequestsPerSecond: alias: solr.search_handler.avg_requests_per_sec metric_type: gauge + is_jmx: true EOF cached(:chef_run) do diff --git a/spec/integrations/sqlserver_spec.rb b/spec/integrations/sqlserver_spec.rb index 7432583c..8ea6b255 100644 --- a/spec/integrations/sqlserver_spec.rb +++ b/spec/integrations/sqlserver_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::sqlserver' do context 'config 1' do expected_yaml = <<-EOF diff --git a/spec/integrations/system_core_spec.rb b/spec/integrations/system_core_spec.rb index b6a89b28..b3e69c60 100644 --- a/spec/integrations/system_core_spec.rb +++ b/spec/integrations/system_core_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::system_core' do expected_yaml = <<-EOF # Generated by Chef, local modifications will be overwritten diff --git a/spec/integrations/system_swap_spec.rb b/spec/integrations/system_swap_spec.rb index b5a548bf..9c2113a7 100644 --- a/spec/integrations/system_swap_spec.rb +++ b/spec/integrations/system_swap_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::system_swap' do expected_yaml = <<-EOF # Generated by Chef, local modifications will be overwritten diff --git a/spec/integrations/systemd_spec.rb b/spec/integrations/systemd_spec.rb index a4d9f65c..e8a646d4 100644 --- a/spec/integrations/systemd_spec.rb +++ b/spec/integrations/systemd_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::systemd' do expected_yaml = <<-EOF init_config: ~ @@ -15,6 +29,9 @@ mysocket.socket: exited: critical running: ok + mytimer.timer: + exited: critical + running: ok tags: - 'mykey1:myvalue1' - 'mykey2:myvalue2' @@ -22,6 +39,7 @@ - myservice1.service - myservice2.service - mysocket.socket + - mytimer.timer logs: ~ EOF @@ -40,7 +58,8 @@ unit_names: [ 'myservice1.service', 'myservice2.service', - 'mysocket.socket' + 'mysocket.socket', + 'mytimer.timer' ], substate_status_mapping: [ services: [ @@ -61,6 +80,12 @@ running: 'ok', exited: 'critical' } + ], + timers: [ + mytimer: { + running: 'ok', + exited: 'critical' + } ] ], tags: [ diff --git a/spec/integrations/tokumx_spec.rb b/spec/integrations/tokumx_spec.rb index 3dd032f0..48f0d4e3 100644 --- a/spec/integrations/tokumx_spec.rb +++ b/spec/integrations/tokumx_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::tokumx' do expected_yaml = <<-EOF logs: ~ diff --git a/spec/integrations/win32_event_log_spec.rb b/spec/integrations/win32_event_log_spec.rb index de11706c..420298f1 100644 --- a/spec/integrations/win32_event_log_spec.rb +++ b/spec/integrations/win32_event_log_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::win32_event_log' do expected_yaml = <<-EOF init_config: diff --git a/spec/integrations/windows_service_spec.rb b/spec/integrations/windows_service_spec.rb index 08220bda..9a4a00b4 100644 --- a/spec/integrations/windows_service_spec.rb +++ b/spec/integrations/windows_service_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::windows_service' do expected_yaml = <<-EOF instances: diff --git a/spec/integrations/wmi_check_spec.rb b/spec/integrations/wmi_check_spec.rb index 0204352f..dd7328c0 100644 --- a/spec/integrations/wmi_check_spec.rb +++ b/spec/integrations/wmi_check_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + describe 'datadog::wmi_check' do context 'config wmi_check' do expected_yaml = <<-EOF diff --git a/spec/recipe_helpers_spec.rb b/spec/recipe_helpers_spec.rb index 98c8eee0..9b530c1b 100644 --- a/spec/recipe_helpers_spec.rb +++ b/spec/recipe_helpers_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'spec_helper' require_relative '../libraries/recipe_helpers' @@ -37,15 +51,13 @@ context 'when the agent is installed' do before do allow(Chef::Datadog::WindowsInstallHelpers) - .to receive(:agent_status) - .and_return(agent_status_string) + .to receive(:agent_get_version) + .and_return(agent_version_string) end - let(:agent_status_string) do + let(:agent_version_string) do %( -..... -Agent (v6.20.0) -.... +Agent 6.20.0 - Commit: 3c29612 - Serialization version: v5.0.22 - Go version: go1.17.11 ) end @@ -70,11 +82,9 @@ end context 'when the current agent version is a nightly' do - let(:agent_status) do + let(:agent_get_version) do %( -..... -Agent (v6.20.0-devel+git.38.cd7f989) -.... +Agent 6.20.0-devel - Meta: git.38.cd7f989 - Commit: cd7f98964 - Serialization version: v5.0.22 - Go version: go1.17.11 ) end diff --git a/spec/remove-dd-agent_spec.rb b/spec/remove-dd-agent_spec.rb new file mode 100644 index 00000000..462821f7 --- /dev/null +++ b/spec/remove-dd-agent_spec.rb @@ -0,0 +1,65 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +# Importing apt_sources_list_file variable from recipe_helpers.rb +apt_sources_list_file = Chef::Datadog.apt_sources_list_file + +describe 'datadog::remove-dd-agent' do + context 'when on Ubuntu' do + let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '20.04').converge(described_recipe) } + + it 'purges the datadog-agent package' do + expect(chef_run).to purge_package('datadog-agent') + end + + it 'removes apt_sources_list_file and purges the datadog-signing-keys package' do + expect(chef_run).to purge_apt_package('datadog-signing-keys') + expect(chef_run).to delete_file(apt_sources_list_file) + end + end + + context 'when on Amazon Linux' do + let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'amazon', version: '2').converge(described_recipe) } + + it 'purges the datadog-agent package' do + expect(chef_run).to purge_package('datadog-agent') + end + + it 'removes the datadog yum repository' do + expect(chef_run).to remove_yum_repository('datadog') + end + end + + context 'when on Suse' do + let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'suse', version: '12.5').converge(described_recipe) } + + it 'purges the datadog-agent package' do + expect(chef_run).to purge_package('datadog-agent') + end + + it 'removes the datadog zypper repository' do + expect(chef_run).to remove_zypper_repository('datadog') + end + end + + context 'when on Windows' do + let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'windows', version: '2016').converge(described_recipe) } + + it 'removes the Datadog Agent package' do + expect(chef_run).to remove_package('Datadog Agent') + end + end +end diff --git a/spec/repository_spec.rb b/spec/repository_spec.rb index 1564fa15..0fbd7d95 100644 --- a/spec/repository_spec.rb +++ b/spec/repository_spec.rb @@ -1,8 +1,111 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +shared_examples 'old debianoid' do + it 'properly creates both keyring files and imports all keys' do + expect(chef_run).to create_file_if_missing('/usr/share/keyrings/datadog-archive-keyring.gpg') + expect(chef_run).to create_remote_file('/etc/apt/trusted.gpg.d/datadog-archive-keyring.gpg').with( + source: 'file:///usr/share/keyrings/datadog-archive-keyring.gpg') + expect(chef_run).to create_file('/etc/apt/sources.list.d/datadog.list').with( + content: 'deb [signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg] https://apt.datadoghq.com stable 7' + ) + + # NOTE: there is no way in chefspec to actually test the notified action, + # see https://github.com/chefspec/chefspec/issues/541 + expect(chef_run.remote_file('remote_file_DATADOG_APT_KEY_CURRENT.public')).to notify( + 'execute[import apt datadog key DATADOG_APT_KEY_CURRENT.public]').to(:run).immediately + expect(chef_run.remote_file('remote_file_D18886567EABAD8B2D2526900D826EB906462314')).to notify( + 'execute[import apt datadog key D18886567EABAD8B2D2526900D826EB906462314]').to(:run).immediately + expect(chef_run.remote_file('remote_file_5F1E256061D813B125E156E8E6266D4AC0962C7D')).to notify( + 'execute[import apt datadog key 5F1E256061D813B125E156E8E6266D4AC0962C7D]').to(:run).immediately + expect(chef_run.remote_file('remote_file_D75CEA17048B9ACBF186794B32637D44F14F620E')).to notify( + 'execute[import apt datadog key D75CEA17048B9ACBF186794B32637D44F14F620E]').to(:run).immediately + expect(chef_run.remote_file('remote_file_A2923DFF56EDA6E76E55E492D3A80E30382E94DE')).to notify( + 'execute[import apt datadog key A2923DFF56EDA6E76E55E492D3A80E30382E94DE]').to(:run).immediately + end +end + +shared_examples 'new debianoid' do + it 'properly creates the keyring file and imports all keys' do + expect(chef_run).to create_file_if_missing('/usr/share/keyrings/datadog-archive-keyring.gpg') + expect(chef_run).to_not create_remote_file('/etc/apt/trusted.gpg.d/datadog-archive-keyring.gpg') + expect(chef_run).to create_file('/etc/apt/sources.list.d/datadog.list').with( + content: 'deb [signed-by=/usr/share/keyrings/datadog-archive-keyring.gpg] https://apt.datadoghq.com stable 7' + ) + + expect(chef_run.remote_file('remote_file_DATADOG_APT_KEY_CURRENT.public')).to notify( + 'execute[import apt datadog key DATADOG_APT_KEY_CURRENT.public]').to(:run).immediately + expect(chef_run.remote_file('remote_file_D18886567EABAD8B2D2526900D826EB906462314')).to notify( + 'execute[import apt datadog key D18886567EABAD8B2D2526900D826EB906462314]').to(:run).immediately + expect(chef_run.remote_file('remote_file_5F1E256061D813B125E156E8E6266D4AC0962C7D')).to notify( + 'execute[import apt datadog key 5F1E256061D813B125E156E8E6266D4AC0962C7D]').to(:run).immediately + expect(chef_run.remote_file('remote_file_D75CEA17048B9ACBF186794B32637D44F14F620E')).to notify( + 'execute[import apt datadog key D75CEA17048B9ACBF186794B32637D44F14F620E]').to(:run).immediately + expect(chef_run.remote_file('remote_file_A2923DFF56EDA6E76E55E492D3A80E30382E94DE')).to notify( + 'execute[import apt datadog key A2923DFF56EDA6E76E55E492D3A80E30382E94DE]').to(:run).immediately + end +end + +def import_gpg_keys(key_list, install_gnupg = true) + key_list.each do |key| + unless key.eql? 'current' + set_yum_repo_and_gnupg(key, install_gnupg) + end + + it "downloads the #{key} RPM key" do + expect(chef_run).to create_remote_file("remote_file_DATADOG_RPM_KEY_#{key.upcase}.public").with(path: ::File.join(Chef::Config[:file_cache_path], "DATADOG_RPM_KEY_#{key.upcase}.public")) + end + + it "notifies the GPG key install if a new one is downloaded #{key.upcase}" do + keyfile_r = chef_run.remote_file("remote_file_DATADOG_RPM_KEY_#{key.upcase}.public") + expect(keyfile_r).to notify("execute[rpm-import datadog key #{key}]") + .to(:run).immediately + end + + if key.eql? 'current' + it 'execute[rpm-import datadog key *] by default CURRENT' do + keyfile_exec_r = chef_run.execute('rpm-import datadog key current') + expect(keyfile_exec_r).to do_nothing + end + else + it "doesn\'t execute[rpm-import datadog key *] by default #{key.upcase}" do + keyfile_exec_r = chef_run.execute("rpm-import datadog key #{key}") + expect(keyfile_exec_r).to do_nothing + end + end + end +end + +def set_yum_repo_and_gnupg(key, install_gnupg) + it "sets the yumrepo_gpgkey_new attribute #{key}" do + expect(chef_run.node['datadog']["yumrepo_gpgkey_new_#{key}"]).to match( + /DATADOG_RPM_KEY_#{key.upcase}.public/ + ) + end + + if install_gnupg + it "installs gnupg #{key.upcase}" do + expect(chef_run).to install_package('gnupg') if chef_run.node['packages']['gnupg2'].nil? + end + end +end + describe 'datadog::repository' do context 'on debianoids' do cached(:chef_run) do ChefSpec::SoloRunner.new( - platform: 'debian', version: '8.9' + platform: 'debian', version: '8.11' ).converge(described_recipe) end @@ -14,24 +117,63 @@ expect(chef_run).to install_package('install-apt-transport-https') end - it 'sets up an apt repo with fingerprint A2923DFF56EDA6E76E55E492D3A80E30382E94DE and D75CEA17048B9ACBF186794B32637D44F14F620E' do - expect(chef_run).to add_apt_repository('datadog').with( - key: ['D75CEA17048B9ACBF186794B32637D44F14F620E'] - ) - expect(chef_run).to run_execute('apt-key import key 382E94DE') - end + # testing of creation of the source file + keyrings is done for various cases in different methods it 'removes the datadog-beta repo' do expect(chef_run).to remove_apt_repository('datadog-beta') end + it 'removes the datadog_apt_D75CEA17048B9ACBF186794B32637D44F14F620E repo' do + expect(chef_run).to remove_apt_repository('datadog_apt_D75CEA17048B9ACBF186794B32637D44F14F620E') + end + it 'removes the datadog_apt_A2923DFF56EDA6E76E55E492D3A80E30382E94DE repo' do expect(chef_run).to remove_apt_repository('datadog_apt_A2923DFF56EDA6E76E55E492D3A80E30382E94DE') end + end - it 'removes the datadog_apt_D75CEA17048B9ACBF186794B32637D44F14F620E repo' do - expect(chef_run).to remove_apt_repository('datadog_apt_D75CEA17048B9ACBF186794B32637D44F14F620E') + context 'debian < 9' do + cached(:chef_run) do + ChefSpec::SoloRunner.new( + # Fauxhai doesn't have definition for Debian < 9, but we can + # workaround that by setting platform_version below + platform: 'debian', version: '9.11' + ) do |node| + node.automatic['platform_version'] = '8.0' + end.converge(described_recipe) end + + it_behaves_like 'old debianoid' + end + + context 'ubuntu < 16' do + cached(:chef_run) do + ChefSpec::SoloRunner.new( + platform: 'ubuntu', version: '14.04' + ).converge(described_recipe) + end + + it_behaves_like 'old debianoid' + end + + context 'debian >= 9' do + cached(:chef_run) do + ChefSpec::SoloRunner.new( + platform: 'debian', version: '9.11' + ).converge(described_recipe) + end + + it_behaves_like 'new debianoid' + end + + context 'ubuntu >= 16' do + cached(:chef_run) do + ChefSpec::SoloRunner.new( + platform: 'ubuntu', version: '16.04' + ).converge(described_recipe) + end + + it_behaves_like 'new debianoid' end context 'rhellions' do @@ -44,82 +186,24 @@ end.converge(described_recipe) end + # Key B01082D3 (from 2023-04-20 to 2028-04-18) + # Key FD4BF915 (from 2020-09-08 to 2024-09-07) # Key E09422B3 - it 'sets the yumrepo_gpgkey_new attribute E09422B3' do - expect(chef_run.node['datadog']['yumrepo_gpgkey_new_e09422b3']).to match( - /DATADOG_RPM_KEY_E09422B3.public/ - ) - end - - it 'installs gnupg E09422B3' do - epect(chef_run).to install_package('gnupg') if chef_run.node['packages']['gnupg2'].nil? - end - - it 'downloads the current RPM key' do - expect(chef_run).to create_remote_file('remote_file_DATADOG_RPM_KEY_CURRENT.public').with(path: ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY_CURRENT.public')) - end - - it 'notifies the GPG key install if a new one is downloaded CURRENT' do - keyfile_r = chef_run.remote_file('remote_file_DATADOG_RPM_KEY_CURRENT.public') - expect(keyfile_r).to notify('execute[rpm-import datadog key current]') - .to(:run).immediately - end - - it 'execute[rpm-import datadog key *] by default CURRENT' do - keyfile_exec_r = chef_run.execute('rpm-import datadog key current') - expect(keyfile_exec_r).to do_nothing - end - - it 'downloads the new RPM key E09422B3' do - expect(chef_run).to create_remote_file('remote_file_DATADOG_RPM_KEY_E09422B3.public').with(path: ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY_E09422B3.public')) - end - - it 'notifies the GPG key install if a new one is downloaded E09422B3' do - keyfile_r = chef_run.remote_file('remote_file_DATADOG_RPM_KEY_E09422B3.public') - expect(keyfile_r).to notify('execute[rpm-import datadog key e09422b3]') - .to(:run).immediately - end - - it 'doesn\'t execute[rpm-import datadog key *] by default E09422B3' do - keyfile_exec_r = chef_run.execute('rpm-import datadog key e09422b3') - expect(keyfile_exec_r).to do_nothing - end - - # Key FD4BF915 (2020-09-08) - it 'sets the yumrepo_gpgkey_new attribute fd4bf915' do - expect(chef_run.node['datadog']['yumrepo_gpgkey_new_fd4bf915']).to match( - /DATADOG_RPM_KEY_FD4BF915.public/ - ) - end - - it 'installs fd4bf915' do - expect(chef_run).to install_package('gnupg') if chef_run.node['packages']['gnupg2'].nil? - end - - it 'downloads the new RPM key fd4bf915' do - expect(chef_run).to create_remote_file('remote_file_DATADOG_RPM_KEY_FD4BF915.public').with(path: ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY_FD4BF915.public')) - end - - it 'notifies the GPG key install if a new one is downloaded fd4bf915' do - keyfile_r = chef_run.remote_file('remote_file_DATADOG_RPM_KEY_FD4BF915.public') - expect(keyfile_r).to notify('execute[rpm-import datadog key fd4bf915]') - .to(:run).immediately - end - - it 'doesn\'t execute[rpm-import datadog key *] by default fd4bf915' do - keyfile_exec_r = chef_run.execute('rpm-import datadog key fd4bf915') - expect(keyfile_exec_r).to do_nothing - end + import_gpg_keys( + %w[current 4f09d16b b01082d3 fd4bf915 e09422b3] + ) # prefer HTTPS on boxes that support TLS1.2 - it 'sets up a yum repo E09422B3 and FD4BF915' do + it 'sets up a yum repo E09422B3, FD4BF915 and B01082D3' do expect(chef_run).to create_yum_repository('datadog').with( gpgkey: [ 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_4F09D16B.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', ] - ) + ).with(repo_gpgcheck: true) end end @@ -132,68 +216,27 @@ end.converge(described_recipe) end + # Key B01082D3 (from 2023-04-20 to 2028-04-18) + # Key FD4BF915 (from 2020-09-08 to 2024-09-07) # Key E09422B3 - it 'sets the yumrepo_gpgkey_new attribute E09422B3' do - expect(chef_run.node['datadog']['yumrepo_gpgkey_new_e09422b3']).to match( - /DATADOG_RPM_KEY_E09422B3.public/ - ) - end - - it 'installs gnupg E09422B3' do - expect(chef_run).to install_package('gnupg') if chef_run.node['packages']['gnupg2'].nil? - end - - it 'downloads the new RPM key E09422B3' do - expect(chef_run).to create_remote_file('remote_file_DATADOG_RPM_KEY_E09422B3.public').with(path: ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY_E09422B3.public')) - end - - it 'notifies the GPG key install if a new one is downloaded E09422B3' do - keyfile_r = chef_run.remote_file('remote_file_DATADOG_RPM_KEY_E09422B3.public') - expect(keyfile_r).to notify('execute[rpm-import datadog key e09422b3]') - .to(:run).immediately - end - - it 'doesn\'t execute[rpm-import datadog key *] by default E09422B3' do - keyfile_exec_r = chef_run.execute('rpm-import datadog key e09422b3') - expect(keyfile_exec_r).to do_nothing - end - - # Key FD4BF915 (2020-09-08) - it 'sets the yumrepo_gpgkey_new attribute fd4bf915' do - expect(chef_run.node['datadog']['yumrepo_gpgkey_new_fd4bf915']).to match( - /DATADOG_RPM_KEY_FD4BF915.public/ - ) - end - - it 'installs gnupg fd4bf915' do - expect(chef_run).to install_package('gnupg') if chef_run.node['packages']['gnupg2'].nil? - end - - it 'downloads the new RPM key fd4bf915' do - expect(chef_run).to create_remote_file('remote_file_DATADOG_RPM_KEY_FD4BF915.public').with(path: ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY_FD4BF915.public')) - end - - it 'notifies the GPG key install if a new one is downloaded fd4bf915' do - keyfile_r = chef_run.remote_file('remote_file_DATADOG_RPM_KEY_FD4BF915.public') - expect(keyfile_r).to notify('execute[rpm-import datadog key fd4bf915]') - .to(:run).immediately - end - - it 'doesn\'t execute[rpm-import datadog key *] by default fd4bf915' do - keyfile_exec_r = chef_run.execute('rpm-import datadog key fd4bf915') - expect(keyfile_exec_r).to do_nothing - end + import_gpg_keys([ + '4f09d16b', + 'b01082d3', + 'fd4bf915', + 'e09422b3' + ]) # prefer HTTPS on boxes that support TLS1.2 it 'sets up a yum repo' do expect(chef_run).to create_yum_repository('datadog').with( gpgkey: [ 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_4F09D16B.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', - 'https://keys.datadoghq.com/DATADOG_RPM_KEY.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', ] - ) + ).with(repo_gpgcheck: true) end end @@ -206,69 +249,120 @@ end.converge(described_recipe) end + # Key B01082D3 (from 2023-04-20 to 2028-04-18) + # Key FD4BF915 (from 2020-09-08 to 2024-09-07) # Key E09422B3 - it 'sets the yumrepo_gpgkey_new attribute E09422B3' do - expect(chef_run.node['datadog']['yumrepo_gpgkey_new_e09422b3']).to match( - /DATADOG_RPM_KEY_E09422B3.public/ - ) - end - - it 'installs gnupg' do - expect(chef_run).to install_package('gnupg') if chef_run.node['packages']['gnupg2'].nil? - end + import_gpg_keys([ + '4f09d16b', + 'b01082d3', + 'fd4bf915', + 'e09422b3' + ]) - it 'downloads the new RPM key E09422B3' do - expect(chef_run).to create_remote_file('remote_file_DATADOG_RPM_KEY_E09422B3.public').with(path: ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY_E09422B3.public')) + # RHEL5 has to use insecure HTTP due to lack of support for TLS1.2 + # https://github.com/DataDog/chef-datadog/blob/v2.8.1/attributes/default.rb#L85-L91 + it 'sets up a yum repo' do + expect(chef_run).to create_yum_repository('datadog').with( + gpgkey: [ + 'http://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', + 'http://keys.datadoghq.com/DATADOG_RPM_KEY_4F09D16B.public', + 'http://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', + 'http://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', + 'http://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', + ] + ).with(repo_gpgcheck: false) end + end - it 'notifies the GPG key install if a new one is downloaded E09422B3' do - keyfile_r = chef_run.remote_file('remote_file_DATADOG_RPM_KEY_E09422B3.public') - expect(keyfile_r).to notify('execute[rpm-import datadog key e09422b3]') - .to(:run).immediately + context 'centos 8.1, agent 6' do + cached(:chef_run) do + ChefSpec::SoloRunner.new( + platform: 'centos', version: '8' + ) do |node| + node.normal['datadog'] = { 'agent_major_version' => '6' } + node.automatic['platform_version'] = '8.1' + end.converge(described_recipe) end - it 'doesn\'t execute[rpm-import datadog key *] by default E09422B3' do - keyfile_exec_r = chef_run.execute('rpm-import datadog key e09422b3') - expect(keyfile_exec_r).to do_nothing + it 'disables repo_gpgcheck because of dnf bug in RHEL 8.1' do + expect(chef_run).to create_yum_repository('datadog').with( + gpgkey: [ + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_4F09D16B.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', + ] + ).with(repo_gpgcheck: false) end + end - # Key FD4BF915 (2020-09-08) - it 'sets the yumrepo_gpgkey_new attribute fd4bf915' do - expect(chef_run.node['datadog']['yumrepo_gpgkey_new_fd4bf915']).to match( - /DATADOG_RPM_KEY_FD4BF915.public/ - ) + context 'centos 8.2, agent 6' do + cached(:chef_run) do + ChefSpec::SoloRunner.new( + platform: 'centos', version: '8' + ) do |node| + node.normal['datadog'] = { 'agent_major_version' => '6' } + node.automatic['platform_version'] = '8.2' + end.converge(described_recipe) end - it 'installs gnupg' do - expect(chef_run).to install_package('gnupg') if chef_run.node['packages']['gnupg2'].nil? + it 'enables repo_gpgcheck because of fixed dnf bug in RHEL 8.2' do + expect(chef_run).to create_yum_repository('datadog').with( + gpgkey: [ + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_4F09D16B.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', + ] + ).with(repo_gpgcheck: true) end + end - it 'downloads the new RPM key fd4bf915' do - expect(chef_run).to create_remote_file('remote_file_DATADOG_RPM_KEY_FD4BF915.public').with(path: ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY_FD4BF915.public')) + context 'almalinux 8.5, agent 6', if: min_chef_version('17.0.69') do + cached(:chef_run) do + ChefSpec::SoloRunner.new( + platform: 'almalinux', version: '8' + ) do |node| + node.normal['datadog'] = { 'agent_major_version' => '6' } + node.automatic['platform_version'] = '8.5' + end.converge(described_recipe) end - it 'notifies the GPG key install if a new one is downloaded fd4bf915' do - keyfile_r = chef_run.remote_file('remote_file_DATADOG_RPM_KEY_FD4BF915.public') - expect(keyfile_r).to notify('execute[rpm-import datadog key fd4bf915]') - .to(:run).immediately + it 'sets up the yum repo' do + expect(chef_run).to create_yum_repository('datadog').with( + gpgkey: [ + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_4F09D16B.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', + ] + ).with(repo_gpgcheck: true) end + end - it 'doesn\'t execute[rpm-import datadog key *] by default fd4bf915' do - keyfile_exec_r = chef_run.execute('rpm-import datadog key fd4bf915') - expect(keyfile_exec_r).to do_nothing + context 'rocky 8.5, agent 6', if: min_chef_version('17.1.35') do + cached(:chef_run) do + ChefSpec::SoloRunner.new( + platform: 'rocky', version: '8' + ) do |node| + node.normal['datadog'] = { 'agent_major_version' => '6' } + node.automatic['platform_version'] = '8.5' + end.converge(described_recipe) end - # RHEL5 has to use insecure HTTP due to lack of support for TLS1.2 - # https://github.com/DataDog/chef-datadog/blob/v2.8.1/attributes/default.rb#L85-L91 - it 'sets up a yum repo' do + it 'sets up the yum repo' do expect(chef_run).to create_yum_repository('datadog').with( gpgkey: [ - 'http://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', - 'http://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', - 'http://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', - 'http://keys.datadoghq.com/DATADOG_RPM_KEY.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_4F09D16B.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_B01082D3.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public', + 'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public', ] - ) + ).with(repo_gpgcheck: true) end end end @@ -287,69 +381,30 @@ end.converge(described_recipe) end - # Key E09422B3 - it 'sets the yumrepo_gpgkey_new attribute E09422B3' do - expect(chef_run.node['datadog']['yumrepo_gpgkey_new_e09422b3']).to match( - /DATADOG_RPM_KEY_E09422B3.public/ - ) - end - - it 'downloads the new RPM key E09422B3' do - expect(chef_run).to create_remote_file('remote_file_DATADOG_RPM_KEY_E09422B3.public').with(path: ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY_E09422B3.public')) - end - - it 'notifies the GPG key install if a new one is downloaded E09422B3' do - keyfile_r = chef_run.remote_file('remote_file_DATADOG_RPM_KEY_E09422B3.public') - expect(keyfile_r).to notify('execute[rpm-import datadog key e09422b3]') - .to(:run).immediately - end - - it 'doesn\'t execute[rpm-import datadog key *] by default E09422B3' do - keyfile_exec_r = chef_run.execute('rpm-import datadog key e09422b3') - expect(keyfile_exec_r).to do_nothing - end - - # Key FD4BF915 (2020-09-08) - it 'sets the yumrepo_gpgkey_new attribute fd4bf915' do - expect(chef_run.node['datadog']['yumrepo_gpgkey_new_fd4bf915']).to match( - /DATADOG_RPM_KEY_FD4BF915.public/ - ) - end + import_gpg_keys([ + '4f09d16b', + 'b01082d3', + 'fd4bf915', + 'e09422b3' + ], false) - it 'downloads the new RPM key fd4bf915' do - expect(chef_run).to create_remote_file('remote_file_DATADOG_RPM_KEY_FD4BF915.public').with(path: ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY_FD4BF915.public')) - end - - it 'notifies the GPG key install if a new one is downloaded fd4bf915' do - keyfile_r = chef_run.remote_file('remote_file_DATADOG_RPM_KEY_FD4BF915.public') - expect(keyfile_r).to notify('execute[rpm-import datadog key fd4bf915]') - .to(:run).immediately - end - - it 'doesn\'t execute[rpm-import datadog key *] by default fd4bf915' do - keyfile_exec_r = chef_run.execute('rpm-import datadog key fd4bf915') - expect(keyfile_exec_r).to do_nothing - end - - it 'downloads the old RPM key 4172a230' do - expect(chef_run).to create_remote_file('DATADOG_RPM_KEY.public').with(path: ::File.join(Chef::Config[:file_cache_path], 'DATADOG_RPM_KEY.public')) - end - - it 'notifies the GPG key install if the old key is downloaded 4172a230' do - keyfile_r = chef_run.remote_file('DATADOG_RPM_KEY.public') - expect(keyfile_r).to notify('execute[rpm-import datadog key 4172a230]') - .to(:run).immediately - end - - it 'doesn\'t execute[rpm-import datadog key *] by default 4172a230' do - keyfile_exec_r = chef_run.execute('rpm-import datadog key 4172a230') - expect(keyfile_exec_r).to do_nothing + it 'deletes the old RPM GPG key 4172a230 if it exists' do + expect(chef_run).to run_execute('rpm-remove old gpg key 4172a230-55dd14f6') + .with(command: 'rpm --erase gpg-pubkey-4172a230-55dd14f6') end it 'sets up a yum repo' do - expect(chef_run).to create_zypper_repository('datadog').with( - gpgkey: 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public' - ) + # Since Chef 17, the gpgkey field is automatically converted into an + # array by the zypper_repository resource. + if Gem::Version.new(Chef::VERSION) >= Gem::Version.new(17) + expect(chef_run).to create_zypper_repository('datadog').with( + gpgkey: ['https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public'] + ) + else + expect(chef_run).to create_zypper_repository('datadog').with( + gpgkey: 'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public' + ) + end end end end diff --git a/spec/security-agent_spec.rb b/spec/security-agent_spec.rb new file mode 100644 index 00000000..e7d025bf --- /dev/null +++ b/spec/security-agent_spec.rb @@ -0,0 +1,127 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'datadog::security-agent' do + context 'with CWS enabled' do + cached(:solo) do + ChefSpec::SoloRunner.new( + platform: 'ubuntu', + version: '16.04' + ) do |node| + node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml` + node.normal['datadog'] = { + 'api_key' => 'somethingnotnil', + 'agent_major_version' => 6, + 'security_agent' => { + 'cws' => { + 'enabled' => true, + } + }, + 'extra_config' => { + 'security_agent' => { + 'runtime_security_config' => { + 'activity_dump' => { + 'enabled' => true, + } + } + } + } + } + end + end + + cached(:chef_run) do + solo.converge(described_recipe) do + solo.resource_collection.insert( + Chef::Resource::Service.new('datadog-agent', solo.run_context)) + end + end + + it 'security-agent.yaml is created' do + expect(chef_run).to create_template('/etc/datadog-agent/security-agent.yaml') + end + + it 'security-agent.yaml contains expected YAML configuration' do + expected_yaml = <<-EOF + compliance_config: + enabled: false + runtime_security_config: + enabled: true + activity_dump: + enabled: true + EOF + + expect(chef_run).to(render_file('/etc/datadog-agent/security-agent.yaml').with_content { |content| + expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json) + }) + end + end + + context 'with CWS enabled on Windows' do + cached(:solo) do + ChefSpec::SoloRunner.new( + platform: 'windows', + version: '2012R2' + ) do |node| + node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml` + node.normal['datadog'] = { + 'api_key' => 'somethingnotnil', + 'agent_major_version' => 6, + 'security_agent' => { + 'cws' => { + 'enabled' => true, + } + }, + 'extra_config' => { + 'security_agent' => { + 'runtime_security_config' => { + 'activity_dump' => { + 'enabled' => true, + } + } + } + } + } + end + end + + cached(:chef_run) do + solo.converge(described_recipe) do + solo.resource_collection.insert( + Chef::Resource::Service.new('datadog-agent', solo.run_context)) + end + end + + it 'security-agent.yaml is created' do + expect(chef_run).to create_template('C:/ProgramData/Datadog/security-agent.yaml') + end + + it 'security-agent.yaml contains expected YAML configuration' do + expected_yaml = <<-EOF + compliance_config: + enabled: false + runtime_security_config: + enabled: true + activity_dump: + enabled: true + EOF + + expect(chef_run).to(render_file('C:/ProgramData/Datadog/security-agent.yaml').with_content { |content| + expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json) + }) + end + end +end diff --git a/spec/shared_examples.rb b/spec/shared_examples.rb index 17bd34c5..b6c7cedf 100644 --- a/spec/shared_examples.rb +++ b/spec/shared_examples.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + shared_examples_for 'datadog-agent service' do it 'enables the datadog-agent service' do expect(chef_run).to enable_service 'datadog-agent' @@ -78,6 +92,14 @@ end end +shared_examples_for 'rhellions dnf datadog-agent v5' do + it_behaves_like 'datadog-agent v5' + + it 'installs the datadog-agent' do + expect(chef_run).to install_dnf_package 'datadog-agent' + end +end + shared_examples_for 'rhellions datadog-agent' do it_behaves_like 'datadog-agent' @@ -86,6 +108,23 @@ end end +shared_examples_for 'rhellions datadog-agent rhel<7' do + it_behaves_like 'datadog-agent' + + # Centos < 7 was deprecated on Agent 7.52 + it 'installs the version-capped datadog-agent' do + expect(chef_run).to install_yum_package 'datadog-agent < 1:7.52.0-1' + end +end + +shared_examples_for 'rhellions dnf datadog-agent' do + it_behaves_like 'datadog-agent' + + it 'installs the datadog-agent' do + expect(chef_run).to install_dnf_package 'datadog-agent' + end +end + shared_examples_for 'common windows resources' do it_behaves_like 'datadog-agent service' it_behaves_like 'datadog conf' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8e4d4d6a..83faab25 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'chefspec' require 'chefspec/berkshelf' require 'coveralls' @@ -8,6 +22,10 @@ require 'shared_examples' +def min_chef_version(version) + Gem.loaded_specs['chef'].version > Gem::Version.new(version) +end + RSpec.configure do |config| # Use color not only in STDOUT but also in pagers and files config.tty = true @@ -28,9 +46,11 @@ # recipes/repository.rb stub_command('rpm -q gpg-pubkey-current').and_return(false) - stub_command('rpm -q gpg-pubkey-e09422b3').and_return(false) + stub_command('rpm -q gpg-pubkey-4f09d16b').and_return(false) + stub_command('rpm -q gpg-pubkey-b01082d3').and_return(false) stub_command('rpm -q gpg-pubkey-fd4bf915').and_return(false) - stub_command('rpm -q gpg-pubkey-4172a230').and_return(false) + stub_command('rpm -q gpg-pubkey-e09422b3').and_return(false) + stub_command('rpm -q gpg-pubkey-4172a230-55dd14f6').and_return(true) stub_command('apt-key adv --list-public-keys --with-fingerprint --with-colons | grep 382E94DE | grep pub').and_return(false) end diff --git a/spec/system-probe_spec.rb b/spec/system-probe_spec.rb index bb94f14e..7bfb8f95 100644 --- a/spec/system-probe_spec.rb +++ b/spec/system-probe_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'spec_helper' describe 'datadog::system-probe' do @@ -32,6 +46,104 @@ end end + context 'with service_monitoring_enabled set to true' do + cached(:solo) do + ChefSpec::SoloRunner.new( + platform: 'ubuntu', + version: '16.04' + ) do |node| + node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml` + node.normal['datadog'] = { + 'api_key' => 'somethingnotnil', + 'agent_major_version' => 6, + 'system_probe' => { + 'debug_port' => 123, + 'bpf_debug' => true, + 'sysprobe_socket' => '/test/ing.sock', + 'service_monitoring_enabled' => true, + } + } + end + end + + cached(:chef_run) do + solo.converge(described_recipe) do + solo.resource_collection.insert( + Chef::Resource::Service.new('datadog-agent', solo.run_context)) + end + end + + it 'is created with enabled service_monitoring_enabled' do + expect(chef_run).to create_template('/etc/datadog-agent/system-probe.yaml') + end + + it 'contains expected YAML configuration' do + expected_yaml = <<-EOF + service_monitoring_config: + enabled: true + system_probe_config: + bpf_debug: true + debug_port: 123 + enable_conntrack: false + enabled: false + sysprobe_socket: "/test/ing.sock" + EOF + + expect(chef_run).to(render_file('/etc/datadog-agent/system-probe.yaml').with_content { |content| + expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json) + }) + end + end + + context 'with network_enabled set to true' do + cached(:solo) do + ChefSpec::SoloRunner.new( + platform: 'ubuntu', + version: '16.04' + ) do |node| + node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml` + node.normal['datadog'] = { + 'api_key' => 'somethingnotnil', + 'agent_major_version' => 6, + 'system_probe' => { + 'debug_port' => 123, + 'bpf_debug' => true, + 'sysprobe_socket' => '/test/ing.sock', + 'network_enabled' => true, + } + } + end + end + + cached(:chef_run) do + solo.converge(described_recipe) do + solo.resource_collection.insert( + Chef::Resource::Service.new('datadog-agent', solo.run_context)) + end + end + + it 'is created with enabled network_config' do + expect(chef_run).to create_template('/etc/datadog-agent/system-probe.yaml') + end + + it 'contains expected YAML configuration' do + expected_yaml = <<-EOF + network_config: + enabled: true + system_probe_config: + bpf_debug: true + debug_port: 123 + enable_conntrack: false + enabled: false + sysprobe_socket: "/test/ing.sock" + EOF + + expect(chef_run).to(render_file('/etc/datadog-agent/system-probe.yaml').with_content { |content| + expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json) + }) + end + end + context 'with system-probe enabled' do cached(:solo) do ChefSpec::SoloRunner.new( @@ -65,8 +177,6 @@ it 'contains expected YAML configuration' do expected_yaml = <<-EOF - network_config: - enabled: false system_probe_config: bpf_debug: true debug_port: 123 @@ -116,8 +226,6 @@ it 'contains expected YAML configuration' do expected_yaml = <<-EOF - network_config: - enabled: false system_probe_config: bpf_debug: false debug_port: 0 @@ -132,4 +240,115 @@ }) end end + + context 'with CWS enabled' do + cached(:solo) do + ChefSpec::SoloRunner.new( + platform: 'ubuntu', + version: '16.04' + ) do |node| + node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml` + node.normal['datadog'] = { + 'api_key' => 'somethingnotnil', + 'agent_major_version' => 6, + 'security_agent' => { + 'cws' => { + 'enabled' => true, + } + }, + 'extra_config' => { + 'security_agent' => { + 'runtime_security_config' => { + 'activity_dump' => { + 'enabled' => true, + } + } + } + } + } + end + end + + cached(:chef_run) do + solo.converge(described_recipe) do + solo.resource_collection.insert( + Chef::Resource::Service.new('datadog-agent', solo.run_context)) + solo.resource_collection.insert( + Chef::Resource::Service.new('datadog-agent-security', solo.run_context)) + end + end + + it 'system-probe.yaml is created' do + expect(chef_run).to create_template('/etc/datadog-agent/system-probe.yaml') + end + + it 'system-probe.yaml contains expected YAML configuration' do + expected_yaml = <<-EOF + runtime_security_config: + enabled: true + activity_dump: + enabled: true + system_probe_config: + enabled: false + bpf_debug: false + debug_port: 0 + enable_conntrack: false + sysprobe_socket: '/opt/datadog-agent/run/sysprobe.sock' + EOF + + expect(chef_run).to(render_file('/etc/datadog-agent/system-probe.yaml').with_content { |content| + expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json) + }) + end + end + + context 'with CWS enabled on Windows' do + cached(:solo) do + ChefSpec::SoloRunner.new( + platform: 'windows', + version: '2012R2' + ) do |node| + node.name 'chef-nodename' # expected to be used as the hostname in `datadog.yaml` + node.normal['datadog'] = { + 'api_key' => 'somethingnotnil', + 'agent_major_version' => 6, + 'security_agent' => { + 'cws' => { + 'enabled' => true, + } + } + } + end + end + + cached(:chef_run) do + solo.converge(described_recipe) do + solo.resource_collection.insert( + Chef::Resource::Service.new('datadog-agent', solo.run_context)) + solo.resource_collection.insert( + Chef::Resource::Service.new('datadog-agent-security', solo.run_context)) + end + end + + it 'system-probe.yaml is created' do + expect(chef_run).to create_template('C:/ProgramData/Datadog/system-probe.yaml') + end + + it 'system-probe.yaml contains expected YAML configuration' do + expected_yaml = <<-EOF + runtime_security_config: + enabled: true + system_probe_config: + enabled: false + bpf_debug: false + debug_port: 0 + enable_conntrack: false + sysprobe_socket: 'localhost:3333' + EOF + + expect(chef_run).to(render_file('C:/ProgramData/Datadog/system-probe.yaml').with_content { |content| + expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json) + }) + end + end end diff --git a/tasks/config_specification.rb b/tasks/config_specification.rb index a73dc0ae..fea6c28d 100644 --- a/tasks/config_specification.rb +++ b/tasks/config_specification.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'inflecto' require 'virtus' require 'active_support/core_ext' diff --git a/tasks/config_specification/models.rb b/tasks/config_specification/models.rb index cf636215..2412c843 100644 --- a/tasks/config_specification/models.rb +++ b/tasks/config_specification/models.rb @@ -1,3 +1,16 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. module ConfigSpecification class Specification diff --git a/tasks/config_specification/monitor_serializer.rb b/tasks/config_specification/monitor_serializer.rb index 328d26c1..d3fcb367 100644 --- a/tasks/config_specification/monitor_serializer.rb +++ b/tasks/config_specification/monitor_serializer.rb @@ -1,3 +1,16 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. module ConfigSpecification class MonitorSerializer @@ -7,7 +20,7 @@ def initialize(specification, integration_name) end def serialize - %(include_recipe 'datadog::dd-agent' + %(include_recipe '::dd-agent' # Monitor #{specification.name} # diff --git a/tasks/config_specification/overrider.rb b/tasks/config_specification/overrider.rb index b2b27360..5cecc3f5 100644 --- a/tasks/config_specification/overrider.rb +++ b/tasks/config_specification/overrider.rb @@ -1,3 +1,16 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. module ConfigSpecification # Overriding values using the syntax from specification files diff --git a/tasks/config_specification/parameters_serializer.rb b/tasks/config_specification/parameters_serializer.rb index c8838726..3b521ccf 100644 --- a/tasks/config_specification/parameters_serializer.rb +++ b/tasks/config_specification/parameters_serializer.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + module ConfigSpecification class ParametersSerializer def initialize(specification, integration_name) diff --git a/tasks/config_specification/template_cache.rb b/tasks/config_specification/template_cache.rb index 41c9a150..d3f2beb2 100644 --- a/tasks/config_specification/template_cache.rb +++ b/tasks/config_specification/template_cache.rb @@ -1,3 +1,16 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. module ConfigSpecification # Bookeeping expanded templates diff --git a/tasks/config_specification/yaml_expander.rb b/tasks/config_specification/yaml_expander.rb index 97ff0353..35402133 100644 --- a/tasks/config_specification/yaml_expander.rb +++ b/tasks/config_specification/yaml_expander.rb @@ -1,3 +1,16 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. # rubocop:disable Lint/AssignmentInCondition module ConfigSpecification diff --git a/tasks/create_integration_monitor.rake b/tasks/create_integration_monitor.rake index 06cfba98..57fa6a84 100644 --- a/tasks/create_integration_monitor.rake +++ b/tasks/create_integration_monitor.rake @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'rake' require 'pathname' diff --git a/tasks/release.rake b/tasks/release.rake index 18fb9316..b46aba1b 100644 --- a/tasks/release.rake +++ b/tasks/release.rake @@ -1,9 +1,20 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'rake' require 'chef' require 'chef/cookbook_uploader' -require 'chef/cookbook_site_streaming_uploader' -require 'chef/knife' -require 'chef/knife/supermarket_share' COOKBOOK_PATH = File.join(File.dirname(__FILE__), '..').freeze METADATA_PATH = File.join(COOKBOOK_PATH, 'metadata.rb').freeze @@ -28,6 +39,11 @@ end desc 'Release the cookbook on the Chef supermarket' task :release, :key_path do + # Lazy-load these modules, not available in Chef 17 + require 'chef/cookbook_site_streaming_uploader' + require 'chef/knife' + require 'chef/knife/supermarket_share' + Chef::Knife.new.configure_chef metadata = load_metadata diff --git a/templates/default/custom_log_collection.yaml.erb b/templates/default/custom_log_collection.yaml.erb new file mode 100644 index 00000000..4596766e --- /dev/null +++ b/templates/default/custom_log_collection.yaml.erb @@ -0,0 +1 @@ +<%= JSON.parse(({'logs' => @logs }).to_json).to_yaml -%> diff --git a/templates/default/datadog.yaml.erb b/templates/default/datadog.yaml.erb index b9523163..a8f8bfc2 100644 --- a/templates/default/datadog.yaml.erb +++ b/templates/default/datadog.yaml.erb @@ -89,10 +89,12 @@ agent_config = @extra_config.merge({ histogram_aggregates: string_list_to_array(node['datadog']['histogram_aggregates']), histogram_percentiles: string_list_to_array(node['datadog']['histogram_percentiles']), use_dogstatsd: node['datadog']['dogstatsd'], + dogstatsd_port: node['datadog']['dogstatsd_port'], statsd_metric_namespace: node['datadog']['statsd_metric_namespace'], log_level: node['datadog']['log_level'], cmd_port: node['datadog']['cmd_port'], GUI_port: node['datadog']['gui_port'], + inventories_configuration_enabled: node['datadog']['inventories_configuration_enabled'], # log agent options logs_enabled: node['datadog']['enable_logs_agent'], @@ -180,4 +182,4 @@ agent_config.reject!{ |k,v| v.nil? } -%> # Generated by Chef, local modifications will be overwritten -<%= JSON.parse(agent_config.to_json).to_yaml %> +<%= YAML.dump(JSON.parse(agent_config.to_json)).to_s %> diff --git a/templates/default/gearmand.yaml.erb b/templates/default/gearmand.yaml.erb new file mode 100644 index 00000000..b1a1fa4d --- /dev/null +++ b/templates/default/gearmand.yaml.erb @@ -0,0 +1,62 @@ +<%= JSON.parse(({'logs' => @logs }).to_json).to_yaml -%> + +instances: +<% @instances.each do |i| %> + <% if i['server'] -%> + <% ip = i['server'] %> + <% else %> + <% ip = '127.0.0.1' %> + <% end -%> +- server: <%= ip %> + <% if i['port'] -%> + <% port = i['port'] %> + <% else %> + <% port = '4730' %> + <% end -%> + port: <%= port %> + <% if i['tasks'] %> + tasks: + <% i['tasks'].each do |task| -%> + - <%= task %> + <% end %> + <% end %> + <% if i['tags'] %> + tags: + <% i['tags'].each do |tag| -%> + - <%= tag %> + <% end %> + <% end %> + <% if i['service'] %> + service: <%= i['service'] %> + <% end %> + <% if i['min_collection_interval'] %> + <% seconds = i['min_collection_interval'] %> + <% else %> + <% seconds = 15 %> + <% end %> + min_collection_interval: <%= seconds %> + <% if i['empty_default_hostname'] %> + <% boolean = i['empty_default_hostname'] %> + <% else %> + <% boolean = false %> + <% end %> + empty_default_hostname: <%= boolean %> + <% if i['metric_patterns'] %> + metric_patterns: + <% if i['metric_patterns'].include?('include') %> + include: + <% i['metric_patterns']['include'].each do |regex| %> + - <%= regex %> + <% end %> + <% end %> + <% if i['metric_patterns'].include?('exclude') %> + exclude: + <% i['metric_patterns']['exclude'].each do |regex| %> + - <%= regex %> + <% end %> + <% end %> + <% end %> +<% end -%> + +init_config: +# No init_config details needed diff --git a/templates/default/kafka_consumer.yaml.erb b/templates/default/kafka_consumer.yaml.erb index 68c6d23b..5076e999 100644 --- a/templates/default/kafka_consumer.yaml.erb +++ b/templates/default/kafka_consumer.yaml.erb @@ -3,21 +3,26 @@ instances: <% @instances.each do |i| -%> - kafka_connect_str: <%= i['kafka_connect_str'] %> + <% if i['consumer_groups'] -%> + consumer_groups: <%= i['name'] %> + <% i["consumer_groups"].each do |consumer, t| -%> + <%= consumer %>: + <% t.each do |topic, l| -%> + <%= topic %>: <%= l %> + <% end -%> + <% end -%> + <% end -%> + <% if i.key?('monitor_unlisted_consumer_groups') -%> + monitor_unlisted_consumer_groups: <%= if i['monitor_unlisted_consumer_groups'] == true && !i['consumer_groups']; true; else false; end %> + <% end -%> zk_connect_str: <%= i['zk_connect_str'] %> <% if i['zk_prefix'] -%> zk_prefix: <%= i['zk_prefix'] %> <% end -%> - <% if i['consumer_groups'] -%> - consumer_groups: <%= i['name'] %> - <% i["consumer_groups"].each do |consumer, t| -%> - <%= consumer %>: - <% t.each do |topic, l| -%> - <%= topic %>: <%= l %> - <% end -%> - <% end -%> + <% if i.key?('kafka_consumer_offsets') && i['kafka_consumer_offsets'] == true-%> + kafka_consumer_offsets: true <% end -%> <% end -%> init_config: # The Kafka Consumer check does not require any init_config - diff --git a/templates/default/security-agent.yaml.erb b/templates/default/security-agent.yaml.erb new file mode 100644 index 00000000..dafb4379 --- /dev/null +++ b/templates/default/security-agent.yaml.erb @@ -0,0 +1,13 @@ +<% +## Populate system_probe_config ## +security_agent_config = { + runtime_security_config: { + enabled: @runtime_security_enabled, + }.merge(@runtime_security_extra_config), + compliance_config: { + enabled: @compliance_enabled, + }.merge(@compliance_extra_config), +} +-%> + +<%= JSON.parse(security_agent_config.to_json).to_yaml %> \ No newline at end of file diff --git a/templates/default/solr.yaml.erb b/templates/default/solr.yaml.erb index f4e6cd90..bbb5bebc 100644 --- a/templates/default/solr.yaml.erb +++ b/templates/default/solr.yaml.erb @@ -5,6 +5,8 @@ # List of metrics to be collected by the integration # Read http://docs.datadoghq.com/integrations/java/ to learn how to customize it init_config: + is_jmx: true + collect_default_metrics: true conf: - include: type: searcher diff --git a/templates/default/ssh_check.yaml.erb b/templates/default/ssh_check.yaml.erb index daf37dbc..ceb50d57 100644 --- a/templates/default/ssh_check.yaml.erb +++ b/templates/default/ssh_check.yaml.erb @@ -5,7 +5,7 @@ instances: - host: <%= i['host'] %> username: <%= i['username'] %> <% - keys = %w(password port sftp_check private_key_file add_missing_keys tags) + keys = %w(password port sftp_check private_key_file add_missing_keys min_collection_interval tags) keys.each do |key| if i.key?(key) -%> diff --git a/templates/default/system_probe.yaml.erb b/templates/default/system_probe.yaml.erb index 84545271..50312cb5 100644 --- a/templates/default/system_probe.yaml.erb +++ b/templates/default/system_probe.yaml.erb @@ -7,11 +7,27 @@ system_probe_config = { debug_port: @debug_port, bpf_debug: @bpf_debug, enable_conntrack: @enable_conntrack, - }.merge(@extra_config), - network_config: { - enabled: node['datadog']['system_probe']['network_enabled'], - } + }.merge(@system_probe_extra_config), } + +if @runtime_security_enabled + system_probe_config['runtime_security_config'] = { + enabled: @runtime_security_enabled + }.merge(@runtime_security_extra_config) +end + +# We let the Agent default value take effect if user didn't explicitly +# specify something else than nil for 'network_enabled' +if !node['datadog']['system_probe']['network_enabled'].nil? + system_probe_config['network_config'] = { + 'enabled': node['datadog']['system_probe']['network_enabled'], + } +end +if !node['datadog']['system_probe']['service_monitoring_enabled'].nil? + system_probe_config['service_monitoring_config'] = { + 'enabled': node['datadog']['system_probe']['service_monitoring_enabled'], + } +end -%> # Generated by Chef, local modifications will be overwritten diff --git a/templates/default/systemd.yaml.erb b/templates/default/systemd.yaml.erb index a9b20d2e..4814eab7 100644 --- a/templates/default/systemd.yaml.erb +++ b/templates/default/systemd.yaml.erb @@ -1,4 +1,4 @@ -<%= JSON.parse(({'logs' => @logs }).to_json).to_yaml %> +<%= JSON.parse(({'logs' => @logs }).to_json).to_yaml -%> instances: <% @instances.each do |i| -%> @@ -9,22 +9,14 @@ instances: <% if i.key?('substate_status_mapping') -%> substate_status_mapping: <% i['substate_status_mapping'].each do |s| -%> - <% if s.key?('services') -%> - <% s['services'].each do |k| -%> - <% k.keys.each do |j| -%> - <%= j %>.service: - <% k[j].each do |l,v| %> - <%= l %>: <%= v %> - <% end -%> - <% end -%> - <% end -%> - <% end -%> - <% if s.key?('sockets') -%> - <% s['sockets'].each do |k| -%> - <% k.keys.each do |j| -%> - <%= j %>.socket: - <% k[j].each do |l,v| %> + <% %w(targets services sockets devices mounts automounts swaps paths timers snapshots slices scopes busnames).each do |unit_type| -%> + <% if s.key?(unit_type)-%> + <% s[unit_type].each do |k| -%> + <% k.keys.each do |j| -%> + <%= j %>.<%= unit_type.chomp('s') %>: + <% k[j].each do |l,v| %> <%= l %>: <%= v %> + <% end -%> <% end -%> <% end -%> <% end -%> diff --git a/test/cookbooks/test/recipes/dd_integration_resource.rb b/test/cookbooks/test/recipes/dd_integration_resource.rb index 98c82087..5c5561a0 100644 --- a/test/cookbooks/test/recipes/dd_integration_resource.rb +++ b/test/cookbooks/test/recipes/dd_integration_resource.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + datadog_integration 'datadog-aerospike' do action :remove notifies :restart, 'service[datadog-agent]' diff --git a/test/cookbooks/test/recipes/monitor_add.rb b/test/cookbooks/test/recipes/monitor_add.rb index 03a0a0d3..7f6e3d15 100644 --- a/test/cookbooks/test/recipes/monitor_add.rb +++ b/test/cookbooks/test/recipes/monitor_add.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + datadog_monitor 'potato' do action :add end diff --git a/test/cookbooks/test/recipes/monitor_remove.rb b/test/cookbooks/test/recipes/monitor_remove.rb index 7c99e398..8ad5b8d7 100644 --- a/test/cookbooks/test/recipes/monitor_remove.rb +++ b/test/cookbooks/test/recipes/monitor_remove.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + datadog_monitor 'potato' do action :remove end diff --git a/test/integration/datadog_apache/serverspec_datadog/Gemfile b/test/integration/datadog_apache/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_apache/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_apache/serverspec/apache_spec.rb b/test/integration/datadog_apache/serverspec_datadog/apache_spec.rb similarity index 55% rename from test/integration/datadog_apache/serverspec/apache_spec.rb rename to test/integration/datadog_apache/serverspec_datadog/apache_spec.rb index c2a8d1bf..f989c4e1 100644 --- a/test/integration/datadog_apache/serverspec/apache_spec.rb +++ b/test/integration/datadog_apache/serverspec_datadog/apache_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_cacti/serverspec_datadog/Gemfile b/test/integration/datadog_cacti/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_cacti/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_cacti/serverspec/cacti_spec.rb b/test/integration/datadog_cacti/serverspec_datadog/cacti_spec.rb similarity index 58% rename from test/integration/datadog_cacti/serverspec/cacti_spec.rb rename to test/integration/datadog_cacti/serverspec_datadog/cacti_spec.rb index 249552e2..7b8d2a90 100644 --- a/test/integration/datadog_cacti/serverspec/cacti_spec.rb +++ b/test/integration/datadog_cacti/serverspec_datadog/cacti_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_cassandra/serverspec/Gemfile b/test/integration/datadog_cassandra/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_cassandra/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_cassandra/serverspec_datadog/Gemfile b/test/integration/datadog_cassandra/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_cassandra/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_cassandra/serverspec/cassandra_spec.rb b/test/integration/datadog_cassandra/serverspec_datadog/cassandra_spec.rb similarity index 81% rename from test/integration/datadog_cassandra/serverspec/cassandra_spec.rb rename to test/integration/datadog_cassandra/serverspec_datadog/cassandra_spec.rb index 62e0d319..ffeceb17 100644 --- a/test/integration/datadog_cassandra/serverspec/cassandra_spec.rb +++ b/test/integration/datadog_cassandra/serverspec_datadog/cassandra_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_cassandra_greater_22/serverspec/Gemfile b/test/integration/datadog_cassandra_greater_22/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_cassandra_greater_22/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_cassandra_greater_22/serverspec_datadog/Gemfile b/test/integration/datadog_cassandra_greater_22/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_cassandra_greater_22/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_cassandra_greater_22/serverspec/cassandra_spec.rb b/test/integration/datadog_cassandra_greater_22/serverspec_datadog/cassandra_spec.rb similarity index 86% rename from test/integration/datadog_cassandra_greater_22/serverspec/cassandra_spec.rb rename to test/integration/datadog_cassandra_greater_22/serverspec_datadog/cassandra_spec.rb index 8068a383..a0667756 100644 --- a/test/integration/datadog_cassandra_greater_22/serverspec/cassandra_spec.rb +++ b/test/integration/datadog_cassandra_greater_22/serverspec_datadog/cassandra_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_consul/serverspec/Gemfile b/test/integration/datadog_consul/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_consul/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_consul/serverspec_datadog/Gemfile b/test/integration/datadog_consul/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_consul/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_consul/serverspec/consul_spec.rb b/test/integration/datadog_consul/serverspec_datadog/consul_spec.rb similarity index 59% rename from test/integration/datadog_consul/serverspec/consul_spec.rb rename to test/integration/datadog_consul/serverspec_datadog/consul_spec.rb index aeda852a..c0603fb6 100644 --- a/test/integration/datadog_consul/serverspec/consul_spec.rb +++ b/test/integration/datadog_consul/serverspec_datadog/consul_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_couchdb/serverspec/Gemfile b/test/integration/datadog_couchdb/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_couchdb/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_couchdb/serverspec_datadog/Gemfile b/test/integration/datadog_couchdb/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_couchdb/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_couchdb/serverspec/couchdb_spec.rb b/test/integration/datadog_couchdb/serverspec_datadog/couchdb_spec.rb similarity index 52% rename from test/integration/datadog_couchdb/serverspec/couchdb_spec.rb rename to test/integration/datadog_couchdb/serverspec_datadog/couchdb_spec.rb index c4de184a..a1109c60 100644 --- a/test/integration/datadog_couchdb/serverspec/couchdb_spec.rb +++ b/test/integration/datadog_couchdb/serverspec_datadog/couchdb_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_docker/serverspec/Gemfile b/test/integration/datadog_docker/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_docker/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_docker/serverspec_datadog/Gemfile b/test/integration/datadog_docker/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_docker/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_docker/serverspec/docker_spec.rb b/test/integration/datadog_docker/serverspec_datadog/docker_spec.rb similarity index 64% rename from test/integration/datadog_docker/serverspec/docker_spec.rb rename to test/integration/datadog_docker/serverspec_datadog/docker_spec.rb index 60679951..5594d765 100644 --- a/test/integration/datadog_docker/serverspec/docker_spec.rb +++ b/test/integration/datadog_docker/serverspec_datadog/docker_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_elasticsearch/serverspec/Gemfile b/test/integration/datadog_elasticsearch/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_elasticsearch/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_elasticsearch/serverspec_datadog/Gemfile b/test/integration/datadog_elasticsearch/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_elasticsearch/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_elasticsearch/serverspec/elasticsearch_spec.rb b/test/integration/datadog_elasticsearch/serverspec_datadog/elasticsearch_spec.rb similarity index 58% rename from test/integration/datadog_elasticsearch/serverspec/elasticsearch_spec.rb rename to test/integration/datadog_elasticsearch/serverspec_datadog/elasticsearch_spec.rb index 205e255d..c3a921aa 100644 --- a/test/integration/datadog_elasticsearch/serverspec/elasticsearch_spec.rb +++ b/test/integration/datadog_elasticsearch/serverspec_datadog/elasticsearch_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_etcd/serverspec_datadog/Gemfile b/test/integration/datadog_etcd/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_etcd/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_etcd/serverspec/etcd_spec.rb b/test/integration/datadog_etcd/serverspec_datadog/etcd_spec.rb similarity index 61% rename from test/integration/datadog_etcd/serverspec/etcd_spec.rb rename to test/integration/datadog_etcd/serverspec_datadog/etcd_spec.rb index 25643ad5..7b3aebaf 100644 --- a/test/integration/datadog_etcd/serverspec/etcd_spec.rb +++ b/test/integration/datadog_etcd/serverspec_datadog/etcd_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_fluentd/serverspec/Gemfile b/test/integration/datadog_fluentd/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_fluentd/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_fluentd/serverspec_datadog/Gemfile b/test/integration/datadog_fluentd/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_fluentd/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_fluentd/serverspec/fluentd_spec.rb b/test/integration/datadog_fluentd/serverspec_datadog/fluentd_spec.rb similarity index 54% rename from test/integration/datadog_fluentd/serverspec/fluentd_spec.rb rename to test/integration/datadog_fluentd/serverspec_datadog/fluentd_spec.rb index 26bdbec7..214c7a43 100644 --- a/test/integration/datadog_fluentd/serverspec/fluentd_spec.rb +++ b/test/integration/datadog_fluentd/serverspec_datadog/fluentd_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_gearmand/serverspec_datadog/gearmand_spec.rb b/test/integration/datadog_gearmand/serverspec_datadog/gearmand_spec.rb new file mode 100644 index 00000000..0de3a189 --- /dev/null +++ b/test/integration/datadog_gearmand/serverspec_datadog/gearmand_spec.rb @@ -0,0 +1,65 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Encoding: utf-8 + +require 'spec_helper' + +AGENT_CONFIG = File.join(@agent_config_dir, 'conf.d/gearmand.d/conf.yaml') + +describe service(@agent_service_name) do + it { should be_running } +end + +describe file(AGENT_CONFIG) do + it { should be_a_file } + + it 'is valid yaml matching input values' do + generated = YAML.load_file(AGENT_CONFIG) + + expected = { + 'instances' => [ + { + 'server' => '127.0.0.1', + 'port' => '4730', + 'tasks' => [ + 'TASK_1', + 'TASK_2', + ], + 'tags' => [ + ':', + ':' + ], + 'service' => '', + # Defaults to 15 if not set + 'min_collection_interval' => 60, + # Defaults to false if not set + 'empty_default_hostname' => true, + 'metric_patterns' => { + 'include' => [ + '' + ], + 'exclude' => [ + '' + ] + } + } + ], + 'logs' => nil, + 'init_config' => nil + } + + expect(generated.to_json).to be_json_eql expected.to_json + end +end diff --git a/test/integration/datadog_haproxy/serverspec/Gemfile b/test/integration/datadog_haproxy/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_haproxy/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_haproxy/serverspec_datadog/Gemfile b/test/integration/datadog_haproxy/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_haproxy/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_haproxy/serverspec/haproxy_spec.rb b/test/integration/datadog_haproxy/serverspec_datadog/haproxy_spec.rb similarity index 57% rename from test/integration/datadog_haproxy/serverspec/haproxy_spec.rb rename to test/integration/datadog_haproxy/serverspec_datadog/haproxy_spec.rb index 18431f43..a4bbb4b7 100644 --- a/test/integration/datadog_haproxy/serverspec/haproxy_spec.rb +++ b/test/integration/datadog_haproxy/serverspec_datadog/haproxy_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_http_check/serverspec/Gemfile b/test/integration/datadog_http_check/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_http_check/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_apache/serverspec/Gemfile b/test/integration/datadog_http_check/serverspec_datadog/Gemfile similarity index 100% rename from test/integration/datadog_apache/serverspec/Gemfile rename to test/integration/datadog_http_check/serverspec_datadog/Gemfile diff --git a/test/integration/datadog_http_check/serverspec/http_check_spec.rb b/test/integration/datadog_http_check/serverspec_datadog/http_check_spec.rb similarity index 54% rename from test/integration/datadog_http_check/serverspec/http_check_spec.rb rename to test/integration/datadog_http_check/serverspec_datadog/http_check_spec.rb index 6d984ed3..42ee0a22 100644 --- a/test/integration/datadog_http_check/serverspec/http_check_spec.rb +++ b/test/integration/datadog_http_check/serverspec_datadog/http_check_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_integrations/serverspec/Gemfile b/test/integration/datadog_integrations/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_integrations/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_integrations/serverspec_datadog/Gemfile b/test/integration/datadog_integrations/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_integrations/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_integrations/serverspec/integrations_spec.rb b/test/integration/datadog_integrations/serverspec_datadog/integrations_spec.rb similarity index 53% rename from test/integration/datadog_integrations/serverspec/integrations_spec.rb rename to test/integration/datadog_integrations/serverspec_datadog/integrations_spec.rb index f7712c46..3fedc21a 100644 --- a/test/integration/datadog_integrations/serverspec/integrations_spec.rb +++ b/test/integration/datadog_integrations/serverspec_datadog/integrations_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_jmx/serverspec/Gemfile b/test/integration/datadog_jmx/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_jmx/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_jmx/serverspec_datadog/Gemfile b/test/integration/datadog_jmx/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_jmx/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_jmx/serverspec/dd-agent-jmx_spec.rb b/test/integration/datadog_jmx/serverspec_datadog/dd-agent-jmx_spec.rb similarity index 72% rename from test/integration/datadog_jmx/serverspec/dd-agent-jmx_spec.rb rename to test/integration/datadog_jmx/serverspec_datadog/dd-agent-jmx_spec.rb index 70ed7f28..5956725c 100644 --- a/test/integration/datadog_jmx/serverspec/dd-agent-jmx_spec.rb +++ b/test/integration/datadog_jmx/serverspec_datadog/dd-agent-jmx_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_kafka-consumer/bats/kafka_consumer_config.bats b/test/integration/datadog_kafka-consumer/bats/kafka_consumer_config.bats deleted file mode 100644 index d66b978b..00000000 --- a/test/integration/datadog_kafka-consumer/bats/kafka_consumer_config.bats +++ /dev/null @@ -1,19 +0,0 @@ -@test "kafka.yaml exists" { - [ -f /etc/datadog-agent/conf.d/kafka_consumer.yaml ] -} - -@test "kafka.yaml is correct" { - export PYTHONPATH=/usr/share/datadog/agent/ - script='import yaml, json, sys; print json.dumps(yaml.load(sys.stdin.read()))' - actual=$(cat /etc/datadog-agent/conf.d/kafka_consumer.yaml | python -c "$script") - - expected='{"instances": [{"zk_connect_str": "localhost:2181", "kafka_connect_str": "localhost:19092", "consumer_groups": {"my_consumer": {"my_topic": [0, 1, 4, 12]}}, "zk_prefix": "/0.8"}], "init_config": null}' - - echo "Expected: $expected" - echo "Actual: $actual" - [ "x$actual" == "x$expected" ] -} - - - - diff --git a/test/integration/datadog_kafka/serverspec/Gemfile b/test/integration/datadog_kafka/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_kafka/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_kafka/serverspec_datadog/Gemfile b/test/integration/datadog_kafka/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_kafka/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_kafka/serverspec/kafka_spec.rb b/test/integration/datadog_kafka/serverspec_datadog/kafka_spec.rb similarity index 92% rename from test/integration/datadog_kafka/serverspec/kafka_spec.rb rename to test/integration/datadog_kafka/serverspec_datadog/kafka_spec.rb index 457da27f..16b10026 100644 --- a/test/integration/datadog_kafka/serverspec/kafka_spec.rb +++ b/test/integration/datadog_kafka/serverspec_datadog/kafka_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_kafka_consumer/serverspec_datadog/kafka_consumer_spec.rb b/test/integration/datadog_kafka_consumer/serverspec_datadog/kafka_consumer_spec.rb new file mode 100644 index 00000000..753f06c8 --- /dev/null +++ b/test/integration/datadog_kafka_consumer/serverspec_datadog/kafka_consumer_spec.rb @@ -0,0 +1,51 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Encoding: utf-8 +require 'spec_helper' + +AGENT_CONFIG = File.join(@agent_config_dir, 'conf.d/kafka_consumer.d/conf.yaml') + +describe service(@agent_service_name) do + it { should be_running } +end + +describe file(AGENT_CONFIG) do + it { should be_a_file } + + it 'is valid yaml matching input values' do + generated = YAML.load_file(AGENT_CONFIG) + + expected = { + 'instances' => [ + { + :kafka_connect_str => 'localhost:19092', + :consumer_groups => { + :my_consumer => { + :my_topic => [0, 1, 4, 12] + } + }, + :monitor_unlisted_consumer_groups => false, + :zk_connect_str => 'localhost:2181', + :zk_prefix => '/0.8', + :kafka_consumer_offsets => true + } + ], + 'logs' => nil, + 'init_config' => nil + } + + expect(generated.to_json).to be_json_eql expected.to_json + end +end diff --git a/test/integration/datadog_mesos_master/serverspec/Gemfile b/test/integration/datadog_mesos_master/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_mesos_master/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_mesos_master/serverspec_datadog/Gemfile b/test/integration/datadog_mesos_master/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_mesos_master/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_mesos_master/serverspec/mesos_spec.rb b/test/integration/datadog_mesos_master/serverspec_datadog/mesos_spec.rb similarity index 52% rename from test/integration/datadog_mesos_master/serverspec/mesos_spec.rb rename to test/integration/datadog_mesos_master/serverspec_datadog/mesos_spec.rb index ddb2986d..d6d8f671 100644 --- a/test/integration/datadog_mesos_master/serverspec/mesos_spec.rb +++ b/test/integration/datadog_mesos_master/serverspec_datadog/mesos_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_mesos_slave/serverspec/Gemfile b/test/integration/datadog_mesos_slave/serverspec/Gemfile deleted file mode 100644 index 96cef5d3..00000000 --- a/test/integration/datadog_mesos_slave/serverspec/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source 'https://rubygems.org' - -gem 'json_spec', '~> 1.1.0' diff --git a/test/integration/datadog_mesos_slave/serverspec_datadog/Gemfile b/test/integration/datadog_mesos_slave/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_mesos_slave/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_mesos_slave/serverspec/mesos_spec.rb b/test/integration/datadog_mesos_slave/serverspec_datadog/mesos_spec.rb similarity index 52% rename from test/integration/datadog_mesos_slave/serverspec/mesos_spec.rb rename to test/integration/datadog_mesos_slave/serverspec_datadog/mesos_spec.rb index b0ac64d2..72ed6395 100644 --- a/test/integration/datadog_mesos_slave/serverspec/mesos_spec.rb +++ b/test/integration/datadog_mesos_slave/serverspec_datadog/mesos_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_mongo/serverspec/mongo_spec.rb b/test/integration/datadog_mongo/serverspec_datadog/mongo_spec.rb similarity index 53% rename from test/integration/datadog_mongo/serverspec/mongo_spec.rb rename to test/integration/datadog_mongo/serverspec_datadog/mongo_spec.rb index a30c4874..bf0bf29b 100644 --- a/test/integration/datadog_mongo/serverspec/mongo_spec.rb +++ b/test/integration/datadog_mongo/serverspec_datadog/mongo_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_mysql/serverspec/Gemfile b/test/integration/datadog_mysql/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_mysql/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_mysql/serverspec_datadog/Gemfile b/test/integration/datadog_mysql/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_mysql/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_mysql/serverspec/mysql_spec.rb b/test/integration/datadog_mysql/serverspec_datadog/mysql_spec.rb similarity index 71% rename from test/integration/datadog_mysql/serverspec/mysql_spec.rb rename to test/integration/datadog_mysql/serverspec_datadog/mysql_spec.rb index ec9b77a1..2e422c81 100644 --- a/test/integration/datadog_mysql/serverspec/mysql_spec.rb +++ b/test/integration/datadog_mysql/serverspec_datadog/mysql_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_ntp/serverspec/Gemfile b/test/integration/datadog_ntp/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_ntp/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_ntp/serverspec_datadog/Gemfile b/test/integration/datadog_ntp/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_ntp/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_ntp/serverspec/ntp_spec.rb b/test/integration/datadog_ntp/serverspec_datadog/ntp_spec.rb similarity index 54% rename from test/integration/datadog_ntp/serverspec/ntp_spec.rb rename to test/integration/datadog_ntp/serverspec_datadog/ntp_spec.rb index 2c103231..8cf4e846 100644 --- a/test/integration/datadog_ntp/serverspec/ntp_spec.rb +++ b/test/integration/datadog_ntp/serverspec_datadog/ntp_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_pgbouncer/serverspec/Gemfile b/test/integration/datadog_pgbouncer/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_pgbouncer/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_pgbouncer/serverspec_datadog/Gemfile b/test/integration/datadog_pgbouncer/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_pgbouncer/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_pgbouncer/serverspec/pgbouncer_spec.rb b/test/integration/datadog_pgbouncer/serverspec_datadog/pgbouncer_spec.rb similarity index 57% rename from test/integration/datadog_pgbouncer/serverspec/pgbouncer_spec.rb rename to test/integration/datadog_pgbouncer/serverspec_datadog/pgbouncer_spec.rb index e2f5e5a7..9b66e062 100644 --- a/test/integration/datadog_pgbouncer/serverspec/pgbouncer_spec.rb +++ b/test/integration/datadog_pgbouncer/serverspec_datadog/pgbouncer_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_postfix/serverspec/Gemfile b/test/integration/datadog_postfix/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_postfix/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_postfix/serverspec_datadog/Gemfile b/test/integration/datadog_postfix/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_postfix/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_postfix/serverspec/postfix_spec.rb b/test/integration/datadog_postfix/serverspec_datadog/postfix_spec.rb similarity index 61% rename from test/integration/datadog_postfix/serverspec/postfix_spec.rb rename to test/integration/datadog_postfix/serverspec_datadog/postfix_spec.rb index a826a209..8ba9b529 100644 --- a/test/integration/datadog_postfix/serverspec/postfix_spec.rb +++ b/test/integration/datadog_postfix/serverspec_datadog/postfix_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_process/serverspec/Gemfile b/test/integration/datadog_process/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_process/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_process/serverspec_datadog/Gemfile b/test/integration/datadog_process/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_process/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_process/serverspec/dd-agent-process_spec.rb b/test/integration/datadog_process/serverspec_datadog/dd-agent-process_spec.rb similarity index 56% rename from test/integration/datadog_process/serverspec/dd-agent-process_spec.rb rename to test/integration/datadog_process/serverspec_datadog/dd-agent-process_spec.rb index d50ba3f3..e796e38d 100644 --- a/test/integration/datadog_process/serverspec/dd-agent-process_spec.rb +++ b/test/integration/datadog_process/serverspec_datadog/dd-agent-process_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_rabbitmq/serverspec/rabbitmq_spec.rb b/test/integration/datadog_rabbitmq/serverspec_datadog/rabbitmq_spec.rb similarity index 66% rename from test/integration/datadog_rabbitmq/serverspec/rabbitmq_spec.rb rename to test/integration/datadog_rabbitmq/serverspec_datadog/rabbitmq_spec.rb index ad9272d6..e050061e 100644 --- a/test/integration/datadog_rabbitmq/serverspec/rabbitmq_spec.rb +++ b/test/integration/datadog_rabbitmq/serverspec_datadog/rabbitmq_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_ssh_check/serverspec/Gemfile b/test/integration/datadog_ssh_check/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_ssh_check/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_ssh_check/serverspec_datadog/Gemfile b/test/integration/datadog_ssh_check/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_ssh_check/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_ssh_check/serverspec/ssh_check_spec.rb b/test/integration/datadog_ssh_check/serverspec_datadog/ssh_check_spec.rb similarity index 57% rename from test/integration/datadog_ssh_check/serverspec/ssh_check_spec.rb rename to test/integration/datadog_ssh_check/serverspec_datadog/ssh_check_spec.rb index f8c47a16..64f8b757 100644 --- a/test/integration/datadog_ssh_check/serverspec/ssh_check_spec.rb +++ b/test/integration/datadog_ssh_check/serverspec_datadog/ssh_check_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' @@ -27,7 +41,8 @@ 'username' => 'root', 'password' => 'password', 'add_missing_keys' => false, - 'tags' => ['tag1', 'tag2'] + 'tags' => ['tag1', 'tag2'], + 'min_collection_interval' => 300 }, { 'host' => 'sftp_server.example.com', @@ -35,7 +50,8 @@ 'port' => 2323, 'sftp_check' => true, 'private_key_file' => '/path/to/key', - 'tags' => ['tag1', 'tag3'] + 'tags' => ['tag1', 'tag3'], + 'min_collection_interval' => 300 } ], 'logs' => nil, diff --git a/test/integration/datadog_supervisord/serverspec/Gemfile b/test/integration/datadog_supervisord/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_supervisord/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_supervisord/serverspec_datadog/Gemfile b/test/integration/datadog_supervisord/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_supervisord/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_supervisord/serverspec/supervisord_spec.rb b/test/integration/datadog_supervisord/serverspec_datadog/supervisord_spec.rb similarity index 62% rename from test/integration/datadog_supervisord/serverspec/supervisord_spec.rb rename to test/integration/datadog_supervisord/serverspec_datadog/supervisord_spec.rb index bcf9420a..6d52a3d0 100644 --- a/test/integration/datadog_supervisord/serverspec/supervisord_spec.rb +++ b/test/integration/datadog_supervisord/serverspec_datadog/supervisord_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_systemd/serverspec/systemd_spec.rb b/test/integration/datadog_systemd/serverspec_datadog/systemd_spec.rb similarity index 50% rename from test/integration/datadog_systemd/serverspec/systemd_spec.rb rename to test/integration/datadog_systemd/serverspec_datadog/systemd_spec.rb index 12a60474..101fe6aa 100644 --- a/test/integration/datadog_systemd/serverspec/systemd_spec.rb +++ b/test/integration/datadog_systemd/serverspec_datadog/systemd_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' @@ -20,7 +34,8 @@ 'unit_names' => [ 'myservice1.service', 'myservice2.service', - 'mysocket.socket' + 'mysocket.socket', + 'mytimer.timer' ] } ], diff --git a/test/integration/datadog_tcp_check/serverspec/Gemfile b/test/integration/datadog_tcp_check/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_tcp_check/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_tcp_check/serverspec_datadog/Gemfile b/test/integration/datadog_tcp_check/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/datadog_tcp_check/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_tcp_check/serverspec/tcp_check_spec.rb b/test/integration/datadog_tcp_check/serverspec_datadog/tcp_check_spec.rb similarity index 55% rename from test/integration/datadog_tcp_check/serverspec/tcp_check_spec.rb rename to test/integration/datadog_tcp_check/serverspec_datadog/tcp_check_spec.rb index 8ce6ad5f..148929af 100644 --- a/test/integration/datadog_tcp_check/serverspec/tcp_check_spec.rb +++ b/test/integration/datadog_tcp_check/serverspec_datadog/tcp_check_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/datadog_vault/serverspec/Gemfile b/test/integration/datadog_vault/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/datadog_vault/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/datadog_cacti/serverspec/Gemfile b/test/integration/datadog_vault/serverspec_datadog/Gemfile similarity index 100% rename from test/integration/datadog_cacti/serverspec/Gemfile rename to test/integration/datadog_vault/serverspec_datadog/Gemfile diff --git a/test/integration/datadog_vault/serverspec/vault_spec.rb b/test/integration/datadog_vault/serverspec_datadog/vault_spec.rb similarity index 59% rename from test/integration/datadog_vault/serverspec/vault_spec.rb rename to test/integration/datadog_vault/serverspec_datadog/vault_spec.rb index 0a4d7cb6..fde4f4b2 100644 --- a/test/integration/datadog_vault/serverspec/vault_spec.rb +++ b/test/integration/datadog_vault/serverspec_datadog/vault_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Encoding: utf-8 require 'spec_helper' diff --git a/test/integration/dd-agent-handler/serverspec/dd-agent_spec.rb b/test/integration/dd-agent-handler/serverspec/dd-agent_spec.rb deleted file mode 120000 index ef9035c2..00000000 --- a/test/integration/dd-agent-handler/serverspec/dd-agent_spec.rb +++ /dev/null @@ -1 +0,0 @@ -../../dd-agent/serverspec/dd-agent_spec.rb \ No newline at end of file diff --git a/test/integration/dd-agent-handler/serverspec/dd-handler_spec.rb b/test/integration/dd-agent-handler/serverspec/dd-handler_spec.rb deleted file mode 120000 index 631ae922..00000000 --- a/test/integration/dd-agent-handler/serverspec/dd-handler_spec.rb +++ /dev/null @@ -1 +0,0 @@ -../../dd-handler/serverspec/dd-handler_spec.rb \ No newline at end of file diff --git a/test/integration/dd-agent-handler/serverspec_datadog/dd-agent_spec.rb b/test/integration/dd-agent-handler/serverspec_datadog/dd-agent_spec.rb new file mode 120000 index 00000000..fdb24a50 --- /dev/null +++ b/test/integration/dd-agent-handler/serverspec_datadog/dd-agent_spec.rb @@ -0,0 +1 @@ +../../dd-agent/serverspec_datadog/dd-agent_spec.rb \ No newline at end of file diff --git a/test/integration/dd-agent-handler/serverspec_datadog/dd-handler_spec.rb b/test/integration/dd-agent-handler/serverspec_datadog/dd-handler_spec.rb new file mode 120000 index 00000000..0d5997d7 --- /dev/null +++ b/test/integration/dd-agent-handler/serverspec_datadog/dd-handler_spec.rb @@ -0,0 +1 @@ +../../dd-agent/serverspec_datadog/dd-handler_spec.rb \ No newline at end of file diff --git a/test/integration/dd-agent-handler5/serverspec/dd-agent_spec.rb b/test/integration/dd-agent-handler5/serverspec/dd-agent_spec.rb deleted file mode 100644 index 93518705..00000000 --- a/test/integration/dd-agent-handler5/serverspec/dd-agent_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'spec_helper' - -describe package(@agent_package_name) do - it { should be_installed } -end - -describe service(@agent_service_name) do - it { should be_running } -end - -describe command('/etc/init.d/datadog-agent info | grep -v "API Key is invalid"'), :if => os[:family] != 'windows' do - its(:exit_status) { should eq 0 } - its(:stdout) { should contain 'OK' } - its(:stdout) { should_not contain 'ERROR' } -end - -# The new APT keys are imported -describe command('apt-key list'), :if => ['debian', 'ubuntu'].include?(os[:family]) do - its(:exit_status) { should eq 0 } - its(:stdout) { should contain '382E94DE' } - its(:stdout) { should contain 'F14F620E' } -end - -# The new RPM keys are imported -describe command('rpm -q gpg-pubkey-e09422b3'), :if => os[:family] == 'redhat' do - its(:exit_status) { should eq 0 } - its(:stdout) { should contain 'gpg-pubkey-e09422b3' } -end - -describe command('rpm -q gpg-pubkey-fd4bf915'), :if => os[:family] == 'redhat' do - its(:exit_status) { should eq 0 } - its(:stdout) { should contain 'gpg-pubkey-fd4bf915' } -end diff --git a/test/integration/dd-agent-handler5/serverspec/dd-handler_spec.rb b/test/integration/dd-agent-handler5/serverspec/dd-handler_spec.rb deleted file mode 100644 index 5c2e34ea..00000000 --- a/test/integration/dd-agent-handler5/serverspec/dd-handler_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'spec_helper' - -# the be_installed.by('gem') check is not implemented for Windows as of v2.24 of Serverspec -describe package('chef-handler-datadog'), :if => os[:family] != 'windows' do - it { should be_installed.by('gem') } -end diff --git a/test/integration/dd-agent-handler5/serverspec_datadog/Gemfile b/test/integration/dd-agent-handler5/serverspec_datadog/Gemfile new file mode 100644 index 00000000..2e440b8a --- /dev/null +++ b/test/integration/dd-agent-handler5/serverspec_datadog/Gemfile @@ -0,0 +1,14 @@ +source 'https://rubygems.org' + +chef_version = ENV.fetch('CHEF_VERSION', '14.10.9') + +if RUBY_VERSION < '2.6' + gem 'net-ssh', '~> 6.1.0' + gem 'public_suffix', '~> 4.0.0' +end + +gem 'json_spec', '~> 1.1.0' + +if Gem::Version.new(chef_version) > Gem::Version.new('16.0.0') && RUBY_VERSION < '2.7' + gem 'train-core', '~> 3.9.0' +end diff --git a/test/integration/dd-agent-handler5/serverspec_datadog/dd-agent_spec.rb b/test/integration/dd-agent-handler5/serverspec_datadog/dd-agent_spec.rb new file mode 100644 index 00000000..92d19c86 --- /dev/null +++ b/test/integration/dd-agent-handler5/serverspec_datadog/dd-agent_spec.rb @@ -0,0 +1,61 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe package(@agent_package_name) do + it { should be_installed } +end + +describe service(@agent_service_name) do + it { should be_running } +end + +# On Linux kernel >= 5.5, Agent 5 disk check fails because of old psutil version, which doesn't have fix +# https://github.com/giampaolo/psutil/commit/2e0952e939d6ab517449314876d8d3488ba5b98b +describe command('/etc/init.d/datadog-agent info | grep -v "API Key is invalid" | grep -v "not sure how to interpret line"'), :if => os[:family] != 'windows' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'OK' } + its(:stdout) { should_not contain 'ERROR' } +end + +# The new APT keys are imported +describe command('apt-key list'), :if => ['debian', 'ubuntu'].include?(os[:family]) do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain '06462314' } + its(:stdout) { should contain 'C0962C7D' } + its(:stdout) { should contain 'F14F620E' } + its(:stdout) { should contain '382E94DE' } +end + +# The new RPM keys are imported +describe command('rpm -q gpg-pubkey-4f09d16b'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-4f09d16b' } +end + +describe command('rpm -q gpg-pubkey-b01082d3'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-b01082d3' } +end + +describe command('rpm -q gpg-pubkey-fd4bf915'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-fd4bf915' } +end + +describe command('rpm -q gpg-pubkey-e09422b3'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-e09422b3' } +end diff --git a/test/integration/dd-agent-handler5/serverspec_datadog/dd-handler_spec.rb b/test/integration/dd-agent-handler5/serverspec_datadog/dd-handler_spec.rb new file mode 100644 index 00000000..9ccbaf12 --- /dev/null +++ b/test/integration/dd-agent-handler5/serverspec_datadog/dd-handler_spec.rb @@ -0,0 +1,20 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +# the be_installed.by('gem') check is not implemented for Windows as of v2.24 of Serverspec +describe package('chef-handler-datadog'), :if => os[:family] != 'windows' do + it { should be_installed.by('gem') } +end diff --git a/test/integration/dd-agent-handler6/serverspec/dd-handler_spec.rb b/test/integration/dd-agent-handler6/serverspec/dd-handler_spec.rb deleted file mode 100644 index 5c2e34ea..00000000 --- a/test/integration/dd-agent-handler6/serverspec/dd-handler_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'spec_helper' - -# the be_installed.by('gem') check is not implemented for Windows as of v2.24 of Serverspec -describe package('chef-handler-datadog'), :if => os[:family] != 'windows' do - it { should be_installed.by('gem') } -end diff --git a/test/integration/dd-agent-handler6/serverspec_datadog/Gemfile b/test/integration/dd-agent-handler6/serverspec_datadog/Gemfile new file mode 100644 index 00000000..2e440b8a --- /dev/null +++ b/test/integration/dd-agent-handler6/serverspec_datadog/Gemfile @@ -0,0 +1,14 @@ +source 'https://rubygems.org' + +chef_version = ENV.fetch('CHEF_VERSION', '14.10.9') + +if RUBY_VERSION < '2.6' + gem 'net-ssh', '~> 6.1.0' + gem 'public_suffix', '~> 4.0.0' +end + +gem 'json_spec', '~> 1.1.0' + +if Gem::Version.new(chef_version) > Gem::Version.new('16.0.0') && RUBY_VERSION < '2.7' + gem 'train-core', '~> 3.9.0' +end diff --git a/test/integration/dd-agent-handler7/serverspec/dd-agent_spec.rb b/test/integration/dd-agent-handler6/serverspec_datadog/dd-agent_spec.rb similarity index 50% rename from test/integration/dd-agent-handler7/serverspec/dd-agent_spec.rb rename to test/integration/dd-agent-handler6/serverspec_datadog/dd-agent_spec.rb index dbaf20f5..93576365 100644 --- a/test/integration/dd-agent-handler7/serverspec/dd-agent_spec.rb +++ b/test/integration/dd-agent-handler6/serverspec_datadog/dd-agent_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'spec_helper' describe package(@agent_package_name) do @@ -17,17 +31,29 @@ # The new APT keys are imported describe command('apt-key list'), :if => ['debian', 'ubuntu'].include?(os[:family]) do its(:exit_status) { should eq 0 } - its(:stdout) { should contain '382E94DE' } + its(:stdout) { should contain '06462314' } + its(:stdout) { should contain 'C0962C7D' } its(:stdout) { should contain 'F14F620E' } + its(:stdout) { should contain '382E94DE' } end # The new RPM keys are imported -describe command('rpm -q gpg-pubkey-e09422b3'), :if => os[:family] == 'redhat' do +describe command('rpm -q gpg-pubkey-4f09d16b'), :if => os[:family] == 'redhat' do its(:exit_status) { should eq 0 } - its(:stdout) { should contain 'gpg-pubkey-e09422b3' } + its(:stdout) { should contain 'gpg-pubkey-4f09d16b' } +end + +describe command('rpm -q gpg-pubkey-b01082d3'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-b01082d3' } end describe command('rpm -q gpg-pubkey-fd4bf915'), :if => os[:family] == 'redhat' do its(:exit_status) { should eq 0 } its(:stdout) { should contain 'gpg-pubkey-fd4bf915' } end + +describe command('rpm -q gpg-pubkey-e09422b3'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-e09422b3' } +end diff --git a/test/integration/dd-agent-handler6/serverspec_datadog/dd-handler_spec.rb b/test/integration/dd-agent-handler6/serverspec_datadog/dd-handler_spec.rb new file mode 100644 index 00000000..9ccbaf12 --- /dev/null +++ b/test/integration/dd-agent-handler6/serverspec_datadog/dd-handler_spec.rb @@ -0,0 +1,20 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +# the be_installed.by('gem') check is not implemented for Windows as of v2.24 of Serverspec +describe package('chef-handler-datadog'), :if => os[:family] != 'windows' do + it { should be_installed.by('gem') } +end diff --git a/test/integration/dd-agent-handler7/serverspec/dd-handler_spec.rb b/test/integration/dd-agent-handler7/serverspec/dd-handler_spec.rb deleted file mode 100644 index 5c2e34ea..00000000 --- a/test/integration/dd-agent-handler7/serverspec/dd-handler_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'spec_helper' - -# the be_installed.by('gem') check is not implemented for Windows as of v2.24 of Serverspec -describe package('chef-handler-datadog'), :if => os[:family] != 'windows' do - it { should be_installed.by('gem') } -end diff --git a/test/integration/dd-agent-handler7/serverspec_datadog/Gemfile b/test/integration/dd-agent-handler7/serverspec_datadog/Gemfile new file mode 100644 index 00000000..2e440b8a --- /dev/null +++ b/test/integration/dd-agent-handler7/serverspec_datadog/Gemfile @@ -0,0 +1,14 @@ +source 'https://rubygems.org' + +chef_version = ENV.fetch('CHEF_VERSION', '14.10.9') + +if RUBY_VERSION < '2.6' + gem 'net-ssh', '~> 6.1.0' + gem 'public_suffix', '~> 4.0.0' +end + +gem 'json_spec', '~> 1.1.0' + +if Gem::Version.new(chef_version) > Gem::Version.new('16.0.0') && RUBY_VERSION < '2.7' + gem 'train-core', '~> 3.9.0' +end diff --git a/test/integration/dd-agent/serverspec/dd-agent_spec.rb b/test/integration/dd-agent-handler7/serverspec_datadog/dd-agent_spec.rb similarity index 50% rename from test/integration/dd-agent/serverspec/dd-agent_spec.rb rename to test/integration/dd-agent-handler7/serverspec_datadog/dd-agent_spec.rb index dbaf20f5..93576365 100644 --- a/test/integration/dd-agent/serverspec/dd-agent_spec.rb +++ b/test/integration/dd-agent-handler7/serverspec_datadog/dd-agent_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'spec_helper' describe package(@agent_package_name) do @@ -17,17 +31,29 @@ # The new APT keys are imported describe command('apt-key list'), :if => ['debian', 'ubuntu'].include?(os[:family]) do its(:exit_status) { should eq 0 } - its(:stdout) { should contain '382E94DE' } + its(:stdout) { should contain '06462314' } + its(:stdout) { should contain 'C0962C7D' } its(:stdout) { should contain 'F14F620E' } + its(:stdout) { should contain '382E94DE' } end # The new RPM keys are imported -describe command('rpm -q gpg-pubkey-e09422b3'), :if => os[:family] == 'redhat' do +describe command('rpm -q gpg-pubkey-4f09d16b'), :if => os[:family] == 'redhat' do its(:exit_status) { should eq 0 } - its(:stdout) { should contain 'gpg-pubkey-e09422b3' } + its(:stdout) { should contain 'gpg-pubkey-4f09d16b' } +end + +describe command('rpm -q gpg-pubkey-b01082d3'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-b01082d3' } end describe command('rpm -q gpg-pubkey-fd4bf915'), :if => os[:family] == 'redhat' do its(:exit_status) { should eq 0 } its(:stdout) { should contain 'gpg-pubkey-fd4bf915' } end + +describe command('rpm -q gpg-pubkey-e09422b3'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-e09422b3' } +end diff --git a/test/integration/dd-agent-handler7/serverspec_datadog/dd-handler_spec.rb b/test/integration/dd-agent-handler7/serverspec_datadog/dd-handler_spec.rb new file mode 100644 index 00000000..9ccbaf12 --- /dev/null +++ b/test/integration/dd-agent-handler7/serverspec_datadog/dd-handler_spec.rb @@ -0,0 +1,20 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +# the be_installed.by('gem') check is not implemented for Windows as of v2.24 of Serverspec +describe package('chef-handler-datadog'), :if => os[:family] != 'windows' do + it { should be_installed.by('gem') } +end diff --git a/test/integration/dd-agent-iot/serverspec/install_info_spec.rb b/test/integration/dd-agent-iot/serverspec/install_info_spec.rb deleted file mode 100644 index 5b8bb9c9..00000000 --- a/test/integration/dd-agent-iot/serverspec/install_info_spec.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'spec_helper' - -@agent_package_name = 'datadog-iot-agent' - -describe 'Install infos' do - let(:install_info_path) do - if os == :windows - "#{ENV['ProgramData']}\\Datadog\\install_info" - else - '/etc/datadog-agent/install_info' - end - end - - let(:install_info) do - YAML.load_file(install_info_path) - end - - it 'adds an install_info' do - expect(install_info['install_method']).to match( - 'tool_version' => /chef-\d+\.\d+\.\d+/, - 'tool' => 'chef', - 'installer_version' => /^datadog_cookbook-\d+\.\d+\.\d+$/ - ) - end -end diff --git a/test/integration/dd-agent-iot/serverspec/dd-agent_spec.rb b/test/integration/dd-agent-iot/serverspec_datadog/dd-agent_spec.rb similarity index 51% rename from test/integration/dd-agent-iot/serverspec/dd-agent_spec.rb rename to test/integration/dd-agent-iot/serverspec_datadog/dd-agent_spec.rb index 4fd56b13..6b1c9937 100644 --- a/test/integration/dd-agent-iot/serverspec/dd-agent_spec.rb +++ b/test/integration/dd-agent-iot/serverspec_datadog/dd-agent_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'spec_helper' @agent_package_name = 'datadog-iot-agent' @@ -19,17 +33,29 @@ # The new APT keys are imported describe command('apt-key list'), :if => ['debian', 'ubuntu'].include?(os[:family]) do its(:exit_status) { should eq 0 } - its(:stdout) { should contain '382E94DE' } + its(:stdout) { should contain '06462314' } + its(:stdout) { should contain 'C0962C7D' } its(:stdout) { should contain 'F14F620E' } + its(:stdout) { should contain '382E94DE' } end # The new RPM keys are imported -describe command('rpm -q gpg-pubkey-e09422b3'), :if => os[:family] == 'redhat' do +describe command('rpm -q gpg-pubkey-4f09d16b'), :if => os[:family] == 'redhat' do its(:exit_status) { should eq 0 } - its(:stdout) { should contain 'gpg-pubkey-e09422b3' } + its(:stdout) { should contain 'gpg-pubkey-4f09d16b' } +end + +describe command('rpm -q gpg-pubkey-b01082d3'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-b01082d3' } end describe command('rpm -q gpg-pubkey-fd4bf915'), :if => os[:family] == 'redhat' do its(:exit_status) { should eq 0 } its(:stdout) { should contain 'gpg-pubkey-fd4bf915' } end + +describe command('rpm -q gpg-pubkey-e09422b3'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-e09422b3' } +end diff --git a/test/integration/dd-agent-iot/serverspec_datadog/install_info_spec.rb b/test/integration/dd-agent-iot/serverspec_datadog/install_info_spec.rb new file mode 100644 index 00000000..3b915aef --- /dev/null +++ b/test/integration/dd-agent-iot/serverspec_datadog/install_info_spec.rb @@ -0,0 +1,39 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +@agent_package_name = 'datadog-iot-agent' + +describe 'Install infos' do + let(:install_info_path) do + if os == :windows + "#{ENV['ProgramData']}\\Datadog\\install_info" + else + '/etc/datadog-agent/install_info' + end + end + + let(:install_info) do + YAML.load_file(install_info_path) + end + + it 'adds an install_info' do + expect(install_info['install_method']).to match( + 'tool_version' => /chef-\d+\.\d+\.\d+/, + 'tool' => 'chef', + 'installer_version' => /^datadog_cookbook-\d+\.\d+\.\d+$/ + ) + end +end diff --git a/test/integration/dd-agent/serverspec/install_info_spec.rb b/test/integration/dd-agent/serverspec/install_info_spec.rb deleted file mode 100644 index 67b7c6e5..00000000 --- a/test/integration/dd-agent/serverspec/install_info_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'Install infos' do - let(:install_info_path) do - if os == :windows - "#{ENV['ProgramData']}\\Datadog\\install_info" - else - '/etc/datadog-agent/install_info' - end - end - - let(:install_info) do - YAML.load_file(install_info_path) - end - - it 'adds an install_info' do - expect(install_info['install_method']).to match( - 'tool_version' => /chef-\d+\.\d+\.\d+/, - 'tool' => 'chef', - 'installer_version' => /^datadog_cookbook-\d+\.\d+\.\d+$/ - ) - end -end diff --git a/test/integration/dd-agent-handler6/serverspec/dd-agent_spec.rb b/test/integration/dd-agent/serverspec_datadog/dd-agent_spec.rb similarity index 50% rename from test/integration/dd-agent-handler6/serverspec/dd-agent_spec.rb rename to test/integration/dd-agent/serverspec_datadog/dd-agent_spec.rb index dbaf20f5..93576365 100644 --- a/test/integration/dd-agent-handler6/serverspec/dd-agent_spec.rb +++ b/test/integration/dd-agent/serverspec_datadog/dd-agent_spec.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + require 'spec_helper' describe package(@agent_package_name) do @@ -17,17 +31,29 @@ # The new APT keys are imported describe command('apt-key list'), :if => ['debian', 'ubuntu'].include?(os[:family]) do its(:exit_status) { should eq 0 } - its(:stdout) { should contain '382E94DE' } + its(:stdout) { should contain '06462314' } + its(:stdout) { should contain 'C0962C7D' } its(:stdout) { should contain 'F14F620E' } + its(:stdout) { should contain '382E94DE' } end # The new RPM keys are imported -describe command('rpm -q gpg-pubkey-e09422b3'), :if => os[:family] == 'redhat' do +describe command('rpm -q gpg-pubkey-4f09d16b'), :if => os[:family] == 'redhat' do its(:exit_status) { should eq 0 } - its(:stdout) { should contain 'gpg-pubkey-e09422b3' } + its(:stdout) { should contain 'gpg-pubkey-4f09d16b' } +end + +describe command('rpm -q gpg-pubkey-b01082d3'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-b01082d3' } end describe command('rpm -q gpg-pubkey-fd4bf915'), :if => os[:family] == 'redhat' do its(:exit_status) { should eq 0 } its(:stdout) { should contain 'gpg-pubkey-fd4bf915' } end + +describe command('rpm -q gpg-pubkey-e09422b3'), :if => os[:family] == 'redhat' do + its(:exit_status) { should eq 0 } + its(:stdout) { should contain 'gpg-pubkey-e09422b3' } +end diff --git a/test/integration/dd-agent/serverspec_datadog/install_info_spec.rb b/test/integration/dd-agent/serverspec_datadog/install_info_spec.rb new file mode 100644 index 00000000..a277adb0 --- /dev/null +++ b/test/integration/dd-agent/serverspec_datadog/install_info_spec.rb @@ -0,0 +1,37 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +describe 'Install infos' do + let(:install_info_path) do + if os == :windows + "#{ENV['ProgramData']}\\Datadog\\install_info" + else + '/etc/datadog-agent/install_info' + end + end + + let(:install_info) do + YAML.load_file(install_info_path) + end + + it 'adds an install_info' do + expect(install_info['install_method']).to match( + 'tool_version' => /chef-\d+\.\d+\.\d+/, + 'tool' => 'chef', + 'installer_version' => /^datadog_cookbook-\d+\.\d+\.\d+$/ + ) + end +end diff --git a/test/integration/dd-handler/serverspec/dd-handler_spec.rb b/test/integration/dd-handler/serverspec/dd-handler_spec.rb deleted file mode 100644 index 5c2e34ea..00000000 --- a/test/integration/dd-handler/serverspec/dd-handler_spec.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'spec_helper' - -# the be_installed.by('gem') check is not implemented for Windows as of v2.24 of Serverspec -describe package('chef-handler-datadog'), :if => os[:family] != 'windows' do - it { should be_installed.by('gem') } -end diff --git a/test/integration/dd-handler/serverspec_datadog/dd-handler_spec.rb b/test/integration/dd-handler/serverspec_datadog/dd-handler_spec.rb new file mode 100644 index 00000000..9ccbaf12 --- /dev/null +++ b/test/integration/dd-handler/serverspec_datadog/dd-handler_spec.rb @@ -0,0 +1,20 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require 'spec_helper' + +# the be_installed.by('gem') check is not implemented for Windows as of v2.24 of Serverspec +describe package('chef-handler-datadog'), :if => os[:family] != 'windows' do + it { should be_installed.by('gem') } +end diff --git a/test/integration/dd_integration_resource/serverspec/Gemfile b/test/integration/dd_integration_resource/serverspec/Gemfile deleted file mode 120000 index 74f9789f..00000000 --- a/test/integration/dd_integration_resource/serverspec/Gemfile +++ /dev/null @@ -1 +0,0 @@ -../../helpers/serverspec/Gemfile \ No newline at end of file diff --git a/test/integration/dd_integration_resource/serverspec/resource_integration_spec.rb b/test/integration/dd_integration_resource/serverspec/resource_integration_spec.rb deleted file mode 100644 index aea6aeca..00000000 --- a/test/integration/dd_integration_resource/serverspec/resource_integration_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Encoding: utf-8 - -require 'serverspec' - -set :backend, :exec -set :path, '/sbin:/usr/local/sbin:$PATH' - -describe service('datadog-agent') do - it { should be_running } -end - -# Checks that it's installed properly and with the good version -describe command('/opt/datadog-agent/bin/agent/agent integration show datadog-aerospike') do - its(:stdout) { should match /Package datadog-aerospike:\nInstalled version:/ } -end diff --git a/test/integration/dd_integration_resource/serverspec_datadog/Gemfile b/test/integration/dd_integration_resource/serverspec_datadog/Gemfile new file mode 120000 index 00000000..d0b5775b --- /dev/null +++ b/test/integration/dd_integration_resource/serverspec_datadog/Gemfile @@ -0,0 +1 @@ +../../helpers/serverspec_datadog/Gemfile \ No newline at end of file diff --git a/test/integration/dd_integration_resource/serverspec_datadog/resource_integration_spec.rb b/test/integration/dd_integration_resource/serverspec_datadog/resource_integration_spec.rb new file mode 100644 index 00000000..671e7dea --- /dev/null +++ b/test/integration/dd_integration_resource/serverspec_datadog/resource_integration_spec.rb @@ -0,0 +1,29 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Encoding: utf-8 + +require 'serverspec' + +set :backend, :exec +set :path, '/sbin:/usr/local/sbin:$PATH' + +describe service('datadog-agent') do + it { should be_running } +end + +# Checks that it's installed properly and with the good version +describe command('/opt/datadog-agent/bin/agent/agent integration show datadog-aerospike') do + its(:stdout) { should match /Package datadog-aerospike:\nInstalled version:/ } +end diff --git a/test/integration/helpers/serverspec/Gemfile b/test/integration/helpers/serverspec/Gemfile deleted file mode 100644 index 96cef5d3..00000000 --- a/test/integration/helpers/serverspec/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source 'https://rubygems.org' - -gem 'json_spec', '~> 1.1.0' diff --git a/test/integration/helpers/serverspec/spec_template.rb b/test/integration/helpers/serverspec/spec_template.rb deleted file mode 100644 index 20de73e4..00000000 --- a/test/integration/helpers/serverspec/spec_template.rb +++ /dev/null @@ -1,29 +0,0 @@ -# Encoding: utf-8 - -require 'spec_helper' - -AGENT_CONFIG = File.join(@agent_config_dir, 'conf.d/REPLACEME.d/conf.yaml') - -describe service(@agent_service_name) do - it { should be_running } -end - -describe file(AGENT_CONFIG) do - it { should be_a_file } - - it 'is valid yaml matching input values' do - generated = YAML.load_file(AGENT_CONFIG) - - expected = { - instances: [ - { - config_param: 'value', - tags: ['kitchen', 'sink'] - } - ], - init_config: nil - } - - expect(generated.to_json).to be_json_eql expected.to_json - end -end diff --git a/test/integration/datadog_etcd/serverspec/Gemfile b/test/integration/helpers/serverspec_datadog/Gemfile similarity index 100% rename from test/integration/datadog_etcd/serverspec/Gemfile rename to test/integration/helpers/serverspec_datadog/Gemfile diff --git a/test/integration/helpers/serverspec/spec_helper.rb b/test/integration/helpers/serverspec_datadog/spec_helper.rb similarity index 58% rename from test/integration/helpers/serverspec/spec_helper.rb rename to test/integration/helpers/serverspec_datadog/spec_helper.rb index eebf34a0..26ccdf73 100644 --- a/test/integration/helpers/serverspec/spec_helper.rb +++ b/test/integration/helpers/serverspec_datadog/spec_helper.rb @@ -1,3 +1,17 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + # Shared helper for all serverspec tests require 'json_spec' require 'serverspec' diff --git a/test/integration/helpers/serverspec_datadog/spec_template.rb b/test/integration/helpers/serverspec_datadog/spec_template.rb new file mode 100644 index 00000000..0aa1afff --- /dev/null +++ b/test/integration/helpers/serverspec_datadog/spec_template.rb @@ -0,0 +1,43 @@ +# Copyright:: 2011-Present, Datadog +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Encoding: utf-8 + +require 'spec_helper' + +AGENT_CONFIG = File.join(@agent_config_dir, 'conf.d/REPLACEME.d/conf.yaml') + +describe service(@agent_service_name) do + it { should be_running } +end + +describe file(AGENT_CONFIG) do + it { should be_a_file } + + it 'is valid yaml matching input values' do + generated = YAML.load_file(AGENT_CONFIG) + + expected = { + instances: [ + { + config_param: 'value', + tags: ['kitchen', 'sink'] + } + ], + init_config: nil + } + + expect(generated.to_json).to be_json_eql expected.to_json + end +end