I was trying to write a module for epel repo.
here is the content of that module.
[root# manifests]# cat init.pp
class epel {
file { "/etc/yum.repos.d/epel.repo":
ensure => "present",
mode => "400",
owner => "root",
group => "root",
source => "puppet://$puppetmaster/modules/yumrepos/files/epel.repo"
}
}
While applying this module to client side, I am getting following error.
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find class epel for
Please tell me where will be the error exists.
Thanks in adv
Sankar
The class epel will only be located if the init.pp file is in the epel module.
Make sure that
The file is in the manifests subdirectory
The epel tree (including manifests/) is in a module search directory of the current environment
There is no other epel module (this is pretty far fetched, though)
Note that you probably want to use the yumrepo type to manage repositories, instead of deploying prepared configuration files.
Related
Per the Docker documentation, the list of yum repositories are added by this command:
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
I'd like to have Puppet do this for me, so I was hoping this would work:
yumrepo { "docker":
descr => 'docker',
baseurl => 'https://download.docker.com/linux/centos/docker-ce.repo',
enabled => 1
}
But, this doesn't work.
Unfortunately, the URL used in the yum-config-manager contains an entire list of name/baseurl/enabled/gpgcheck/gpgkey entries, where the yumrepo is expecting just one of those. So, is there a way to add the entire list of entries in the docker URL with one yumrepo command, or some other command?
The URL in the Docker instructions is that of a .repo file to be installed on the system. The contents of such a file are what the properties of a Yumrepo resource describe. Applying a Yumrepo resource involves managing the contents of repository description files, not obtaining external files from somewhere else, whether via yum-config-manager or otherwise.
You have many options, but here are some of the more likely ones:
Obtain the specified file from docker.com, store it in your module's files directory, and install and manage it on target nodes via a File resource.
Install the repo file on some node that also has Puppet, and use the puppet resource command to obtain Puppet DSL representations of the Yumrepo resources that result. Put these into a suitable class on the master.
Or alternatively you can peak inside docker-ce.repo and write proper yumrepo config:
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
into:
yumrepo { 'docker-ce-stable':
name => 'Docker CE Stable',
baseurl => 'https://download.docker.com/linux/centos/$releasever/$basearch/stable',
enabled => 1,
gpgcheck => 1,
gpgkey => https://download.docker.com/linux/centos/gpg',
}
which looks straightforward and could be generated once from docker-ce.repo file via sed or other tools.
I'm trying to download a JAR file from a repo, but I'm getting the below error:
pget { 'Download 123 jar file':
source => 'url'
target => 'C:\download,
targetfilename => '123.jar',
require => File['E:\download'],
}
I'm getting the below error while executing the resource
Error: Evaluation Error: Error while evaluating a Resource Statement, Unknown resource type: 'pget'
Can anyone explain why I cannot use pget? Is there any other way to download the JAR file?
You either forgot to install the module that provides the pget type, or it was not installed correctly: https://forge.puppet.com/cyberious/pget
Install it either locally (using puppet apply) or on the master (using puppet agent) with:
puppet module install cyberious-pget
and then your resource will work.
I have set up Puppet master/agent in Oracle VirtualBox using Vagrant and installed netdev_stdlib on both master and agent according to instruction in the README.
I have set up module path to /etc/puppet/modules/netdev_stdlib where standard library stdlib also exists.
The master node is puppet.example.com and agent is node01.example.com.
My manifest file is as follows:
node default {
file { "/tmp/example_ip": ensure => present }
include stdlib # No error on this line
# include netdev_stdlib # Uncomment this line will cause error
netdev_device { $hostname: }
}
However, when I run puppet agent -t on the client I got
Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid
resource type netdev_device at /etc/puppet/manifests/site.pp:17 on node
node01.example.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
I tried to use include netdev_stdlib in the manifest file site.pp, but Puppet couldn't find the class netdev_stdlib. However, include stdlib is fine.
I tried to use include netdev_stdlib in manifest file site.pp but Puppet couldn't find the class netdev_stdlib, but include stdlib is fine.
The netdev_stdlib module doesn't provide a class that can simply be included. It's more of a programming framework for writing new Puppet types to manage network devices in Ruby.
You should either use the module to write a new network device module of your own for interfacing to some new type of device, per the README, or remove it and don't include the class.
If you're trying to manage a network device, you should look for an existing module that supports that type of device - it may then use this module as a dependency instead. If you're not managing a network device, I don't think you should be trying to use the module.
Note that most module READMEs will indicate class names that can be included; not all modules will contain Puppet classes.
Miss { in end of file type:
change from:
file { "/tmp/example_ip": ensure => present,
to
file { "/tmp/example_ip": ensure => present, }
I am starting using puppet to manage many servers, the problem is that whenever I try to use a class, new relic for example:
node 'mynode' {
class {'newrelic::server::linux':
newrelic_license_key => '***',
}
}
It fails, and returns the following error:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class newrelic::server::linux at /etc/puppet/manifests/site.pp:3 on node mynode
I have installed fsalum-newrelic on the master, and everything works fine when using files, packages, services etc. What am I doing wrong?
The catalog compiler will look for class newrelic::server::linux at newrelic/manifests/server/linux.pp relative to each directory in your module path. (Note: newrelic, NOT fsalum-newrelic.) Make certain that you indeed did install the module such that such a file exists in your modulepath, and make sure that it is readable by the puppetmaster process.
Note, too, that "readable by the puppetmaster process" means more than just the ownership and permissions of the file itself. It also involves ownership and permissions of all the directories in the path to that file, and possibly other forms of access control, such as ACLs and SELinux conext and policy.
Find out where you are actually installing the new puppet forge modules using perhaps a unix utility like "locate".
Then look in the the /etc/puppet/puppet.conf at the "basemodulepath" and check that the place it is installed is in the path
Here is my basemodulepath
basemodulepath = $confdir/environments/production/modules:$confdir/environments/production/local_modules:/etc/puppet/modules
The external modules I am using are either in /etc/puppet/modules or in /etc/puppet/enviroments/production/modules
i am using the example of iptraf on github
I do a git clone, and then sudo puppet apply init.pp
but i dont see iptraf installed on the ubuntu 11.04 host
now this puppet is a client ONLY instance, and NO Master.
from another example i see i can install apache2 as:
class basic_services {
##Get Apache
package { 'apache2':
ensure => 'installed',
}
##Edit the Apache Conf
file { "/etc/apache2/sites-available/default":
require => Package["apache2"],
owner => "root",
group => "root",
content => "$some_variables::apache_config",
}
##Make sure Apache is running, and restarts on changes to conf
service {'apache2':
require => Package["apache2"],
ensure => running,
subscribe => File["/etc/apache2/sites-available/default"],
}
}
so for iptraf:
init.pp
class iptraf {
include iptraf::base
}
base.pp
class iptraf::base {
package{'iptraf': ensure => installed }
}
I will use this example as a base to develop a manifest for Testing Tools
So what am i missing here , as after i run :
sudo puppet apply init.pp , and try to access iptraf, i get the message:
iptraf
The program 'iptraf' is currently not installed. You can install it by typing:
sudo apt-get install iptraf
in the directory:
/etc/puppet/modules/iptraf
- create a file:
iptraf.pp
- with contents:
package { "iptraf":
ensure => "installed"
}
- issue the command:
puppet apply iptraf.pp
/Stage[main]//Package[iptraf]/ensure: ensure changed 'purged' to 'present'
Finished catalog run in 2.71 seconds
run iptraf on command line , the UI POPS UP.
Done!
move the iptraf directory to the modules. Your directory structure should be this :
/etc/puppet/modules/iptraf/manifests/{init.pp,base.pp}
then do,
sudo puppet apply -e 'include iptraf'
that should install iptraf.
sudo iptraf should open a nice screen in your terminal :)