puppet-zabbix icon indicating copy to clipboard operation
puppet-zabbix copied to clipboard

"Cannot Load Such File -- zabbixapi" despite installation

Open rtizzy opened this issue 10 years ago • 19 comments

Version Information

OS: RHEL 6 Puppet Master: 3.7.4 Puppet Agent: 3.7.4

Manifest

node 'ZABBIXMASTER' {
  file { '/etc/yum.conf':
    source => 'puppet:///modules/yum/yum.conf',
    owner  => root,
    group  => root,
  }
  class { 'apache':
    mpm_module    => 'prefork',
  }
  include apache::mod::php
  class { 'mysql::server': }
  class { 'zabbix':
    zabbix_url      => 'ZABBIXMASTER',
    database_type   => 'mysql',
    zabbix_api_user => 'Admin',
    zabbix_api_pass => 'HIDDEN',
    manage_resources => true,
  }
  class { 'zabbix::agent':
    server => 'ZABBIXMASTER',
  }
}

node 'EXAMPLENODE' {
  class { 'zabbix::agent':
    server => 'c0007329.itcs.hp.com',
    manage_resources => true,
  }

Issue:

Puppet complains that neither bundler or zabbixapi are installed in logs.

The Zabbix module reports this should resolve after a maximum of 3 runs. Issue did not resolve itself after more than 3 runs.

https://forge.puppetlabs.com/wdijkerman/zabbix/readme#when-using-exported-resources

Attempted Resolution:

Installed bundler and zabbixapi gems on the Zabbix Master server.

gem install bundler 
gem install zabbixapi

Result:

After running puppet agent --test on Zabbix Master the following errors are reported.

[root@nope zabbix]# puppet agent --test
Info: Retrieving plugin
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/win_common_desktop_directory.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/apt_update_last_success.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/pe_puppetdb_server_status.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/concat_basedir.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/puppi_projects.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/pe_version.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/last_run.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/platform_tag.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/pe_postgres_default_version.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/custom_auth_conf.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/root_home.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/ip6tables_version.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/puppet_vardir.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/pe_build.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/windows_common_appdata.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/iptables_persistent_version.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/gemhome.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/apt_updates.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/iptables_version.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/staging_http_get.rb
Info: Loading facts in /var/opt/lib/pe-puppet/lib/facter/windows.rb
Info: Caching catalog for c2t06545.itcs.hp.com
Info: Applying configuration version '1424201871'
Error: Could not run Puppet configuration client: cannot load such file -- zabbixapi
Error: Could not run: can't convert Puppet::Util::Log into Integer

rtizzy avatar Feb 17 '15 20:02 rtizzy

Let me know if further details are needed but I believe this should offer a good representation of the problem.

rtizzy avatar Feb 17 '15 20:02 rtizzy

This is caused by Puppet Enterprise using it's own version of Ruby as opposed to the systems Ruby. Best way to manage this might be to check if Puppet Enterprise is installed then use it's version of gem to install the required components?

rtizzy avatar Feb 17 '15 21:02 rtizzy

Hi elricsfate,

Thanks for making time to create and update this issue. I'll take a look at it. For now I have all te information I need, but I'll let you know if I need some more.

Kind regards, Werner

dj-wasabi avatar Feb 21 '15 09:02 dj-wasabi

Hi,

I just push an fix for this. Please let me know if this helps. (I've created an fact to determine if puppet enterprise is used and thus load pe_gem instead of gem).

Kind regards, Werner

dj-wasabi avatar Feb 21 '15 20:02 dj-wasabi

@dj-wasabi Thank you for the attempted fix.

I pulled this down and attempted to run again but I'm still seeing the same error. I purged all existing instances of zabbix-api using gems before running puppet.

rtizzy avatar Mar 11 '15 20:03 rtizzy

Here is the last bit of a Puppet agent debug on the node in question (Zabbix master node)

Info: Applying configuration version '1426106362'
Debug: Prefetching yum resources for package
Debug: Executing '/bin/rpm --version'
Debug: Executing '/bin/rpm -qa --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n''
Debug: Executing '/usr/bin/python /opt/puppet/lib/ruby/site_ruby/1.9.1/puppet/provider/package/yumhelper.py'
Debug: Failed to load library 'msgpack' for feature 'msgpack'
Debug: file_metadata supports formats: pson b64_zlib_yaml yaml raw
Debug: Prefetching crontab resources for cron
Debug: Failed to load library 'msgpack' for feature 'msgpack'
Debug: file_metadata supports formats: pson b64_zlib_yaml yaml raw
Debug: Failed to load library 'msgpack' for feature 'msgpack'
Debug: file_metadata supports formats: pson b64_zlib_yaml yaml raw
Debug: Executing '/sbin/service mysqld status'
Debug: Executing '/sbin/chkconfig mysqld'
Debug: Failed to load library 'msgpack' for feature 'msgpack'
Debug: file_metadata supports formats: pson b64_zlib_yaml yaml raw
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat[15-default-ssl.conf]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat[15-default-ssl.conf]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf/fragments.concat]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat[15-default-ssl.conf]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf/fragments.concat.out]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Pe_mcollective::Server/File[/etc/puppetlabs/facter/facts.d/puppet_enterprise_installer.txt]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat[15-default-ssl.conf]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf/fragments]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat::Fragment[default-ssl-access_log]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf/fragments/100_default-ssl-access_log]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat::Fragment[default-ssl-ssl]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf/fragments/210_default-ssl-ssl]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat::Fragment[default-ssl-file_footer]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf/fragments/999_default-ssl-file_footer]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat::Fragment[default-ssl-directories]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf/fragments/60_default-ssl-directories]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat::Fragment[default-ssl-docroot]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf/fragments/10_default-ssl-docroot]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat::Fragment[default-ssl-serversignature]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf/fragments/90_default-ssl-serversignature]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat::Fragment[default-ssl-apache-header]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf/fragments/0_default-ssl-apache-header]: Nothing to manage: no ensure and the resource doesn't exist
Debug: Exec[concat_/etc/httpd/conf/ports.conf](provider=posix): Executing check '/var/opt/lib/pe-puppet/concat/bin/concatfragments.sh -o "/var/opt/lib/pe-puppet/concat/_etc_httpd_conf_ports.conf/fragments.concat.out" -d "/var/opt/lib/pe-puppet/concat/_etc_httpd_conf_ports.conf" -t'
Debug: Executing '/var/opt/lib/pe-puppet/concat/bin/concatfragments.sh -o "/var/opt/lib/pe-puppet/concat/_etc_httpd_conf_ports.conf/fragments.concat.out" -d "/var/opt/lib/pe-puppet/concat/_etc_httpd_conf_ports.conf" -t'
Debug: /Stage[main]/Apache/Apache::Vhost[default-ssl]/Concat::Fragment[default-ssl-logging]/File[/var/opt/lib/pe-puppet/concat/15-default-ssl.conf/fragments/80_default-ssl-logging]: Nothing to manage: no ensure and the resource doesn't exist
Debug: Exec[concat_15-default-ssl.conf](provider=posix): Executing check 'true'
Debug: Executing 'true'
Debug: /Stage[main]/Pe_mcollective::Server::Plugins/File[/opt/puppet/libexec/mcollective/mcollective/agent/puppetd.ddl]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Pe_mcollective::Server::Plugins/File[/opt/puppet/libexec/mcollective/mcollective/agent/puppetd.rb]: Nothing to manage: no ensure and the resource doesn't exist
Debug: /Stage[main]/Pe_mcollective::Server::Plugins/File[/opt/puppet/libexec/mcollective/mcollective/application/puppetd.rb]: Nothing to manage: no ensure and the resource doesn't exist
Debug: Storing state
Debug: Stored state in 0.19 seconds
Error: Could not run Puppet configuration client: cannot load such file -- -- zabbixapi
Error: Could not run: can't convert Puppet::Util::Log into Integer

