diff --git a/.kitchen.dokken.yml b/.kitchen.dokken.yml index 950d0cd..d8db3d4 100644 --- a/.kitchen.dokken.yml +++ b/.kitchen.dokken.yml @@ -128,6 +128,6 @@ suites: - name: chef13-preview driver: - chef_version: 13.3.42 + chef_version: 13.9.4 run_list: - recipe[filebeat_test::defaultv6preview] diff --git a/CHANGELOG.md b/CHANGELOG.md index 29b6a4b..7f62f79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,31 @@ filebeat CHANGELOG ================== +2.1.0 +----- + +- Virender Khatri - Added filebeat_install attr :elastic_repo_options for :elastic_repo resource configuration + +- Virender Khatri - Added filebeat Log Directory Resource + +- Virender Khatri - Updated filebeat_service service resource + +- Virender Khatri - Updated filebeat_resource lookup to use attr filebeat_install_resource_name + +- Virender Khatri - Fixed filebeat_install for windows + +- Virender Khatri - Updated elastic_repo cookbook version + + +2.0.0 +----- + +- Virender Khatri - Converted Recipes to LWRP Resources, check README for available resources and test cookbook for usage reference + +- Virender Khatri - LWRP Resources uses elastic_repo cookbook to setup elastic yum/apt repository + +- Michael Burns - Clean up redundant filebeat_prospector resource attribute in test cookbook + 1.5.0 ----- - Virender Khatri - Updated filebeat version to v6.2.4 diff --git a/README.md b/README.md index 0d8470a..3a4369d 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,14 @@ This is a [Chef] cookbook to manage [Filebeat]. ## Most Recent Release ```ruby -cookbook 'filebeat', '~> 2.0.0' +cookbook 'filebeat', '~> 2.1.0' ``` ## From Git ```ruby -cookbook 'filebeat', github: 'vkhatri/chef-filebeat', tag: 'v2.0.0' +cookbook 'filebeat', github: 'vkhatri/chef-filebeat', tag: 'v2.1.0' ``` @@ -124,6 +124,7 @@ end - *windows_package_url* (optional, String) - default `auto`, windows filebeat package url - *windows_base_dir* (optional, String) - default `C:/opt/filebeat`, filebeat windows base directory - *apt_options* (optional, Array) - default `%w[stable main]`, filebeat package resource attribute for `debian` platform family +- *elastic_repo_options* (optional, Hash) - default `{}`, resource elastic_repo options, `filebeat_install` attribute `version` overrides `elasti_repo_options` key `version` value. Check out [elastic_repo cookbook](https://github.com/vkhatri/chef-elastic-repo) for more details. ## LWRP filebeat_service diff --git a/libraries/helper.rb b/libraries/helper.rb index 43877f6..bba2135 100644 --- a/libraries/helper.rb +++ b/libraries/helper.rb @@ -23,7 +23,7 @@ def machine_arch node['kernel']['machine'] =~ /x86_64/ ? 'x86_64' : 'x86' end -def windows_package_url(version, package_url) +def win_package_url(version, package_url) package_url = if version < '5.0' package_url == 'auto' ? "https://download.elastic.co/beats/filebeat/filebeat-#{version}-windows.zip" : package_url else diff --git a/metadata.rb b/metadata.rb index a36c538..8275896 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,13 +4,13 @@ license 'Apache-2.0' description 'Installs/Configures Elastic Filebeat' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '2.0.0' +version '2.1.0' source_url 'https://github.com/vkhatri/chef-filebeat' if respond_to?(:source_url) issues_url 'https://github.com/vkhatri/chef-filebeat/issues' if respond_to?(:issues_url) chef_version '>= 12.14' if respond_to?(:chef_version) depends 'homebrew', '~> 4.2' -depends 'elastic_repo', '>= 1.0.0' +depends 'elastic_repo', '>= 1.1.1' depends 'yum-plugin-versionlock', '>= 0.1.2' depends 'runit' depends 'windows' diff --git a/resources/config.rb b/resources/config.rb index 171864a..3ced584 100755 --- a/resources/config.rb +++ b/resources/config.rb @@ -50,7 +50,7 @@ end action :delete do - filebeat_install_resource = find_beat_resource(Chef.run_context, :filebeat_install) + filebeat_install_resource = find_beat_resource(Chef.run_context, :filebeat_install, new_resource.filebeat_install_resource_name) new_resource.conf_file = new_resource.conf_file || default_conf_file(filebeat_install_resource.conf_dir) file new_resource.conf_file do diff --git a/resources/install.rb b/resources/install.rb index a03f26b..9e6681d 100755 --- a/resources/install.rb +++ b/resources/install.rb @@ -19,6 +19,7 @@ property :windows_package_url, String, default: 'auto' property :windows_base_dir, String, default: 'C:/opt/filebeat' property :apt_options, String, default: "-o Dpkg::Options::='--force-confnew' --force-yes" +property :elastic_repo_options, Hash, default: {} default_action :create @@ -28,10 +29,9 @@ new_resource.log_dir = new_resource.log_dir || default_log_dir(new_resource.conf_dir) version_string = %w[fedora rhel amazon].include?(node['platform_family']) ? "#{new_resource.version}-#{new_resource.release}" : new_resource.version - service_action = new_resource.disable_service ? %i[disable nothing] : %i[enable nothing] with_run_context(:root) do edit_resource(:service, new_resource.service_name) do - action service_action + action :nothing end end @@ -61,7 +61,7 @@ ## install filebeat windows if node['platform'] == 'windows' - package_url = windows_package_url(new_resource.version, new_resource.windows_package_url) + package_url = win_package_url(new_resource.version, new_resource.windows_package_url) package_file = ::File.join(Chef::Config[:file_cache_path], ::File.basename(package_url)) remote_file 'filebeat_package_file' do @@ -89,8 +89,12 @@ ## install filebeat yum/apt if %w[fedora rhel amazon debian].include?(node['platform_family']) # setup yum/apt repository + elastic_repo_opts = new_resource.elastic_repo_options.dup + elastic_repo_opts['version'] = new_resource.version elastic_repo 'default' do - version new_resource.version + elastic_repo_opts.each do |key, value| + send(key, value) unless value.nil? + end only_if { new_resource.setup_repo } end @@ -126,7 +130,9 @@ end end - directory new_resource.log_dir + directory new_resource.log_dir do + mode 0o755 + end prospectors_dir_action = new_resource.delete_prospectors_dir ? %i[delete create] : %i[create] @@ -151,4 +157,9 @@ action :delete recursive true end + + directory '/var/log/filebeat' do + action :delete + recursive true + end end diff --git a/resources/prospector.rb b/resources/prospector.rb index 9089cf1..39058a3 100755 --- a/resources/prospector.rb +++ b/resources/prospector.rb @@ -46,7 +46,7 @@ end action :delete do - filebeat_install_resource = find_beat_resource(Chef.run_context, :filebeat_install) + filebeat_install_resource = find_beat_resource(Chef.run_context, :filebeat_install, new_resource.filebeat_install_resource_name) file "prospector_#{new_resource.name}" do path ::File.join(filebeat_install_resource.prospectors_dir, "lwrp-prospector-#{new_resource.name}.yml") action :delete diff --git a/resources/service.rb b/resources/service.rb index 1814e7d..5bf0ead 100755 --- a/resources/service.rb +++ b/resources/service.rb @@ -13,7 +13,6 @@ property :retries, Integer, default: 2 property :retry_delay, Integer, default: 0 -property :notify_restart, [TrueClass, FalseClass], default: false default_action :create @@ -48,15 +47,13 @@ service_action = new_resource.disable_service ? %i[disable stop] : %i[enable nothing] - with_run_context(:root) do - edit_resource(:service, new_resource.service_name) do - provider Chef::Provider::Service::Solaris if node['platform_family'] == 'solaris2' - retries new_resource.retries - retry_delay new_resource.retry_delay - supports :status => true, :restart => true - action service_action - ignore_failure new_resource.ignore_failure - end + service new_resource.service_name do + provider Chef::Provider::Service::Solaris if node['platform_family'] == 'solaris2' + retries new_resource.retries + retry_delay new_resource.retry_delay + supports :status => true, :restart => true + action service_action + ignore_failure new_resource.ignore_failure end end