Skip to content

Instantly share code, notes, and snippets.

@bageljp
Created July 29, 2014 17:27
Show Gist options
  • Save bageljp/969613dbecc19a80c130 to your computer and use it in GitHub Desktop.
Save bageljp/969613dbecc19a80c130 to your computer and use it in GitHub Desktop.
chefでconf一式を反映させたい ref: http://qiita.com/bageljp@github/items/16808a4c32270edb0ba3
Chef::Config[:cookbook_path].each{|elem|
if File.exists?(File.join(elem, "/nginx/templates/default/", node['nginx']['template_dir']))
conf_dir = File.join(elem, "/nginx/templates/default/", node['nginx']['template_dir'])
Dir.chdir conf_dir
confs = Dir::glob("**/*")
confs.each do |t|
if File::ftype("#{conf_dir}/#{t}") == "file"
template "/etc/nginx/#{t}" do
owner "root"
group "root"
mode 00644
source "#{node['nginx']['template_dir']}/#{t}"
notifies :restart, "service[nginx]"
end
else
directory "/etc/nginx/#{t}" do
owner "root"
group "root"
mode 00755
end
end
end
end
}
$ tree nginx/templates/default/conf_web
nginx/templates/default/conf_web
├── conf.d
│   ├── ssl.conf
│   └── virtual.conf
├── fastcgi.conf
├── fastcgi_params
├── nginx.conf
├── scgi_params
├── conf.d
│   ├── server.key
│   └── server.crt
└── uwsgi_params
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment