Help on puppet (multiple class in single manifest)

16 views
Skip to first unread message

Alessandro Ciappei

unread,
May 9, 2018, 1:56:31 PM5/9/18
to Puppet Users
Hello all,

I'm new on puppet, and i try to create one deployment for my company by satellite 6 and puppet.
I would like to create a module, with single manifest, and inside multiple classes.
I need to choose each class separately, because will be installed in different server for same application

then i created module with 

puppet module generate 
i fill all metadata.json

Inside in manifest
i create init.pp and some other files called test-install.pp and test-config.pp

#init.pp

class test {

          include redis::install

          include redis::config

        }


#test-install


class redis::install inherits test{

 

                exec {

                "Disable Transparent Huge Pages":

                command => '/usr/bin/echo never > /sys/kernel/mm/transparent_hugepage/enabled',

                onlyif =>  '/usr/bin/test -f /sys/kernel/mm/transparent_hugepage/enabled',

                }

 

                package { ['redis','filebeat-5.3.2']:

                ensure   => present,

                provider => yum,

                #install_option => ['--enablerepo=R_EPEL_RHEL7_Yum']

                #source   => File['nameofrpm_rpm']['path'],

                #require  => File['nameofrpm_rpm'],

                }

        }


#test-config


class redis::config inherits test {

 

                exec {

               "Move FILEXXX to right path in PATHXXXX":

                command => '/usr/bin/mv /cs/ecommint/etc/systemd/system/*.service /etc/systemd/system/',

#               onlyif =>  "test -e /cs/ecommint/systemd/system/*.service",

#               require => File["/cs/eccomint/systemd/system/*service"]

                }

                exec {

                "Reload System Control Deamon":

                command => '/usr/bin/systemctl deamon-reload',

                }

        }




But it's not working


Some one can help me?

David Schmitt

unread,
May 10, 2018, 5:09:48 AM5/10/18
to puppet...@googlegroups.com
* "puppet module generate" is deprecated and does not provide you with the full set of tools and practices you could be using. Have a look at the PDK instead.

* All the classes in a module need to have the module name as base name. i.e. when your module is called "test", the classes need to be called "test::install", and "test::config". `pkd new class` does that automatically for you.

* Each class needs to go into its own file. e.g. the "test::config" class goes into "manifests/config.pp". Especially with bigger modules, this allows for a much better navigation in the source. Again, `pkd new class` does that automatically for you.

Cheers, David

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/f07dd07c-3fef-410d-99ad-0e7a0c310615%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Reply all
Reply to author
Forward
0 new messages