rtizzy avatar Mar 11 '15 20:03 rtizzy

Hi elricsfate,

It's a pity this fix won't help you. You do have this module 'https://github.com/puppetlabs/puppetlabs-pe_gem' on the puppet master?

Kind regards, Werner

dj-wasabi avatar Mar 12 '15 17:03 dj-wasabi

[root@HOSTNAME puppet]# puppet module list | grep puppetlabs-pe_gem

├── puppetlabs-pe_gem (v0.1.0)

It would seem I do. Another note: It would seem this issue was again fixed by referencing the puppet enterprise gem binary directly and installing the correct version via that.

Thanks,

elricsfate [email protected]

On Thu, Mar 12, 2015 at 12:19 PM, Werner Dijkerman <[email protected]

wrote:

Hi elricsfate,

It's a pity this fix won't help you. You do have this module ' https://github.com/puppetlabs/puppetlabs-pe_gem' on the puppet master?

Kind regards, Werner

— Reply to this email directly or view it on GitHub https://github.com/dj-wasabi/puppet-zabbix/issues/54#issuecomment-78534749 .

rtizzy avatar Mar 12 '15 19:03 rtizzy

Hi elricsfate,

Does this mean that issue is fixed?

Kind regards, Werner

dj-wasabi avatar Apr 08 '15 09:04 dj-wasabi

