Ask Your Question
0

How to apply puppet code on agent ??? which command should we use on puppet agent.Below is the our module and class file which should be enforced on agent

asked 2016-07-23 08:02:53 -0500

KALPESH gravatar image

updated 2016-07-23 16:02:06 -0500

lupin gravatar image

[root@puppet Desktop]# cd /etc/puppet/modules/my_modules/manifest/

[root@puppet manifest]# ls
init.pp  nrpe.pp 
[root@puppet manifest]# cat nrpe.pp 
class my_module::nrpe{
    package { [nagios-plugins, nrpe, nagios-plugins-all ]:
        ensure => installed,
            }
    service { nrpe:
        ensure => running,
        enable => true,
        require => Package[nrpe],
            }           
    file line{ "allowed hosts":
            line => "allowed hosts = 127.0.0.1,192.168.164.145",
            path => "/etc/nagios/nrpe.cfg",
            match => "allowed host,"
            ensure => present,
            notify => Service["nrpe"],
    }

}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-07-24 12:56:59 -0500

DarylW gravatar image

What you are trying to do is called 'masterless puppet'. There are lots of results if you search for that. Ultimatly, you only need a few things.

You can either create an individual manifest which has everything you need (the approach you currently have), or you can create a proper 'module' to perform the parts that you need performed. (see https://docs.puppet.com/guides/module...) Either way you need to have a manifest that calls your modules.

1) a manifest file that can apply your module (for your above, since you have everything hard coded into your my_module::nrpe would be 'include mymodule::nrpe' ) 1) A delivery mechanism to get your puppet code to your servers. puppet-librarian/r10k/git pull in a cron, NFS/shared drive

2) Properly configure your puppet environment to access the pulled in puppet code.. Your modules need to be properly added to your modulepath, and you either need to set up your puppet config to set the modulepath where your modules live, or specify it in your puppet command (puppet apply /manifests/path/nodes.pp --modulepath /path/to/your/modules/

3) a cron or some other scheduler to run your puppet apply command as frequently as you require.

If you need any additional help, feel free to reach out. It would be good to either create a proper module, work up from there, or possibly find a module from the forge that does what you require.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-07-23 08:02:53 -0500

Seen: 89 times

Last updated: Jul 24 '16