Test code with canary nodes and alternate Puppet environments
You can test new code using one-time Puppet agent runs on specific canary nodes.
You must Create environment node groups other than All Environments in which to test code, such as
development
or test
environment node groups.To enable the canary workflow, create a one-time run exception child group under each environment node group in which you want to test code. This group matches nodes on the fly when you run Puppet with the environment specified.
For example, the following steps create a one-time run exception environment group as a child of the Development environment node group. You can create a similar group for any environment you want to test.
- In the console, click Node groups, and click Add group.
- Create the one-time run exception environment node group with
these options:
- Name: <ENVIRONMENT> one-time run exception, such as Development one-time run exception
- Parent: Whichever environment you are testing, such as the Development environment
- Environment: Select agent-specified
- Environment group: Select this option.
- Click Add.
- Dynamically add nodes to a node group by creating a rule to
match nodes to this group if they request a Puppet environment other than their default environment:
- Fact:
agent_specified_environmentThis fact name doesn't autocomplete. You must manually type it.
- Operator: ~
- Value: .+
This rule matches any node from the parent environment node group that requests to use a non-default environment, through either the
--environment
flag on the command line or theenvironment
setting inpuppet.conf
. For other rules you might use, refer to Sample rules for one-time run exception groups. - Fact:
agent_specified_environment
- On any node in the parent environment node group (such as the
Development environment group), run the following
code:
puppet agent -t --environment <ENVNAME>
<ENVNAME>
is the name of the Puppet environment that contains your test code. If you're using Code Manager and a Git workflow,<ENVNAME>
is the name of your Git development or feature branch.During this Puppet run, the agent sets the
agent_specified_environment
value to<ENVNAME>
. The one-time run exception group's rule matches the node, and permits it to use the requested environment.