Howdy Werner,

Negative, unfortunately.

I do have the pe_gem module installed but even then the problem does not seem to be resolved.

Thanks,

Robert Tisdale

rtizzy avatar Apr 08 '15 17:04 rtizzy

@dj-wasabi @elricsfate We are experiencing the same issue. We believe it is due to a missing dependency on gcc.

[user@server ~]$ sudo /opt/puppet/bin/gem install zabbixapi
Building native extensions.  This could take a while...
ERROR:  Error installing zabbixapi:
        ERROR: Failed to build gem native extension.

        /opt/puppet/bin/ruby extconf.rb
creating Makefile

make
compiling generator.c
make: gcc: Command not found
make: *** [generator.o] Error 127


Gem files will remain installed in /opt/puppet/lib/ruby/gems/1.9.1/gems/json-1.8.2 for inspection.
Results logged to /opt/puppet/lib/ruby/gems/1.9.1/gems/json-1.8.2/ext/json/ext/generator/gem_make.out

We are trying to update the profile class to include puppetlabs/gcc and will report back!

rnelson0 avatar Apr 08 '15 20:04 rnelson0

The required fix was to install gcc and then install the gem manually. To ensure this was a similar issue, here is the error:

[user@zabbix ~]# puppet agent -t --environment zabbix_test 
Info: Retrieving pluginfacts 
Info: Retrieving plugin 
Info: Loading facts 
Info: Caching catalog for zabbix.example.com 
Info: Applying configuration version '1428525699' 
Error: Could not run Puppet configuration client: cannot load such file -- zabbixapi 
Error: Could not run: can't convert Puppet::Util::Log into Integer

A yum install -y gcc followed by installing the gem:

[user@zabbix ~]# /opt/puppet/bin/gem install zabbixapi 
Building native extensions.  This could take a while... 
Fetching: zabbixapi-2.4.2.gem (100%) 
Successfully installed json-1.8.2 
Successfully installed zabbixapi-2.4.2 
2 gems installed 
Installing ri documentation for json-1.8.2... 
Installing ri documentation for zabbixapi-2.4.2... 
Installing RDoc documentation for json-1.8.2... 
Installing RDoc documentation for zabbixapi-2.4.2...

Now we are able to get catalog compilation working and exported resources flow.

This appears to be an ordering issue, where the zabbixapi is used before the gem is installed. Run stages could probably solve it.

Gem usage: https://github.com/dj-wasabi/puppet-zabbix/blob/master/lib/puppet/provider/zabbix.rb#L4-L6 Gem installation: https://github.com/dj-wasabi/puppet-zabbix/blob/master/manifests/web.pp#L177-L181

rnelson0 avatar Apr 08 '15 20:04 rnelson0

Hi @rnelson0

