Wiki

Foreman acts as an external node classifier (ENC) for Puppet, which allows it to pass a list of classes, global and class parameters. It isn't able to instantiate individual resources (such as a file or package), or a defined type through this interface.

If the resources you're managing are simple and all have the same properties and parameters, you can use Puppet's array resource declaration syntax (array of title docs) to create many resources at once.

In this example to install a list of packages, we create /etc/puppet/environments/production/modules/packages/manifests/init.pp with:

When you import this "packages" class, it will have a "list" parameter. In Foreman's UI, go to Configure, Puppet classes, "packages", Smart class parameters and tick the Override checkbox on the "list" parameter. Set the Parameter type to json and use JSON syntax to set the list parameter to an array of values, e.g.

["httpd","vim"]

You can then override this per host or host group and supply a new array.

Note that the keys of the first level of the hash are the names of the resources (what usually goes after the resource type on the first list), and then the values are a full hash of the properties and parameters of the resource. You'll need to supply them all (type documentation).

Also important is that JSON hashes do not have the same syntax as Puppet. JSON uses colons (":") as key/value separators, while Puppet uses "=>". Foreman will give a parse error if you try using "=>"!

Foreman can store complex parameters using YAML or JSON, here's a YAML example which may be easier to read and work with:

Using create_resources means all resource properties/params need to be passed in. When they're often the same, or you have multiple resources to instantiate, it's usually simpler to wrap it all in a defined type and then instantiate that. Here's an example to manage services: