# Chef\_environment

**URL:** <https://discourse.chef.io/t/chef-environment/24252>\
**Category:** Chef Workstation\
**Created:** [September 2, 2025, 4:20pm UTC](https://discourse.chef.io/t/chef-environment/24252 "2025-09-02T16:20:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![charr](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@charr](https://discourse.chef.io/u/charr)\
**Post date:** [September 2, 2025, 4:20pm UTC](https://discourse.chef.io/t/chef-environment/24252/1 "2025-09-02T16:20:24Z")

</div>

I am looking for a way to override the node.chef\_environment either with a kitchen.yml or a policy file.

The backstory is we have cookbooks written for the old role base instead of policy files. These cookbooks have items in them looking for certain chef\_environment and branch code off of them. In lieu of changing the code, I was looking for a way to test them in test kitchen. It appears test kitchen, when using a policy file sets the chef\_environment to “local” which is fine, we can code to handle that but were seeing if there was a more elegant way to set it to say “dev” at the kitchen or policy level for testing.

---

<div class="post-metadata">

**Author:** ![Stromweld](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/stromweld/32/3416_2.png) [@Stromweld](https://discourse.chef.io/u/Stromweld)\
**Post date:** [September 2, 2025, 5:10pm UTC](https://discourse.chef.io/t/chef-environment/24252/2 "2025-09-02T17:10:18Z")

</div>

You can set the client.rb to use a specific environment as described here [Chef Infra](https://kitchen.ci/docs/provisioners/chef/) . otherwise the node.environment should be set to the policy\_group in test-kitchen environment or policy\_group both get set to `local`.

---

<div class="post-metadata">

**Author:** ![charr](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@charr](https://discourse.chef.io/u/charr)\
**Post date:** [September 2, 2025, 7:10pm UTC](https://discourse.chef.io/t/chef-environment/24252/3 "2025-09-02T19:10:16Z")

</div>

I saw that setting, but it says it requires an environments\_path, but I haven’t found documentation on what that requires.

---

<div class="post-metadata">

**Author:** ![charr](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@charr](https://discourse.chef.io/u/charr)\
**Post date:** [September 2, 2025, 7:21pm UTC](https://discourse.chef.io/t/chef-environment/24252/4 "2025-09-02T19:21:03Z")

</div>

When I try to configure it with the client\_rb I get the following error:

`Running handlers:`  
`[2025-09-02T19:18:10+00:00] ERROR: Running exception handlers`  
`Running handlers complete`  
`[2025-09-02T19:18:10+00:00] ERROR: Exception handlers complete`  
`Infra Phase failed. 0 resources updated in 00 seconds`  
`[2025-09-02T19:18:10+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out`  
`[2025-09-02T19:18:10+00:00] FATAL: ---------------------------------------------------------------------------------------`  
`[2025-09-02T19:18:10+00:00] FATAL: PLEASE PROVIDE THE CONTENTS OF THE stacktrace.out FILE (above) IF YOU FILE A BUG REPORT`  
`[2025-09-02T19:18:10+00:00] FATAL: ---------------------------------------------------------------------------------------`  
`[2025-09-02T19:18:10+00:00] FATAL: Chef::PolicyBuilder::Policyfile::UnsupportedFeature: Policyfile does not work with an Environment configured.`

---

<div class="post-metadata">

**Author:** ![decoyjoe](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/decoyjoe/32/4557_2.png) [@decoyjoe](https://discourse.chef.io/u/decoyjoe)\
**Post date:** [September 3, 2025, 5:15pm UTC](https://discourse.chef.io/t/chef-environment/24252/5 "2025-09-03T17:15:12Z")

</div>

Set the `provisioner.policy_group` property in the `kitchen.yml` file, like so:

```yaml
provisioner:
  policy_group: kitchen

```

That will set both `node.policy_group` and `node.chef_environment` to `kitchen` during your Test Kitchen converge.

For example, the following Test Kitchen recipe:

```ruby
# recipes/default.rb

log "node.policy_group: #{node.policy_group}"
log "node.chef_environment: #{node.chef_environment}"

```

Will log:

```auto
[2025-09-03T16:50:25+00:00] INFO: node.policy_group: kitchen
[2025-09-03T16:50:25+00:00] INFO: node.chef_environment: kitchen

```

---

<div class="post-metadata">

**Author:** ![charr](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@charr](https://discourse.chef.io/u/charr)\
**Post date:** [September 3, 2025, 7:24pm UTC](https://discourse.chef.io/t/chef-environment/24252/6 "2025-09-03T19:24:12Z")

</div>

@decoyjoe Thank you, that is what I needed!
