Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

384
Visualizações
Puppet can't find the module that I just installed

The problem that I found is that I can install Puppet modules successfully. For example:

[puppet@swarmcritic ~]$ puppet module install puppetlabs/mysql
Notice: Preparing to install into /home/puppet/.puppet/modules ...
Notice: Created target directory /home/puppet/.puppet/modules
Notice: Downloading from https://forge.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/home/puppet/.puppet/modules
└─┬ puppetlabs-mysql (v2.1.0)
  └── puppetlabs-stdlib (v4.1.0)

But when I try to invoke a module using a nodes.pp file like this:

 node 'example.com' {
    include '::mysql::server'
 }

Then I get an error like this:

[puppet@example mysql]$ sudo puppet apply ~puppet/puppet/manifests/site.pp
Error: Could not find class ::mysql::server for example.com on node example.com
Error: Could not find class ::mysql::server for example.com on node example.com

How can I fix it?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Puppet was installing the module in the .puppet directory tree of my home directory, but was not looking there when it came time to look for the module! Instead, it was ONLY looking in /etc/puppet/modules. It seems that, by default, it only looks there. If you want it to look in ~myusername/.puppet, you have to configure a path variable in /etc/puppet/puppet.conf or something.

To solve the problem, I didn't try to figure out how to modify the Puppet path. Instead, I installed the module explicitly into /etc/puppet/modules using the following command:

sudo puppet module install -i /etc/puppet/modules puppetlabs/mysql

Once this was done, the puppet apply command worked fine.

Further experimentation revealed that if you execute the Puppet module install command with no -i argument and root access, it will install the module into /etc/puppet/modules, but if you don't have root access, it will install it into ~myusername/.puppet/modules/. So if I had put a sudo in front of my original module installation command like this:

sudo puppet module install puppetlabs/mysql

then there wouldn't have been any problem. You don't have to specify the -i argument!

The entire problem arose because I chose to create a user account to hold all the puppet stuff rather than working in the root account. If I had worked in the root account, Puppet would (presumably) have installed the module into /etc/puppet/modules and there would have been no problem. It's only because I created a user account and then invoked the puppet module install command without sudo that the modules ended up in ~myusername/.puppet. Being a puppet novice, having modules installed in ~myusername/.puppet didn't seem like a bad idea. It seemed like a sensible place for the modules to be installed, particularly if one has created a user account to manage Puppet.

All this shouldn't put you off creating a user account to hold all your puppet configuration files. But if you do, remember to put sudo at the front of the installation command when you install modules.

Posted on behalf of the OP.

over 4 years ago · Santiago Trujillo Relatório

0

It is worth noting that the modulepath can be found as follows :

# puppet config print modulepath
/etc/puppetlabs/puppet/modules:/opt/puppet/share/puppet/modules

More information can be found here ...

https://puppetlabs.com/learn/autoloading

over 4 years ago · Santiago Trujillo Relatório

0

it depends on which version of puppet you are using:

in older versions (3.6 or older), you can add the modulepath variable to you puppet conf (at /etc/puppet/puppet.conf) after applying the change run puppet module list on the master to confirm puppet recognises the change.

in newer versions you are suppose to create a puppet environment (under /etc/puppet up to puppet 4.0 or /etc/puppetlabs/code for puppet 4.0 and above) and include the module path in the environment.conf. you can use the same command (puppet module list) to make sure the modules are installed correctly.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda