Skip to content

Instantly share code, notes, and snippets.

@y13i
Created August 6, 2014 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save y13i/36ac47cc0072ff9cb16a to your computer and use it in GitHub Desktop.
Save y13i/36ac47cc0072ff9cb16a to your computer and use it in GitHub Desktop.
Chef recipe: ApacheのLogFormat末尾に%Dを追加する
ruby_block "add %D to LogFormat" do
path = "/etc/httpd/conf/httpd.conf"
content = File.read path
notifies :restart, "service[httpd]"
not_if do
content.match /^LogFormat.*%D.*combined$/
end
block do
File.open path, "w" do |file|
file.write content.gsub(/^LogFormat "(.+)" (\S*)combined$/) {%(LogFormat "#{Regexp.last_match 1} %D" #{Regexp.last_match 2}combined)}
end
end
end
service "httpd" do
action :nothing
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment