conf_files.rb 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #
  2. # Cookbook Name:: dovecot
  3. # Recipe:: conf_files
  4. #
  5. # Copyright 2013, Onddo Labs, Sl.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. #
  20. # required directories
  21. #
  22. directory node['dovecot']['lib_path'] do
  23. owner node['dovecot']['conf_files_user']
  24. group node['dovecot']['conf_files_group']
  25. mode '00755'
  26. end
  27. conf_files_dirs = []
  28. node['dovecot']['conf_files'].each do |conf_type, conf_files|
  29. conf_files_dirs += conf_files.map{ |f| ::File.dirname(f) }.uniq
  30. end
  31. conf_files_dirs.uniq!
  32. conf_files_dirs.each do |dir|
  33. directory dir do
  34. owner 'root'
  35. group node['dovecot']['group']
  36. mode '00755'
  37. only_if do dir != '.' end
  38. end
  39. end
  40. #
  41. # config files
  42. #
  43. node['dovecot']['conf_files'].each do |type, conf_files|
  44. conf_files.each do |conf_file|
  45. template conf_file do
  46. path "#{node['dovecot']['conf_path']}/#{conf_file}"
  47. source "#{conf_file}.erb"
  48. owner node['dovecot']['conf_files_user']
  49. group node['dovecot']['conf_files_group']
  50. mode node['dovecot']['conf_files_mode']
  51. variables(
  52. :auth => node['dovecot']['auth'].to_hash,
  53. :protocols => node['dovecot']['protocols'].to_hash,
  54. :services => node['dovecot']['services'].to_hash,
  55. :plugins => node['dovecot']['plugins'].to_hash,
  56. :namespaces => node['dovecot']['namespaces'],
  57. :conf => node['dovecot']['conf']
  58. )
  59. notifies :reload, 'service[dovecot]'
  60. action :nothing
  61. end
  62. end
  63. end