Two controls
blocks cannot be named the same. Doing so will raise a compilation error as seen with the following code:
# cookbook: example
# recipe: default
controls "mysql audit" do
control "mysql package" do
it "should be installed" do
expect(package("mysql")).to be_installed.with_version("5.6")
end
end
end
controls "mysql audit" do
control "mysql package" do
it "should be installed" do
expect(package("mysql")).to be_installed.with_version("5.6")
end
end
end
Running the recipe[example::default]
recipe on a node would produce the following output:
Compiling Cookbooks...
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/tyler-mysql/recipes/default.rb
================================================================================
Chef::Exceptions::AuditControlGroupDuplicate
--------------------------------------------
Audit control group with name 'mysql audit' has already been defined
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/tyler-mysql/recipes/default.rb:29:in `from_file'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/tyler-mysql/recipes/default.rb:
22: it "should be installed" do
23: expect(package("mysql")).to be_installed.with_version("5.6")
24: end
25: end
26:
27: end
28:
29>> controls "mysql audit" do
30:
31: control "mysql package" do
32: it "should be installed" do
33: expect(package("mysql")).to be_installed.with_version("5.6")
34: end
35: end
36:
37: end
38: