Search code examples
chef-infraaudit

Referencing node attributes from Chef Audit Control Group


I'm trying to find out if there is a way to reference my node attributes in a Chef Control Group when running in audit mode. As an example, I have a particular recipe that references an attribute for my http(s) proxy and I need to make sure the proxy server is set correctly via my audit.

So, I want to check the contents of my proxy config file and make sure it has the appropriate proxy server in the file. But I currently can't verify this because the audit mode doesn't seem to recognize when I reference:

node['default']['proxy_server']

or

"#{node['default']['proxy_server']}"

Is it just not possible to reference attributes in audit mode? Or is there just a super-secret syntax that I am unaware of? Thanks!!


Solution

  • You should be able to cram node attrs in to global variables or similar and access them from inside the audit controls. Not recommended though since 1) that kind of defeats the point of testing if you are using the same parameters for both the code and the test and 2) it isn't possible with newer InSpec-based tools like the audit cookbook or Compliance.