Use One Class in Another Class (Newbie)

12 views
Skip to first unread message

Blank Reg

unread,
Jul 15, 2015, 7:12:43 AM7/15/15
to puppet...@googlegroups.com
Hi,

I have written a class module that sets up the users, groups and security for each client.
I would like to use the saz/ssh module to set

PermitRootLogin

to

without-password

on every server. This is a SSH server configuration.

How do I do it? Do I have to subclass the ssh class with my class? I really just want to treat the SSH setting as a type that I just set in my class. I've read the docs but I'm really stuck on the syntax for using a class in another class.

Reg.


jcbollinger

unread,
Jul 15, 2015, 9:16:50 AM7/15/15
to puppet...@googlegroups.com


On Wednesday, July 15, 2015 at 6:12:43 AM UTC-5, Blank Reg wrote:
Hi,

I have written a class module that sets up the users, groups and security for each client.
I would like to use the saz/ssh module to set

PermitRootLogin

to

without-password

on every server. This is a SSH server configuration.

How do I do it? Do I have to subclass the ssh class with my class?


No.  Class inheritance in Puppet doesn't do what you probably think it does, and the appropriate uses for it are very few.

 
I really just want to treat the SSH setting as a type that I just set in my class. I've read the docs but I'm really stuck on the syntax for using a class in another class.


There are two main DSL syntax options for using a class, and both are available anywhere you want to use them in a manifest: in a class body, in a defined type body, in a node block, or at top level (but don't put them at top level until and unless you fully understand all the implications).  You should avoid the "resource-like" syntax unless you have good reason, and there's pretty much no good reason for a manifest belonging to one module to use resource-like syntax to declare a class from a different module.

Include-like syntax means one of these:

include 'ssh'

or

require 'ssh'

or

contain 'ssh'

.  Almost certainly the first of those is best for this particular case.  Use automated data binding to assign the needed parameter values to the classes you declare this way.


John

Reply all
Reply to author
Forward
0 new messages