Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failure to load inifile causing Puppet agent to fail. #56

Merged
merged 1 commit into from
Feb 22, 2016
Merged

Fix failure to load inifile causing Puppet agent to fail. #56

merged 1 commit into from
Feb 22, 2016

Conversation

olavmrk
Copy link
Contributor

@olavmrk olavmrk commented Feb 21, 2016

If the inifile gem isn't installed on the node we get the following error from Puppet agent:

Error: Could not autoload puppet/provider/x509_cert/openssl: cannot load such file -- inifile
Error: Could not autoload puppet/type/x509_cert: Could not autoload puppet/provider/x509_cert/openssl: cannot load such file -- inifile
Error: Failed to apply catalog: Could not autoload puppet/type/x509_cert: Could not autoload puppet/provider/x509_cert/openssl: cannot load such file -- inifile

This happens so early in the process that we can't use Puppet to install the required gem.

This patch changes the code so that the inifile gem isn't loaded until it is actually needed. This has two benefits:

  1. If the code that requires the inifile gem isn't actually used in this deployment, we don't need to install it.
  2. If we need the inifile gem, we can install it through Puppet with the puppet_gem provider.

(Note that installing the inifile gem through Puppet won't fix the failure on the first Puppet run, but subsequent runs (after the Gem is installed) will work.)

If the inifile gem isn't installed on the node we get the following
error from Puppet agent:

> Error: Could not autoload puppet/provider/x509_cert/openssl: cannot load
> such file -- inifile
> Error: Could not autoload puppet/type/x509_cert: Could not autoload
> puppet/provider/x509_cert/openssl: cannot load such file -- inifile
> Error: Failed to apply catalog: Could not autoload puppet/type/x509_cert:
> Could not autoload puppet/provider/x509_cert/openssl: cannot load such
> file -- inifile

This happens so early in the process that we can't use Puppet to install
the required gem.

This patch changes the code so that the inifile gem isn't loaded until it
is actually needed. This has two benefits:

1. If the code that requires the inifile gem isn't actually used in this
   deployment, we don't need to install it.

2. If we need the inifile gem, we can install it through Puppet with the
   `puppet_gem` provider.
raphink added a commit that referenced this pull request Feb 22, 2016
Fix failure to load inifile causing Puppet agent to fail.
@raphink raphink merged commit 70c6bb9 into voxpupuli:master Feb 22, 2016
@olivierHa
Copy link

Hello,

Without this gem, we can't really use this module.
This isn't a puppet module "requirements", so we can't put that in the requirements file.

What it the good way ? adding an ensure_package for inifile using the puppet_gem provider ?

Regards

Olivier

@olavmrk
Copy link
Contributor Author

olavmrk commented Mar 7, 2016

@olivierHa: For my usecase I did not really need the the inifile gem, but after I made this patch I made a simple test and verified that I could install it using the puppet_gem provider, and that I was then able to apply a resource requiring it on the next Puppet run.

I didn't test using ensure_packages(), but I guess something like ensure_packages('inifile', { provider => 'puppet_gem' }) should work. It isn't really a perfect solution, but at least I think it is better than it was.

Note that the puppet_gem package provider is a Puppet 4 feature. If you are using an older version of Puppet, you will probably need to install it using a different provider.

@miloaec
Copy link

miloaec commented Mar 7, 2016

Hi,

Using puppet 3.8.6 and ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux] on Centos 6.7.

On client :

I installed inifile gem : gem install inifile

Then got this error :
Error: Could not run Puppet configuration client: /usr/lib/ruby/gems/1.8/gems/inifile-3.0.0/lib/inifile.rb:558: undefined (?...) sequence: /\A"(.*)(?<!\\)"\z/
Error: Could not run: can't convert Puppet::Util::Log into Integer

The solution is to uninstall inifile (version >= 3) and install inifile version 2.0.2 and it will work.

gem uninstall inifile
gem install inifile -v 2.0.2

Hope it will help.

Regards,

Mikael

@raphink raphink added the bugfix label Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants