cerner_splunk
cerner_splunk copied to clipboard
Move the forwarder_monitor validation to the provider?
I have a use case where I have a cookbook that optionally includes splunk integration. It looks something like:
cerner_splunk_forwarder_monitors foo do
action :install
...
only_if { enable_splunk }
end
However, even if that enable_splunk attribute is set to false it still fails during the compilation phase if node['splunk']['home'] is not defined. The only_if clause is evaluated later on during the execution phase. I could modify that cookbook to do this:
if enable_splunk
cerner_splunk_forwarder_monitors foo do
action :install
...
end
end
but then foodcritic flags that as lint. Thoughts on moving that validation into the provider instead of doing it in the after_created on the resource?
I could also just define ['splunk']['home'] to be an empty string to get around the problem when the splunk recipe isn't on my runlist, but that feels a bit hacky too.