Reputation: 64756
In my cookbooks, how should I check if the chef recipe is being provisioned onto a Macintosh machine?
Upvotes: 1
Views: 1245
Reputation: 77951
A better solution is to use a platform_family check. Will work for both OS X and OS X server (Source OHAI-345).
cookbook_file "/etc/nginx/nginx.conf" do
source "nginx.conf"
not_if platform_family?("mac_os_x")
end
An even better solution would be to let chef do all the work. Use a single cookbook_file declaration:
cookbook_file "/etc/nginx/nginx.conf" do
source "nginx.conf"
end
And ship the platform specific files with your cookbook:
Upvotes: 5
Reputation: 64756
Use
node[:platform] == "mac_os_x"
to check.
You can do a not_if
block like this:
cookbook_file "/etc/nginx/nginx.conf" do
source "nginx.conf"
not_if { node[:platform] == "mac_os_x" }
end
Upvotes: 1