You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Chef kitchen.local.yml属性移除后仍生效缓存问题求助

Troubleshooting Persistent Attribute Issues with kitchen.local.yml in Chef Test Kitchen

Let’s break down what’s happening here and walk through practical fixes to get your attributes behaving as expected:

Why This Happens

When you remove an overridden attribute from kitchen.local.yml, Test Kitchen might still cling to old values for two key reasons:

  1. Unclean test VMs: If you’re reusing existing VMs (via kitchen converge instead of rebuilding from scratch), old attribute data can linger in the VM’s filesystem or Chef’s local cache.
  2. Local Test Kitchen cache: The .kitchen directory in your project stores state, merged configurations, and temporary files from previous runs—this can hold onto old attribute values even after you edit your YAML files.

Step-by-Step Fixes

1. Fully Destroy and Rebuild Your Test VMs

Partial updates won’t clear out stale attribute data. Start fresh by wiping all existing test instances:

# Destroy all test VMs (the -a flag targets all platforms/nodes)
kitchen destroy -a

Then rebuild the environment from scratch:

kitchen converge

This ensures the VM starts with no leftover files or cached Chef data.

2. Clear Test Kitchen’s Local Cache

The .kitchen directory is often the hidden culprit for "stuck" configurations. Delete it to force Test Kitchen to regenerate all configs from your latest files:

rm -rf .kitchen

After deletion, run kitchen converge again—this will pull in your updated kitchen.yml and default attributes from attributes/*.rb.

3. Verify Attribute Loading Priority

Double-check that no other config is overriding your default attributes. Chef’s attribute priority (from highest to lowest) is:

  • kitchen.local.yml > kitchen.yml
  • Environment attributes
  • Role attributes
  • Cookbook default attributes (attributes/*.rb)
    If kitchen.yml itself has the FOOO attribute set, removing it from kitchen.local.yml will still use the kitchen.yml value, not the cookbook default. Make sure kitchen.yml doesn’t have a leftover entry for FOOO.

4. Clean Up Leftover Files in the VM

If you still see the FOOO value in /tmp on the VM, it’s likely a leftover from a previous Chef run. The kitchen destroy step should handle this, but if you manually kept the VM, you can clean it directly:

# SSH into the VM
kitchen login
# Delete Chef cache and tmp files linked to FOOO
rm -rf /var/chef/cache /tmp/*FOOO*
exit

Then run kitchen converge again to apply fresh configurations.

5. Debug with Verbose Logs

To track exactly where the FOOO attribute is coming from, run Test Kitchen with debug logging:

kitchen converge -l debug

Look for lines related to attribute loading—this will show you which file or config is setting the value, helping you catch any hidden overrides.

Final Check

After completing these steps, your test environment should respect the removal of the overridden attribute and fall back to the default values in attributes/*.rb.

内容的提问来源于stack exchange,提问作者Ondra Žižka

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:03:58