puppetlabs / puppetlabs-resource_api

deploy the puppet-resource_api gem across your infrastructure
3 stars 8 forks source link

Module throws an error on puppetserver when running environment isolation #36

Open andylytical opened 3 years ago

andylytical commented 3 years ago

Describe the Bug

When running environment isolation, the following error is thrown: Failed to load custom type 'mysql_login_path' from '/etc/puppetlabs/code/environments/production/modules/mysql/lib/puppet/type/mysql_login_path.rb': cannot load such file -- puppet/resource_api

Expected Behavior

Puppet environment isolation should run without errors.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Add to Puppetfile: mod 'puppetlabs-resource_api', '1.1.0'
  2. On puppet master machine, run r10k deploy environment -p -v debug2
  3. On puppet master machine, run puppet generate types --environment production

Environment

Additional Context

This module is included as a dependency for puppetlabs/mysql, which also throws a similar error during environment isolation: Error: Failed to load custom type 'mysql_login_path' from '/etc/puppetlabs/code/environments/production/modules/mysql/lib/puppet/type/mysql_login_path.rb': cannot load such file -- puppet/resource_api

jgrammen-agilitypr commented 3 years ago

I setup a test vm and get a similar error, maybe it is also due to the same issue

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Could not autoload puppet/type/mysql_login_path: no such file to load -- puppet/resource_api (file: /etc/puppetlabs/code/environments/production/manifests/90-infra.pp, line: 623, column: 3) on node
0x6d617474 commented 3 years ago

The command puppet generate types uses the puppet agent ruby libraries, and so the puppet-resource_api gem needs to be installed to the puppet agent ruby library on the puppetserver node.

I think the 6.x version of the puppet agent has the gem bundled in the agent, but 5.x needs to have it explicitly installed.

Running this on the puppetserver node fixes the issue.

/opt/puppetlabs/puppet/bin/gem install puppet-resource_api

This module can install the gems for you, but it's a bit of a catch-22 where you need to run environment isolation before you run puppet to install the gems. Installing the gems manually ahead of running environment isolation works.