[chef] Re: running chef in Audit mode & and getting values of parameters?


Chronological Thread 
  • From: Ranjib Dey < >
  • To: " " < >
  • Subject: [chef] Re: running chef in Audit mode & and getting values of parameters?
  • Date: Tue, 8 Sep 2015 10:17:07 -0700

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 < " target="_blank"> > 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" 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





Archive powered by MHonArc 2.6.16.

§