/proftpd/recipes/default.rb

https://github.com/kalos/chef-cookbooks · Ruby · 89 lines · 62 code · 9 blank · 18 comment · 4 complexity · 5fcb1a1aa0420b28392ff4aed7b5314c MD5 · raw file

  1. #
  2. # Cookbook Name:: proftpd
  3. # Recipe:: default
  4. #
  5. # Copyright 2009, Calogero Lo Leggio
  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. if node[:proftpd][:modules].include?('sql_mysql')
  20. package "proftpd-mod-mysql" do
  21. action :upgrade
  22. end
  23. elsif node[:proftpd][:modules].include?('sql_postgres')
  24. package "proftpd-mod-pgsql" do
  25. action :upgrade
  26. end
  27. else
  28. package "proftpd-basic" do
  29. action :upgrade
  30. end
  31. end
  32. if node[:proftpd][:modules].include?('ldap')
  33. package "proftpd-mod-ldap" do
  34. action :upgrade
  35. end
  36. end
  37. service "proftpd" do
  38. supports :status => true, :restart => true, :reload => true
  39. end
  40. directory "#{node[:proftpd][:dir]}/ssl" do
  41. owner node[:proftpd][:user]
  42. group node[:proftpd][:group]
  43. mode 0700
  44. end
  45. remote_directory "#{node[:proftpd][:dir]}/#{node[:proftpd][:dir_extra_conf]}" do
  46. source "conf.d"
  47. files_backup 0
  48. files_owner node[:proftpd][:user]
  49. files_group node[:proftpd][:group]
  50. files_mode 0600
  51. owner node[:proftpd][:user]
  52. group node[:proftpd][:group]
  53. mode 0700
  54. end
  55. template "#{node[:proftpd][:dir]}/modules.conf" do
  56. source "modules.conf.erb"
  57. mode 0644
  58. owner node[:proftpd][:user]
  59. group node[:proftpd][:group]
  60. notifies :restart, resources(:service => "proftpd")
  61. end
  62. template "#{node[:proftpd][:dir]}/proftpd.conf" do
  63. source "proftpd.conf.erb"
  64. mode 0644
  65. owner node[:proftpd][:user]
  66. group node[:proftpd][:group]
  67. notifies :restart, resources(:service => "proftpd")
  68. end
  69. if (@node[:proftpd][:sql] == "on")
  70. template "#{node[:proftpd][:dir]}/#{node[:proftpd][:dir_extra_conf]}/sql.conf" do
  71. source "sql.conf.erb"
  72. mode 0644
  73. owner node[:proftpd][:user]
  74. group node[:proftpd][:group]
  75. notifies :restart, resources(:service => "proftpd")
  76. end
  77. end
  78. service "proftpd" do
  79. action [ :enable, :start ]
  80. end