- From: Bryan McLellan <
>
- To:
- Subject: [chef] Re: managing custom apache configs chef
- Date: Fri, 17 Aug 2012 15:35:18 -0400
On Tue, Aug 14, 2012 at 11:48 PM, Zippy Zeppoli
<
>
wrote:
>
Is it possible to do the following with Chef and an httpd.conf file.
>
Here is my logic:
>
>
if environment_name (perhaps comes from a file on the system) == PRODUCTION
>
then sed -i s/LogLevel DEBUG/LogLevel INFO/
>
fi
You should definitely do this in a template rather than using sed.
>
So basically if a server meets some condition, then modify the file that is
>
being managed by chef.
>
>
Are there any example recipes/cookbooks to this point?
There are many recipes that use node.chef_environment, which retrieves
the current environment you have configured in chef. Before the
environments feature, folks often used a databag for this information.
https://github.com/opscode-cookbooks/munin/blob/master/recipes/server_nginx.rb
To do exactly what you'd want, you'd modify the apache2.conf.erb
template in the apache2 cookbook like so:
https://github.com/opscode-cookbooks/apache2/blob/master/templates/default/apache2.conf.erb#L139
<% if node.chef_environment == "production" -%>
LogLevel INFO
<% else -%>
LogLevel DEBUG
<% end -%>
Bryan
Archive powered by MHonArc 2.6.16.