Environment-based testing
Sections
An environment-based testing workflow is an effective approach for testing new code before pushing it to production.

- Root All Nodes node group.
-
All Environments parent node group. All environment node groups must be
children of this group. The Puppet environment
assigned to this group is the default Puppet
environment used for nodes without an assigned or matched default environment.
Tip: If this group doesn't exist, you should create it.
-
Environment node groups. Environment node groups are used to specify the
Puppet environment that nodes belong to.
Nodes can belong to no more than one environment node group. The group it
belongs to determines its default environment.
Each environment node group must meet these conditions:
- Must be a direct child of the All Environments node group
- Must not include child groups, except any one-time run exception subgroups used for canary testing
- Must be specified as an environment group in the group metadata
- Must not include classes or configuration data
- Optional one-time run exception group. This group acts as a gatekeeper, and when present, permits nodes in the parent environment group to temporarily use Puppet environments other than their normal default environment.
- PE Infrastructure node group and its children. These are built-in classification node groups used to manage infrastructure nodes. Don't modify these groups except when following official documentation or support instructions.
-
Classification node groups. Classification node groups are used to apply
classes and configuration data to nodes. Nodes can match more than one
classification node group.
Each classification node group must meet these conditions:
- Must be a child of All Nodes or another classification group
- Must not be specified as an environment group in the group metadata
Test and promote a parameter
Test and promote a parameter when using an environment-based testing workflow.
- Create a classification node group with the test environment that is a child of a classification group that uses the production environment.
- In the child group, set a test parameter. The test parameter overrides the value set by the parent group using the production environment.
- If you're satisfied with your test results, manually change the parameter in the parent group.
- Delete the child test group.
Test and promote a class
Test and promote a class when using an environment-based testing workflow.
Test code with canary nodes and alternate Puppet environments
You can test new code using one-time Puppet agent runs on select canary nodes.
To enable the canary workflow, configure a one-time run exception child group for each environment group in which you want to test code. This group matches nodes on the fly when you run Puppet with the environment specified.
In this example, we configure a one-time run exception environment group as a child of the Development environment. You can create a similar group for any environment.
Sample rules for one-time run exception groups
These examples show several ways to configure rules for one-time run exception child groups. Where multiple rules are listed, combine the rules by specifying that nodes must match all rules.
Testing scenario | Fact | Operator | Value |
---|---|---|---|
Permit any node in the parent environment group to use any Puppet environment | agent_specified_environment | ~ | .+ |
Permit RHEL nodes in the parent environment group to use any Puppet environment | agent_specified_environment | ~ | .+ |
facts.os.family | = | RedHat | |
Permit any nodes in the parent environment group to use any Puppet environment except production | agent_specified_environment | ~ | .+ |
agent_specified_environment | != | production | |
Permit any nodes in the parent environment group to use any Puppet environment that begins with the prefix "feature_ | agent_specified_environment | ~ | ^feature_.+ |