How do I run a Puppet Manifest on a Windows server with Puppet Agent? - linux

I have done it in the past. I don't know why I cannot do it this way below. I am using CentOS 7 for the Puppet Master server. I am using Windows Server 2012 with Puppet Agent.
All the content below was taken from the Puppet Master server. Here is site.pp (which is in /etc/puppet/manifests):
node 'fqdnOfWindowsServer' { import 'good.pp'}
node 'fqdnOfLinuxServer' {}
Here is good.pp (which is in /etc/puppet/manifests):
file { 'c:/fun.ps1':
ensure => 'present',
source => '/tmp/special.ps1',
source_permissions => 'ignore',
}
Here is what happens when I run puppet agent -t:
...Caching catalog for fqdnOfLinuxServer... Error: Failed to apply
catalog: Parameter path failed on File[c:/fun.ps1]: File paths must be
fully qualified, not 'c:/fun.ps1' at /etc/puppet/manifests/good.pp:5
How do I input a fully qualified path? It seems to be having a problem with a Windows server as the Puppet Agent. Paths are different from Linux Puppet Agents.

From what I can make of the error message, you're trying to create a Windows file resource on a Linux server (the error mentions caching catalog for fqdnOfLinuxServer). If that's the case, the error message makes sense because on Linux, the agent expects file paths to start with a forward slash.

Related

Puppet creating file on an agent

I'm running a puppet code that create a file with text, it's working when I'm running it locally (with puppet apply <.pp file> on the same machine) but not working when I'm running the code on an agent from a puppet master server (with puppet agent -t on the manifests directory) my code:
node default {
file { '/test544/newdirha1': #the path of the new file
ensure => 'present',
content => 'this is the content', #this text will be inside the file
owner => 'root',
group => 'root',
mode => '0644',
}
}
The problem is that the master does not read or process your manifest file at all.
Puppet 3.8 is obsolete and unsupported. The latest us Puppet 6.2, and since you're just getting going I recommend starting there. The expected layout and behavior of that and other more recent Puppet versions differ in some import and relevant ways, but in Puppet 3, the starting point for the master's processing is a single file, the "site manifest", which by default is /etc/puppet/manifests/site.pp.
Your master having neither a site manifest nor an external node classifier to rely upon, it will not assign any classes or resources to any node. It will generate only empty catalogs, which is exactly what you observe. Your manifest woot3.pp is ignored. The simplest and most direct way to solve the problem would be to rename woot3.pp to site.pp.

Puppet netdev_stdlib: How to fix "Invalid resource type netdev_device"?

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, }

Puppet error when using classes

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

Puppet ignores my node.pp entry

My Puppet master and agent are on the same machine. The master node.pp file contains this:
node 'pear.myserver.com' {
include ntp
}
The ntp.pp file contains this:
class ntp {
package { "ntp":
ensure => installed
}
service { "ntp":
ensure => running,
}
}
The /etc/hosts file contains the line:
96.124.119.41 pear.myserver.com pear
I was able to successfully launch puppetmaster, but when I execute this, ntp doesn't get installed (it is not installed already, I checked).
puppet agent --test --server='pear.myserver.com'
It just reports this:
info: Caching catalog for pear.myserver.com
info: Applying configuration version '1387782253'
notice: Finished catalog run in 0.01 seconds
I don't know what else I could have missed. Can you please help? Note that I replaced the actual server name with 'myserver' for security reasons.
I was following this tutorial: http://bitfieldconsulting.com/puppet-tutorial
$puppet agent --test
This will fetch compiled catalog from Master puppet, which is in /etc/puppetlabs/puppet/manifests/site.pp and run locally.
$puppet apply /etc/puppet/modules/ntp/manifests/ntp.pp
Will apply locally

Whats the best approach to create a repo of the installers to be used for installing and upgrading in the puppet managed nodes

Lets take the example, I am having a jboss-4.2.3 installers as a .tar file. In general to install jboss, i ll
1. untar the jboss-4.2.3 into a prefefined folder (opt/server/jbossas/) into multiple servers
2. untar the openjdk into a preferined path (/opt/software/java)set the path in the bash.profile
3. Create server profile in the place where jboss is installed
4. Start the server.
Lets say that I have to do this in 16 nodes (servers).
Now, I should store the jboss and openjdk installers at a central location and it should be transferred to the nodes before the 1st step can begin.
I wrote the manifest to perform the requirements form 1 to 4. But not sure how can I automate the transfer of the installers from a central repo. I am not worried about the type of central repo. It can be a ftp or puppet or anything else.
Please help me. I was going through filebucket. Will this help or should i write a manifest to get this file from a ftp server?
How to create a file repo which can be referred in puppet manifests?
I am not sure about your exact problem, but you can have a look at this and get an idea...
In most of the usage the files are transferred from the puppetmaster to the clients. If you have your policies defined in a module to untar and install the packages, e.g. module name jboss, you can keep the tarball in these kind of structure in the puppet master and run puppet agent from puppet client :
/etc/puppet/module/jboss/files/jboss_pkg.tar
Your policy for your clients should then say something like the following in the :
In e.g,
/etc/puppet/modules/jboss/manifests/init.pp
class jboss {
file { '/tmp/installation/jboss_pkg.tar' :
source => "puppet:///modules/jboss/jboss_pkg.tar",
}
#You can then right a small script that will execute all the installation process. You can use 'exec' in puppet to do that.
exec { 'install_jboss' :
command => "/path/to/install_jboss.sh",
require => File["/tmp/installation/jboss_pkg.tar"],
onlyif => "/check/that/it/is/not/installed/already",
}
## and write other execs to start the server or enable services etc...
}
# In site.pp
node 'client.mytest.org' {
include jboss
}
The general solution to provide installers to Puppet is to set up your own package repository (rather than just a file repo).
http://www.techrepublic.com/blog/opensource/create-your-own-yum-repository/609
Then, you can use Puppet's built in package resource for easy install/upgrade/uninstall
http://docs.puppetlabs.com/references/latest/type.html#package
The following projects seem to provide a rpm/deb version of JBoss that you can publish to your repository
https://github.com/floreal/jboss-deb-package
http://code.google.com/p/jboss-rpm/

Resources