voxpupuli / puppet-elasticsearch

Elasticsearch Puppet module
Apache License 2.0
404 stars 479 forks source link

`bin/plugin` is used insead of `bin/elasticsearch-plugin` on the first run #1228

Open viliusgec opened 1 week ago

viliusgec commented 1 week ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

Initialize elasticsearch class and try adding plugins on the same puppet run:

  class { 'elasticsearch':
  ...
  }

  $plugins.each |String $name, Hash $config| {
    elasticsearch::plugin { $name:
      *         => $config,
    }
  }

What are you seeing

If we try installing plugins on the same run as elasticsearch class is initialized - it uses bin/plugin instead of bin/elasticsearch-plugin Puppet::Type::Elasticsearch_plugin::ProviderElasticsearch_plugin: file /usr/share/elasticsearch/bin/plugin does not exist On the second puppet run it does use bin/elasticsearch-plugin

What behavior did you expect instead

/usr/share/elasticsearch/bin/elasticsearch-plugin should be used instead of /usr/share/elasticsearch/bin/plugin

Any additional information you'd like to impart

It looks like this code checks if file exists before puppet run (so before elasticsearch is installed) and will determine to use bin/plugin even when elasticsearch will be installed and elasticsearch-plugin will be added. On the second run it will evaluate again and see that elasticsearch-plugin does exist.

 case Facter.value('osfamily')
  when 'OpenBSD'
    ...
  else
    if File.exist? '/usr/share/elasticsearch/bin/elasticsearch-plugin'
      commands plugin: '/usr/share/elasticsearch/bin/elasticsearch-plugin'
    else
      commands plugin: '/usr/share/elasticsearch/bin/plugin'
     ...

Also using workaround mentioned in this (creating a symlink) issue returns this: CliToolProvider [asticsearch/bin/plugin] not found, available names are [node, shard, plugin, sync-plugins] error. It tries to execute asticsearch/bin/plugin