This page is READ-ONLY. It is generated from the old site.
All timestamps are relative to 2013 (when this page is generated).
If you are looking for TeX support, please go to

Puppet: Define a resource type

Added by ruby 11 months ago  »  Votes: 1/1

I didn't see stuff in Puppet documentation. I asked on #puppet. I did many tests, and this is the final thing: To define a resource type cphp::fpm::create_env, you need


You don't need init.php in the directory fpm. The contents of create_env.pp is as below

1 define cphp::php::create_env($param} {
2   # your definition
3 }

Note 1

To use this resource type, you have to do nothing. All you need is to include the module cphp, you don't have to include cphp::fpm nor cphp::fpm::create_env. Weird, !? As you know that cphp was defined (but you have to use include cphp), you don't know if cphp:php was defined. There aren't any explicit declaration for that. (Maybe they come from the directory structure.)

You must use include <class> when you really want to use it, and when you want to use a resource type, you just need to specify its name. Why difference here? include <class> doesn't really mean include, it really means execute the class (or evaluate the class as you can read in the Puppet source code.) I really wonder why Puppet doesn't just support include <resource type>, or <class_name> as evaluation method. That helps the language cleaner

use cphp
use cphp::fpm::create_env

If Puppet tries to emphasize that you can only include a class once, Puppet can try this

use_once cphp
use cphp::fpm::create_env

(Something similar to require_once in php.)

Note 2

When you try to invoke a resource type as a function, Puppet complains that there isn't such function. Woh. This completely leads you to another wrong way when debugging. Puppet should complain that you did use a resource type as a function, IMHO.

Another note

If you invoke the resource type cphp::fpm::create_env in another module, Puppet will complain that the $fqdn isn't defined in the scope. Gruh. This is completely stupid =))


Puppet is messy, again.

PS: Puppet mentioned here has version 2.7.12.