Created
August 6, 2014 12:10
-
-
Save y13i/36ac47cc0072ff9cb16a to your computer and use it in GitHub Desktop.
Chef recipe: ApacheのLogFormat末尾に%Dを追加する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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