0

How many different init.pp can be there? Let's say if I have 10 different manifests that will do different jobs across the servers, should I define all the classes in one init.pp?

If the answer is yes, won't it get confusing once too many information are inside the single init.pp?

James
  • 193
  • 2
  • 4
  • 15

1 Answers1

3

No, you can add different modules in different directories and have separate init.pp's there.

Examples:

apache2/manifests/init.pp:

class apache2  {
   do some stuff;
}

postfix/manifests/init.pp:

class postfix {
   do other stuff;
}

my_mail_and_web_server/manifests/init.pp:

class my_mail_and_web_server {
    class { 'apache2':; }
    class { 'postfix':; }
}

manifests/site.pp:

node 'mailandweb.mycompany.com' {
    class { 'my_mail_and_web_server':; }
}

See https://docs.puppetlabs.com/puppet/latest/reference/modules_fundamentals.html for more details on how to structure your modules.

favoretti
  • 29,299
  • 4
  • 48
  • 61