I'd like to use the environments feature of Puppet in my.. environments. We differentiate between environments via hostname, e.g. prod-web1, stg-web1. I know I can use regex to match these in a single environment, but I'd rather use the actual environments functionality to allow module updates to be propagated through each environment.
From my understanding there are two ways to do this, and both ways have some problems;
-I can set the environment variable in the puppet agent's config. This requires interacting with each host. Obviously this could be trivially managed with Puppet, but the first run will apply the default production configs, and I'd really prefer if it didn't.
-I can define the environment variable when running the agent, but I would need to stick the agent in cron to specify that, and I'd lose the benefits of puppet's built-in splay.
How can I peg a box to an environment based upon its hostname?