diff --git a/README.md b/README.md index 619761f7..9d0a4e25 100644 --- a/README.md +++ b/README.md @@ -178,7 +178,7 @@ By default, the current major version of this cookbook installs Agent v7. The fo | `agent_major_version` | Pin the major version of the Agent to 5, 6, or 7 (default). | | `agent_version` | Pin a specific Agent version (recommended). | | `agent_package_action` | (Linux only) Defaults to `'install'` (recommended), `'upgrade'` to get automatic Agent updates (not recommended, use the default and change the pinned `agent_version` to upgrade). | -| `agent_flavor` | (Linux only) Defaults to `'datadog-agent'` to install the datadog-agent, can be set to `'datadog-iot-agent'` to install the IOT agent. | +| `agent_flavor` | (Linux only) Defaults to `'datadog-agent'` to install the datadog-agent, can be set to `'datadog-iot-agent'` to install the IOT agent and `'datadog-fips-agent'` | See the sample [attributes/default.rb][1] for your cookbook version for all available attributes. diff --git a/attributes/default.rb b/attributes/default.rb index 5fa8a783..0710d8f9 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -40,7 +40,7 @@ # Example: # default['datadog']['agent_version'] = '7.16.0' default['datadog']['agent_version'] = nil # nil to install latest -# Agent flavor to install, acceptable values are "datadog-agent", "datadog-iot-agent" +# Agent flavor to install, acceptable values are "datadog-agent", "datadog-iot-agent", "datadog-fips-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: diff --git a/kitchen.yml b/kitchen.yml index 2f8d7ddb..aa3ca132 100644 --- a/kitchen.yml +++ b/kitchen.yml @@ -75,6 +75,17 @@ suites: api_key: somenonnullapikeythats32charlong application_key: alsonotnil +- name: dd-fips-agent + run_list: + - recipe[datadog::dd-agent] + attributes: + datadog: &DATADOG + api_key: somenonnullapikeythats32charlong + application_key: alsonotnil + install_info_enabled: true + agent_flavor: datadog-fips-agent + agent_version: '7.20.0~rc.3' + - name: dd-agent-iot run_list: - recipe[datadog::dd-agent] diff --git a/libraries/recipe_helpers.rb b/libraries/recipe_helpers.rb index 0ec4f3fa..1d3d4a2c 100644 --- a/libraries/recipe_helpers.rb +++ b/libraries/recipe_helpers.rb @@ -18,6 +18,7 @@ class Datadog class << self ACCEPTABLE_AGENT_FLAVORS = %w[ datadog-agent + datadog-fips-agent datadog-iot-agent ].freeze diff --git a/test/integration/dd-fips-agent/serverspec_datadog/dd-agent_spec.rb b/test/integration/dd-fips-agent/serverspec_datadog/dd-agent_spec.rb new file mode 100644 index 00000000..ded5401f --- /dev/null +++ b/test/integration/dd-fips-agent/serverspec_datadog/dd-agent_spec.rb @@ -0,0 +1,60 @@ +# 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-fips-agent' + +describe package(@agent_package_name) do + it { should be_installed } +end + +describe service(@agent_service_name) do + it { should be_running } +end + +describe command('/opt/datadog-agent/bin/agent/agent status | grep -v "Instance ID"'), :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 1 } +end diff --git a/test/integration/dd-fips-agent/serverspec_datadog/install_info_spec.rb b/test/integration/dd-fips-agent/serverspec_datadog/install_info_spec.rb new file mode 100644 index 00000000..3b915aef --- /dev/null +++ b/test/integration/dd-fips-agent/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