Scope

A scope is a specific area of code that is partially isolated from other areas of code.

Scopes limit the reach of:

Scopes do not limit the reach of:

Diagram showing areas that represent scopes. Top scope contains
            node scope, which in turn contains three local scopes, called example::parent, example::other, and example::four. The example::parent class scope contains a class
            scope called example::child. The relationships formed by these scopes is described in the
            following text.

A particular scope has access to its own contents, and also receives additional contents from its parent scope, node scope, and top scope. The rules for how Puppet determines a local scope’s parent are described in scope lookup rules.

In the diagram above:

  • Top scope can access variables and defaults only from its own scope.

  • Node scope can access variables and defaults from its own scope and top scope.

  • Each of the example::parent, example::other, and example::four classes can access variables and defaults from their own scope, node scope, and top scope.

  • The example::child class can access variables and defaults from its own scope, the example::parent scope, node scope, and top scope.

Sections