Le 2014-10-30 12:21, Varun Shankar a écrit :
I know that attributes can be configured in cookbooks (attribute files and recipes), roles, and environments.Suppose I have a requirement on the following lines:- Two environments: alpha and beta- Two web servers: web-1, web-2- Apache should run on port 80 on web-1 in alpha- Apache should run on port 8080 on web-2 in alpha- Apache should run on port 8081 on web-1 and web-2 in betaI can have two approaches:SOLUTION 1. Write a role cookbook (using application/library pattern) and override the apache[listen_ports] attribute in the role cookbook. Again override the apache[listen_ports] attribute in my chef-repo/environments/alpha.rb and chef-repo/environments/beta.rb file. But this way the configuration for Apache is scattered in multiple places (environment files, role cookbooks and the apache community cookbook).
SOLUTION 2. Write a wrapper cookbook over the community apache cookbook. In the attribute file of my wrapper cookbook, I write logic like this:apache[listen_ports] = 8080if env is alphaif role is web1apache[listen_ports] = 80elseif role is web2apache[listen_ports] = 8080endThis way all apache settings are consolidated in one place i.e. in the cookbook.I have seen all the blog posts suggest the first solution. Why is the second solution a bad idea?
Peter Burkholder — Customer Success Engineer
301-204-5767 – " target="_blank"> – my: Linkedin Twitter
| ||
getchef.com Blog Facebook Twitter Youtube |
Archive powered by MHonArc 2.6.16.