Ask Your Question
0

Could not find class india for puppetmaster

asked 2015-04-18 08:40:30 -0500

Bharatkumar gravatar image

updated 2015-04-18 15:34:42 -0500

GregLarkin gravatar image

I created a module named as bharath as below..

[root@puppetmaster modules]# pwd
/etc/puppetlabs/puppet/modules
[root@puppetmaster modules]# ls -lrth
total 8.0K
drwxr-xr-x 6 root root 4.0K Apr 18 08:01 motd
drwxr-xr-x 6 root root 4.0K Apr 18 13:09 bharath
[root@puppetmaster modules]#

[root@puppetmaster modules]# cd bharath/
[root@puppetmaster bharath]# ls -lrt
total 16
drwxr-xr-x 2 root root 4096 Apr 18 12:59 templates
drwxr-xr-x 2 root root 4096 Apr 18 13:10 files
drwxr-xr-x 2 root root 4096 Apr 18 13:15 manifests
drwxr-xr-x 2 root root 4096 Apr 18 13:16 tests

[root@puppetmaster bharath]# cat manifests/init.pp files/india1 tests/init.pp
class india
{
file { '/root/india1':
ensure => 'file',
source => 'puppet:///modules/bharath/india1',
}
}

india is grat country --> files/india1 content


include india --> tests/init.pp content

But still i am getting error as below..eventhough i added class india in site.pp node classification directive as well.

cd tests

[root@puppetmaster tests]# puppet apply --noop init.pp
Error: Could not find class india for puppetmaster.bharathkumarraju.com on node puppetmaster.bharathkumarraju.com
Error: Could not find class india for puppetmaster.bharathkumarraju.com on node puppetmaster.bharathkumarraju.com
[root@puppetmaster tests]#
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-04-18 15:35:42 -0500

GregLarkin gravatar image

Read this document very closely, and you will find your answer: https://docs.puppetlabs.com/puppet/latest/reference/modules_fundamentals.html#module-layout

edit flag offensive delete link more
0

answered 2015-04-19 00:14:13 -0500

Bharatkumar gravatar image

updated 2015-04-19 11:07:24 -0500

GregLarkin gravatar image

it is got solved . i think at-least one class name should be same as module name. now see my init.pp

[root@puppetmaster bharath]# pwd
/etc/puppetlabs/puppet/modules/bharath
[root@puppetmaster bharath]#

[root@puppetmaster bharath]# cat manifests/init.pp files/india1 files/india2 tests/init.pp
class bharath
{
file { '/root/india1':

ensure => 'file',
source => 'puppet:///modules/bharath/india1',
}
}

class amma
{
file {'/root/india2':
ensure => 'file',
source => 'puppet:///modules/bharath/india2',
}
}

india is grat country --> content of files/india1

hi ------> content of files/india2
india
hello
proud to be indain

include bharath ---> content of tests/init.pp 
include amma
[root@puppetmaster bharath]#

[root@puppetmaster tests]# pwd
/etc/puppetlabs/puppet/modules/bharath/tests
[root@puppetmaster tests]#

[root@puppetmaster tests]# puppet apply init.pp
Notice: Compiled catalog for puppetmaster.bharathkumarraju.com in environment production in 0.34 seconds
Notice: Finished catalog run in 0.43 seconds
[root@puppetmaster tests]# hostname
puppetmaster.bharathkumarraju.com
[root@puppetmaster tests]# cat /root/india1 /root/india2
india is grat country

hi
india
hello
proud to be indain

[root@puppetmaster tests]#
edit flag offensive delete link more

Comments

Ok, the only change I would make is to place only one class in one .pp file. So move "class amma" to amma.pp, and rename the class to "class bharath::amma". That's the correct module naming convention/layout. Otherwise, it looks fine.

GregLarkin gravatar imageGregLarkin ( 2015-04-19 11:10:29 -0500 )edit

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: 2015-04-18 08:40:30 -0500

Seen: 498 times

Last updated: Apr 19 '15