default.rb 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. include_recipe 'apt'
  2. include_recipe 'build-essential'
  3. user "huginn" do
  4. action :create
  5. system true
  6. home "/home/huginn"
  7. password "$6$ZwO6b.6tij$SMa8UIwtESGDxB37NwHsct.gJfXWmmflNbH.oypwJ9y0KkzMkCdw7D14iK7GX9C4CWSEcpGOFUow7p01rQFu5."
  8. supports :manage_home => true
  9. gid "sudo"
  10. shell "/bin/bash"
  11. end
  12. group "huginn" do
  13. members ["huginn"]
  14. action :create
  15. end
  16. %w("ruby1.9.1" "ruby1.9.1-dev" "libxslt-dev" "libxml2-dev" "curl" "libmysqlclient-dev" "libffi-dev" "libssl-dev").each do |pkg|
  17. package pkg do
  18. action :install
  19. end
  20. end
  21. bash "Setting default ruby and gem versions to 1.9" do
  22. code <<-EOH
  23. if [ $(readlink /usr/bin/ruby) != "ruby1.9.1" ]
  24. then
  25. update-alternatives --set ruby /usr/bin/ruby1.9.1
  26. fi
  27. if [ $(readlink /usr/bin/gem) != "gem1.9.1" ]
  28. then
  29. update-alternatives --set gem /usr/bin/gem1.9.1
  30. fi
  31. EOH
  32. end
  33. git "/home/huginn/huginn" do
  34. repository 'git://github.com/cantino/huginn.git'
  35. reference 'master'
  36. action :sync
  37. user "huginn"
  38. end
  39. gem_package("rake")
  40. gem_package("bundle")
  41. bash "Setting huginn user with NOPASSWD option" do
  42. cwd "/etc/sudoers.d"
  43. code <<-EOH
  44. touch huginn
  45. chmod 0440 huginn
  46. echo "huginn ALL=(ALL) NOPASSWD:ALL" >> huginn
  47. EOH
  48. end
  49. bash "huginn dependencies" do
  50. user "huginn"
  51. cwd "/home/huginn/huginn"
  52. code <<-EOH
  53. export LANG="en_US.UTF-8"
  54. export LC_ALL="en_US.UTF-8"
  55. sudo bundle install
  56. sed s/REPLACE_ME_NOW\!/$(sudo bundle exec rake secret)/ .env.example > .env
  57. sudo bundle exec rake db:create
  58. sudo bundle exec rake db:migrate
  59. sudo bundle exec rake db:seed
  60. EOH
  61. end
  62. bash "huginn has been installed and will start in a minute" do
  63. user "huginn"
  64. cwd "/home/huginn/huginn"
  65. code <<-EOH
  66. sudo nohup foreman start &
  67. EOH
  68. end