Running chef in Audit mode & and getting values of parameters?

We need to run chef in “checking mode” first for our project - which is
either “why-run” or “audit-only” modes. We are inclined towards
"audit-only" mode because there is no “node save” at the end of "why run"
run.

So for the audit mode - we would like to get access to a number of
variables in the environment when the test fails. To this end, we
implemented an event handler that gets activated when audit failure
happens. The event we use is:
control_example_failure(control_group_name, example_data, error)

Here is the control group we are using for audit:
control_group “audit service running” do
control “ntp audit” do
it “should be running” do
newService = “ntp2” #Variables we defined.
stats = "ntpstats"
expect(service(“ntpd”)).to be_running
end
end
end

Here is what we found in the “example_data” structure:
{:name=>“should be running”,
:desc=>“audit service running ntp audit should be running”,
:resource_type=>nil, :resource_name=>nil,
:context=>[“ntp audit”],
:line_number=>14
}

Is there a way for us to access any of the internal variables like
"newService" and “stats” from the example_data, or any other way from
Audit results? As the output of audit - we would like to get values of
other relevant variables within the control group. Thank you.

regards,
Bhavna

i cant think of any clean way to pass local variables from control groups
to the event handler. You can use node.run_state or an external singleton
to store them and access from the event handler.
hth
ranjib

On Tue, Sep 8, 2015 at 7:52 AM, Bhavna Agrawal bhavna@us.ibm.com wrote:

We need to run chef in “checking mode” first for our project - which is
either “why-run” or “audit-only” modes. We are inclined towards
"audit-only" mode because there is no “node save” at the end of "why run"
run.

So for the audit mode - we would like to get access to a number of
variables in the environment when the test fails. To this end, we
implemented an event handler that gets activated when audit failure
happens. The event we use is:
control_example_failure(control_group_name, example_data, error)

Here is the control group we are using for audit:

control_group “audit service running” docontrol “ntp audit” doit “should
be running” donewService = “ntp2” #Variables we defined.stats =
"ntpstats"expect(service(“ntpd”)).to be_runningendendend

Here is what we found in the “example_data” structure:

*{:name=>“should be running”,:desc=>“audit service running ntp audit
should be running”,:resource_type=>nil, :resource_name=>nil,:context=>[“ntp
audit”],:line_number=>14} *

Is there a way for us to access any of the internal variables like
"newService" and “stats” from the example_data, or any other way from Audit
results? As the output of audit - we would like to get values of other
relevant variables within the control group. Thank you.

regards,
Bhavna