Ask Your Question
0

Class init.pp not working

asked 2016-03-22 22:36:09 -0500

anfield gravatar image

updated 2016-03-22 22:50:05 -0500

Created a module called addusers. Inside the init.pp file (inside manifests) I have created a class called mitchell.pp When I run the apply there are no errors but it does nothing. What am i missing?

init.pp contains -

 class users {
        user {'mitchell':
                ensure => present,
                uid => '1009',
                gid => '1000',
                shell => '/bin/bash',
                home => '/home/mitchell'
        }
}
edit retag flag offensive close merge delete

Comments

Only works If I remove the first line - class users { and the corresponding end bracket -> }

anfield gravatar imageanfield ( 2016-03-22 22:48:56 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted
2

answered 2016-03-22 22:54:53 -0500

You're not including (declaring) the class anywhere; you're only defining it. It's a bit like defining a function in shell, and then not actually calling it.

You could have it defined and included by adding a line at the end:

include users

Don't do that though. You'll be best served by learning more about Puppet module fundamentals. In practice, you'll hopefully end up writing a special class called a profile to include your user class somewhere.

edit flag offensive delete link more

Comments

Ok..when I dropped the brackets from the tests directory init.pp and just had include users, it worked fine. Thanks

anfield gravatar imageanfield ( 2016-03-23 08:32:49 -0500 )edit

You're welcome. Could you mark the issue as resolved then? Thanks

Alex Harvey gravatar imageAlex Harvey ( 2016-03-23 09:40:48 -0500 )edit
0

answered 2016-03-23 08:27:53 -0500

anfield gravatar image

Hi. So I could do what you stated above or I could add something in my tests directory? I tried - include classusers {} or class addusers { } in my init.pp inside the tests directory, neither of these worked. (All this was done on the master.

Thanks

edit flag offensive delete link more
0

answered 2016-03-25 17:23:30 -0500

kalyan gravatar image

The class name should be your module name

for init.pp (addusers/manifests/init.pp)

class addusers {

rest of the code here

}

suppose if you had mitchell.pp (addusers/manifests/mitchell.pp)

class addusers::mitchell {

Rest of the code here

}

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-03-22 22:36:09 -0500

Seen: 120 times

Last updated: Mar 23 '16