inline classes

10 views
Skip to first unread message

Ligne Six

unread,
Feb 15, 2017, 3:41:29 PM2/15/17
to Puppet Users
Hello folks,

I'm wondering if it is possible to define-declare a class. Something like inlining:

instead of:

```
include hello_distro                                                                                                                                                                                                                         
                                                                                                                                                                                                                                              
class hello_distro {                                                                                                                                                                                                                         
     notify { "Running on distro: ${facts['os']['family']}": }                                                                                                                                                                                
 } 
```

have something like:

```
include class hello_distro {
...

Thanks

jcbollinger

unread,
Feb 16, 2017, 10:35:12 AM2/16/17
to Puppet Users
No, Puppet has no such feature per se, but I don't see what advantage you hope it would provide, relative to simply declaring the contents of the class body directly at the same point.

Moreover, if you're inclined to declare a class in the same manifest in which you define it -- which runs counter to the prevailing views on good style -- I don't see how being able to merge those into a single statement would provide more than the most trivial advantage.  You would save yourself literally one word of code by not repeating the class name.


John



John

Reply all
Reply to author
Forward
0 new messages