From 26c2cd739263a6850699c8b674375cd7b6e31ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Tarti=C3=A8re?= Date: Wed, 22 Nov 2023 16:35:01 -1000 Subject: [PATCH 1/6] Remove legacy top-scope syntax --- CHANGELOG.md | 2 +- HISTORY.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b4b1d951..3f502df7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -499,7 +499,7 @@ This release also adds the ability to define logging rolling file settings and a * Recursively create the logdir for elasticsearch when creating multiple instances * Files and directories with root ownership now specify UID/GID 0 instead to improve compatability with *BSDs. * Elasticsearch Debian init file changed to avoid throwing errors when DATA_DIR, WORK_DIR and/or LOG_DIR were an empty variable. -* Fixed a broken File dependency when a plugin was set to absent and ::elasticsearch set to present. +* Fixed a broken File dependency when a plugin was set to absent and elasticsearch set to present. * Fixed issue when using the `proxy` parameter on plugins in Elasticsearch 2.x. #### Changes diff --git a/HISTORY.md b/HISTORY.md index d2f42ec57..117b0e0db 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -397,7 +397,7 @@ This release also adds the ability to define logging rolling file settings and a * Recursively create the logdir for elasticsearch when creating multiple instances * Files and directories with root ownership now specify UID/GID 0 instead to improve compatability with *BSDs. * Elasticsearch Debian init file changed to avoid throwing errors when DATA_DIR, WORK_DIR and/or LOG_DIR were an empty variable. -* Fixed a broken File dependency when a plugin was set to absent and ::elasticsearch set to present. +* Fixed a broken File dependency when a plugin was set to absent and elasticsearch set to present. * Fixed issue when using the `proxy` parameter on plugins in Elasticsearch 2.x. #### Changes From 383f11268d9df0b2ba54a34ebcd3f88ce04f90ca Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Sun, 2 Jul 2023 23:44:05 +0200 Subject: [PATCH 2/6] Add Puppet 8 support --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index c02e18c0d..62054b7b1 100644 --- a/metadata.json +++ b/metadata.json @@ -78,7 +78,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 7.0.0 < 8.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ] } From f3425a895f731058cc5bedae142e56924f36f59a Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Tue, 20 Feb 2024 18:35:45 +0100 Subject: [PATCH 3/6] Replace PSON.load with JSON.parse --- lib/puppet/type/elasticsearch_component_template.rb | 2 +- lib/puppet/type/elasticsearch_ilm_policy.rb | 2 +- lib/puppet/type/elasticsearch_index_template.rb | 2 +- lib/puppet/type/elasticsearch_slm_policy.rb | 2 +- lib/puppet/type/elasticsearch_template.rb | 2 +- spec/helpers/unit/type/elasticsearch_rest_shared_examples.rb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/puppet/type/elasticsearch_component_template.rb b/lib/puppet/type/elasticsearch_component_template.rb index f8fc45723..ac963fef7 100644 --- a/lib/puppet/type/elasticsearch_component_template.rb +++ b/lib/puppet/type/elasticsearch_component_template.rb @@ -102,7 +102,7 @@ def insync?(value) fail(format('Could not find any content at %s', self[:source])) unless tmp - self[:content] = PSON.load(tmp.content) + self[:content] = JSON.parse(tmp.content) end end # rubocop:enable Style/SignalException diff --git a/lib/puppet/type/elasticsearch_ilm_policy.rb b/lib/puppet/type/elasticsearch_ilm_policy.rb index 554a982aa..5e23c6e4f 100644 --- a/lib/puppet/type/elasticsearch_ilm_policy.rb +++ b/lib/puppet/type/elasticsearch_ilm_policy.rb @@ -78,7 +78,7 @@ def insync?(value) fail(format('Could not find any content at %s', self[:source])) unless tmp - self[:content] = PSON.load(tmp.content) + self[:content] = JSON.parse(tmp.content) end end # rubocop:enable Style/SignalException diff --git a/lib/puppet/type/elasticsearch_index_template.rb b/lib/puppet/type/elasticsearch_index_template.rb index e2bc8cf03..c8b90e400 100644 --- a/lib/puppet/type/elasticsearch_index_template.rb +++ b/lib/puppet/type/elasticsearch_index_template.rb @@ -109,7 +109,7 @@ def insync?(value) fail(format('Could not find any content at %s', self[:source])) unless tmp - self[:content] = PSON.load(tmp.content) + self[:content] = JSON.parse(tmp.content) end end # rubocop:enable Style/SignalException diff --git a/lib/puppet/type/elasticsearch_slm_policy.rb b/lib/puppet/type/elasticsearch_slm_policy.rb index ebb3271da..a7fd76abf 100644 --- a/lib/puppet/type/elasticsearch_slm_policy.rb +++ b/lib/puppet/type/elasticsearch_slm_policy.rb @@ -78,7 +78,7 @@ def insync?(value) fail(format('Could not find any content at %s', self[:source])) unless tmp - self[:content] = PSON.load(tmp.content) + self[:content] = JSON.parse(tmp.content) end end # rubocop:enable Style/SignalException diff --git a/lib/puppet/type/elasticsearch_template.rb b/lib/puppet/type/elasticsearch_template.rb index 6fd715fb5..8e6f70078 100644 --- a/lib/puppet/type/elasticsearch_template.rb +++ b/lib/puppet/type/elasticsearch_template.rb @@ -110,7 +110,7 @@ def insync?(value) fail(format('Could not find any content at %s', self[:source])) unless tmp - self[:content] = PSON.load(tmp.content) + self[:content] = JSON.parse(tmp.content) end end # rubocop:enable Style/SignalException diff --git a/spec/helpers/unit/type/elasticsearch_rest_shared_examples.rb b/spec/helpers/unit/type/elasticsearch_rest_shared_examples.rb index d3e8a4aac..be877a48c 100644 --- a/spec/helpers/unit/type/elasticsearch_rest_shared_examples.rb +++ b/spec/helpers/unit/type/elasticsearch_rest_shared_examples.rb @@ -65,7 +65,7 @@ end.not_to raise_error end - it 'parses PSON-like values for certain types' do + it 'parses JSON-like values for certain types' do expect(described_class.new( :name => resource_name, meta_property => { 'key' => { 'value' => '0', 'other' => true } } From 4d7bed39a20aae907ff86a36a13c4a23a3d4d87c Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Tue, 20 Feb 2024 21:36:39 +0100 Subject: [PATCH 4/6] api_objects: change validate_tls to a parameter --- lib/puppet/provider/elastic_rest.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/elastic_rest.rb b/lib/puppet/provider/elastic_rest.rb index 2a56ed313..e7197197d 100644 --- a/lib/puppet/provider/elastic_rest.rb +++ b/lib/puppet/provider/elastic_rest.rb @@ -92,7 +92,7 @@ def self.api_objects(protocol = 'http', password = nil, ca_file = nil, ca_path = nil, - validate_tls: true) + validate_tls = true) uri = URI("#{protocol}://#{host}:#{port}/#{format_uri(api_discovery_uri)}") http = Net::HTTP.new uri.host, uri.port @@ -158,7 +158,7 @@ def self.prefetch(resources) (p.key?(:password) ? p[:password].value : nil), (p.key?(:ca_file) ? p[:ca_file].value : nil), (p.key?(:ca_path) ? p[:ca_path].value : nil), - { validate_tls: p[:validate_tls].value }, + (p.key?(:validate_tls) ? p[:validate_tls].value : true), ] # Deduplicate identical settings, and fetch templates end.uniq @@ -264,7 +264,7 @@ def flush resource[:password], resource[:ca_file], resource[:ca_path], - validate_tls: resource[:validate_tls] + resource[:validate_tls].nil? ? true : resource[:validate_tls] ).find do |t| t[:name] == resource[:name] end From 1be7a4005522a55419de3ceba6169b694f05d3f0 Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Tue, 20 Feb 2024 21:52:21 +0100 Subject: [PATCH 5/6] Remove duplicate parameter declarations in acceptance tests --- spec/helpers/acceptance/tests/package_url_shared_examples.rb | 2 -- spec/helpers/acceptance/tests/slm_policy_shared_examples.rb | 2 -- .../acceptance/tests/snapshot_repository_shared_examples.rb | 2 -- 3 files changed, 6 deletions(-) diff --git a/spec/helpers/acceptance/tests/package_url_shared_examples.rb b/spec/helpers/acceptance/tests/package_url_shared_examples.rb index 841701a19..10911981b 100644 --- a/spec/helpers/acceptance/tests/package_url_shared_examples.rb +++ b/spec/helpers/acceptance/tests/package_url_shared_examples.rb @@ -10,8 +10,6 @@ <<-MANIFEST api_timeout => 60, config => { - 'cluster.name' => '#{v[:cluster_name]}', - 'http.bind_host' => '0.0.0.0', #{es_config.map { |k, v| " '#{k}' => '#{v}'," }.join("\n")} }, jvm_options => [ diff --git a/spec/helpers/acceptance/tests/slm_policy_shared_examples.rb b/spec/helpers/acceptance/tests/slm_policy_shared_examples.rb index 0c9ec71ed..c9ffe06ac 100644 --- a/spec/helpers/acceptance/tests/slm_policy_shared_examples.rb +++ b/spec/helpers/acceptance/tests/slm_policy_shared_examples.rb @@ -99,8 +99,6 @@ <<-MANIFEST api_timeout => 60, config => { - 'cluster.name' => '#{v[:cluster_name]}', - 'http.bind_host' => '0.0.0.0', #{es_config.map { |k, v| " '#{k}' => '#{v}'," }.join("\n")} }, jvm_options => [ diff --git a/spec/helpers/acceptance/tests/snapshot_repository_shared_examples.rb b/spec/helpers/acceptance/tests/snapshot_repository_shared_examples.rb index 1dbbd73a9..a0d38fa8e 100644 --- a/spec/helpers/acceptance/tests/snapshot_repository_shared_examples.rb +++ b/spec/helpers/acceptance/tests/snapshot_repository_shared_examples.rb @@ -29,8 +29,6 @@ <<-MANIFEST api_timeout => 60, config => { - 'cluster.name' => '#{v[:cluster_name]}', - 'http.bind_host' => '0.0.0.0', #{es_config.map { |k, v| " '#{k}' => '#{v}'," }.join("\n")} }, jvm_options => [ From 3e6af08d31ad7172340968c53d655e86b99081e9 Mon Sep 17 00:00:00 2001 From: Hugo Haakseth Date: Tue, 20 Feb 2024 23:54:17 +0100 Subject: [PATCH 6/6] Fix broken unit tests --- .../elasticsearch_keystore_spec.rb | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/spec/unit/provider/elasticsearch_keystore/elasticsearch_keystore_spec.rb b/spec/unit/provider/elasticsearch_keystore/elasticsearch_keystore_spec.rb index 355350b13..8da362a69 100644 --- a/spec/unit/provider/elasticsearch_keystore/elasticsearch_keystore_spec.rb +++ b/spec/unit/provider/elasticsearch_keystore/elasticsearch_keystore_spec.rb @@ -54,13 +54,15 @@ to receive(:execute). with( [executable, 'list'], - custom_environment: { - 'ES_INCLUDE' => defaults_file, - 'ES_PATH_CONF' => "/etc/elasticsearch/#{instance}" - }, - uid: 'elasticsearch', - gid: 'elasticsearch', - failonfail: true + { + custom_environment: { + 'ES_INCLUDE' => defaults_file, + 'ES_PATH_CONF' => "/etc/elasticsearch/#{instance}" + }, + uid: 'elasticsearch', + gid: 'elasticsearch', + failonfail: true + } ). and_return( Puppet::Util::Execution::ProcessOutput.new( @@ -118,13 +120,15 @@ receive(:execute). with( [executable, 'create'], - custom_environment: { - 'ES_INCLUDE' => '/etc/default/elasticsearch-es-03', - 'ES_PATH_CONF' => '/etc/elasticsearch/es-03' - }, - uid: 'elasticsearch', - gid: 'elasticsearch', - failonfail: true + { + custom_environment: { + 'ES_INCLUDE' => '/etc/default/elasticsearch-es-03', + 'ES_PATH_CONF' => '/etc/elasticsearch/es-03' + }, + uid: 'elasticsearch', + gid: 'elasticsearch', + failonfail: true + } ). and_return(Puppet::Util::Execution::ProcessOutput.new('', 0)) ) @@ -135,13 +139,15 @@ have_received(:execute). with( [executable, 'create'], - custom_environment: { - 'ES_INCLUDE' => '/etc/default/elasticsearch-es-03', - 'ES_PATH_CONF' => '/etc/elasticsearch/es-03' - }, - uid: 'elasticsearch', - gid: 'elasticsearch', - failonfail: true + { + custom_environment: { + 'ES_INCLUDE' => '/etc/default/elasticsearch-es-03', + 'ES_PATH_CONF' => '/etc/elasticsearch/es-03' + }, + uid: 'elasticsearch', + gid: 'elasticsearch', + failonfail: true + } ) ) end