How to write Puppet Classes used by Smart class parameters from Foreman

Good evening,

iam relative new to Foreman and also to Puppet.

In the past i always write very simple puppet manifests and just apply
them. Now i want to use the "Smart class parameters" from Foreman for
example, setting the version of a software who will be installed. I play a
little bit with smart class parameters by some puppet forge modules, look a
bit at the code, but i still dont know how to write puppet classes who can
be used as Foreman Smart class parameters.

Are there some simple examples? Or what i must use from the puppet features
wich are interpreted as Smart class parameters?
i didn't see the forest for the trees :slight_smile:

Iam thanksful for any help and advice

best Regards

Hi anpk

> Good evening,
>
> iam relative new to Foreman and also to Puppet.

Welcome to the community!

> In the past i always write very simple puppet manifests and just apply
> them. Now i want to use the "Smart class parameters" from Foreman for
> example, setting the version of a software who will be installed. I play
> a little bit with smart class parameters by some puppet forge modules,
> look a bit at the code, but i still dont know how to write puppet
> classes who can be used as Foreman Smart class parameters.
>
> Are there some simple examples? Or what i must use from the puppet
> features wich are interpreted as Smart class parameters?
> i didn't see the forest for the trees :slight_smile:

We have some docs for this:

https://projects.theforeman.org/projects/foreman/wiki/Parameterized_class_support

It'll work for any Puppet class with parameters, so for example:

class test ($foo="bar") {
file { '/tmp/test.txt':
ensure => present,
content => $foo
}

This is a class that has one parameter, foo, and writes that parameter
to a file. If you put this in your modulepath, and Import classes into
Foreman, you'll be able to see the "test" class in the UI.

Once you can, edit the class, go to the "foo" parameter, and try setting
a default value, and assign the class to a host. It should pass the
value to Puppet (you can check on the hosts YAML page). After that, you
can try overriding the default at the Host level.

Here's a very old video walking through the process, it hasn't really
change much:

Hope it helps,
Greg

··· On 01/11/17 11:08, anpk wrote:
1 Like