I found this comment from Jeff McCune | 20 Nov 20:42 2012 on this http://comments.gmane.org/gmane.comp.sysutils.puppet.user/47508 link: ----8<---- This specific issue is a chicken and egg problem where by a provider needs a gem, but the catalog run itself is the thing that provides the gem dependency. That is to say, even in Puppet 3.0 where we delay loading all of the providers until after pluginsync finishes, the catalog run hasn't yet installed the gem when the provider is loaded.

The reason I think this is basically a very specific incarnation of #6907 is because that ticket is pretty specific from a product functionality perspective, "You should not have to run puppet twice to use a provider." ----8<----

So in this case, the first run will go into error because of this ordering isse. But the 2nd run will use the zabbixapi and continues to create the hosts.

The Class['ruby::dev'] should have installed gcc right?

Kind regards, Werner

dj-wasabi avatar Apr 09 '15 07:04 dj-wasabi

@dj-wasabi The puppetlabs/ruby module has no mention of gcc. However, even if it did, because the puppet run is interrupted immediately, any application of puppetlabs/gcc will not be installed. Of course, once gcc and the zabbixapi gem are installed by hand, gcc isn't really needed anymore... It would be interesting to see if run stages could force gcc/zabbixapi to be completed before the provider is used. /cc @croddy

rnelson0 avatar Apr 09 '15 12:04 rnelson0

@rnelson0

Will take a look at it. Can't guarantee it will be fixed soon.. (Other projects needs my time to, like my wife ;-))

Kind regards, Werner

dj-wasabi avatar Apr 10 '15 13:04 dj-wasabi

@dj-wasabi did you ever get this fixed?

ericsysmin avatar Feb 22 '16 08:02 ericsysmin

No. I started a while back to look for information about stages, but I tried some small things but didn't work. But don't know if this was related to the stages or something else. Didn't had any time to investigate it further.

dj-wasabi avatar Feb 22 '16 17:02 dj-wasabi

I'd like to comment that for me, on Puppet 5 Open Source, I also had to install gcc-c++ (via yum) to be able to install the zabbixapi gem:

[root@puppetserver 2.4.0]# /opt/puppetlabs/puppet/bin/gem install zabbixapi Building native extensions. This could take a while... ERROR: Error installing zabbixapi: ERROR: Failed to build gem native extension.

current directory: /opt/puppetlabs/puppet/lib/ruby/gems/2.4.0/gems/unf_ext-0.0.7.5/ext/unf_ext

/opt/puppetlabs/puppet/bin/ruby -r ./siteconf20180302-935-13qzu8q.rb extconf.rb checking for -lstdc++... no creating Makefile

current directory: /opt/puppetlabs/puppet/lib/ruby/gems/2.4.0/gems/unf_ext-0.0.7.5/ext/unf_ext make "DESTDIR=" clean

current directory: /opt/puppetlabs/puppet/lib/ruby/gems/2.4.0/gems/unf_ext-0.0.7.5/ext/unf_ext make "DESTDIR=" compiling unf.cc make: g++: Command not found make: *** [unf.o] Error 127

make failed, exit code 2

Gem files will remain installed in /opt/puppetlabs/puppet/lib/ruby/gems/2.4.0/gems/unf_ext-0.0.7.5 for inspection. Results logged to /opt/puppetlabs/puppet/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0/unf_ext-0.0.7.5/gem_make.out

yum install gcc-c++

[root@puppetserver 2.4.0]# /opt/puppetlabs/puppet/bin/gem install zabbixapi
Building native extensions. This could take a while... Successfully installed unf_ext-0.0.7.5

Done installing documentation for unf_ext, unf, domain_name, http-cookie, public_suffix, addressable, http, zabbixapi after 6 seconds 8 gems installed

[root@puppetserver 2.4.0]# /opt/puppetlabs/puppet/bin/gem list zabbixapi

*** LOCAL GEMS ***

zabbixapi (3.2.1)

bschonec avatar Mar 02 '18 15:03 bschonec

I also ran into this issue. I use roles and profiles and always use a base profile which has a parameter "additional_packages" to be able to install missing dependencies easely. So when i added this to my hieradata:

profile::base::additional_packages:
  - 'gcc-c++'

It worked fine.

Fabian1976 avatar May 03 '18 08:05 Fabian1976