File: elasticsearch_shield_users_native.rb

package info (click to toggle)
puppet-module-voxpupuli-elasticsearch 9.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,496 kB
  • sloc: ruby: 9,906; sh: 392; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 620 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

require 'puppet/util/feature'
require 'puppet/util/package'

shield_plugin_dir = '/usr/share/elasticsearch/plugins/shield'

Puppet.features.add(:elasticsearch_shield_users_native) do
  return false unless File.exist?(shield_plugin_dir)

  jars = Dir["#{shield_plugin_dir}/*.jar"]
  jar_parts = jars.map do |file|
    File.basename(file, '.jar').split('-')
  end
  shield_components = jar_parts.select do |parts|
    parts.include? 'shield'
  end
  shield_components.any? do |parts|
    parts.last =~ %r{^[\d.]+$} &&
      Puppet::Util::Package.versioncmp(parts.last, '2.3') >= 0
  end
end