Importing puppet classes/forge

Problem:
Trying to import puppet forge module “powershell”
Installed fine
(import environments from theforeman) doesn’t show installed module
tried ** foreman-rake puppet:import:puppet_classes** doesn’t show installed module
conf module shows “/opt/puppetlabs/puppet/modules” which has module installed
Expected outcome:
able to import an shows in classes

Foreman and Proxy versions:
1.24
Foreman and Proxy plugin versions:
1.24
Other relevant data:
[e.g. logs from Foreman and/or the Proxy, modified templates, commands issued, etc]
(for logs, surround with three back-ticks to get proper formatting, e.g.)

logs
1 Like

The foreman-rake puppet:import:puppet_classes task is deprecated and the current way is to call it via the smart proxy. There’s actually a PR to drop the code:

https://github.com/theforeman/foreman/pull/7080

calling it via the smart proxy doesn’t seem to work either message which comes up is "no change in environment "

The smart proxy queries the Puppetserver’s API. If that can’t find it, the Puppet agents can’t find it either.

I’d have a look at sudo puppet config print basemodulepath and the puppetserver logs. It’d also be useful to know the puppetserver version.

prints out
/home/dptc/.puppetlabs/etc/code/modules:/opt/puppetlabs/puppet/modules

which puppetserver log do i need to look at beacuse /var/log/puppetlabs/puppetserver/puppetserver.log
Doesn’t show any errors or any issues.

One common thing is that people clone a puppet-$module without renaming the directory to $module. Does /opt/puppetlabs/puppet/modules/powershell actually exist?

yes it does, sorry what do you mean by "renaming "

If you simply do git clone .../puppet-powershell, it ends up as /opt/puppetlabs/puppet/modules/puppet-powershell which Puppet refuses to load.

In general I’d recommend tools like r10k or librarian-puppet to deploy modules because they’re much more aware of how things are supposed to be deployed.

Another problem might be that you simply don’t have any environments (like production) so it doesn’t find any classes either.

i used :
puppet module install puppetlabs-powershell --version 2.3.0
which installed it into:
> /home/dptc/.puppetlabs/etc/code/modules
> └── puppetlabs-powershell (v2.3.0)
then i coped it to
/opt/puppetlabs/puppet/modules
└── puppetlabs-powershell (v2.3.0)
environments are set-up
also puppet version is
Puppet v5.5.16

What does ls -l opt/puppetlabs/puppet/modules show? I’m also surprised that your basemodulepath includes /home/dpc which suggests it wasn’t ran as root. That does influence the result and why I included sudo in the command.

total 4
drwxr-xr-x 5 root root 4096 Oct  8 16:22 powershell

running anything under sudo for puppet bring back a error message sudo: puppet: command not found

You might want to use sudo -i to execute the /etc/profile.d/puppet-agent.sh file which sets up the path first.

I’ve ran this and it seems to have set-up the path:

result is:
ls -l /opt/puppetlabs/puppet/modules
total 0

i coped the modules to all the places where the config file is looking for modules and it still doesn’t pick it up

installed librarian-puppet which works but the foreman still doesn’t pick up classes

installed r10k trying to create global config file

I don’t have time to write it all out, but I’d start with debugging the services. That means you can directly look at what the smart-proxy API returns. You can also go deeper and directly look at the Puppetserver API. I’d start with the latter and use https://puppet.com/docs/puppetserver/6.3/http_api_index.html#environment-endpoints. In particular https://puppet.com/docs/puppetserver/6.3/puppet-api/v3/environment_classes.html#get-puppetv3environmentclassesenvironmentenvironment is what the smart-proxy queries.

OK will try this now