Project

General

Profile

Actions

Instantiate Puppet resources » History » Revision 1

Revision 1/6 | Next »
Dominic Cleal, 09/24/2014 09:15 AM


Instantiate Puppet resources

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.

Instead, you have a few possible approaches.

Creating a simple class or module

Resources should generally be kept in a class which can then be included where needed. For static resources, this is the best way.

Basic dynamic resources with arrays

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:

class packages($list = []) {
  package { $list:
    ensure => installed,
  }
}

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.

Updated by Dominic Cleal about 10 years ago · 6 revisions