PageRenderTime 48ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/ems/recipes/default.rb

https://bitbucket.org/mhrbond/cookbooks
Ruby | 305 lines | 214 code | 67 blank | 24 comment | 0 complexity | 2327ebca68601ca9b79b1d13f6c35fe2 MD5 | raw file
  1. #
  2. # Cookbook Name:: ems
  3. # Recipe:: default
  4. #
  5. # Copyright 2012, YOUR_COMPANY_NAME
  6. #
  7. # All rights reserved - Do Not Redistribute
  8. #
  9. # date -s "2 OCT 2006 18:00:00"
  10. # install ems package
  11. # ntpdate ntp.ubuntu.com
  12. # install ems package
  13. package "mercurial" do
  14. action :install
  15. end
  16. execute "clone ems file" do
  17. cwd "/root"
  18. not_if "python welcomerain/manage.py test"
  19. #command "git clone https://github.com/mhrems/welcomerain.git"
  20. command "hg clone https://mhrbond:mhrtest@bitbucket.org/mhrjames/welcomerain"
  21. not_if do
  22. File.exists?("/root/welcomerain")
  23. end
  24. end
  25. template "/root/welcomerain/welcome_rain/settings.py" do
  26. source "ems.setting.erb"
  27. variables( :database_name => node[:ems][:database_name],
  28. :database_mysql_password => node[:ems][:database_mysql_password] )
  29. end
  30. # install mysql-server
  31. package "mysql-server" do
  32. action :install
  33. end
  34. case node["platform"]
  35. when "ubuntu", "debian"
  36. service "mysql" do
  37. action :start
  38. end
  39. when "redhat", "centos", "fedora"
  40. service "mysql" do
  41. service_name "mysqld"
  42. action :start
  43. end
  44. end
  45. execute "assign-root-password" do
  46. not_if "mysql -u root -p#{node[:ems][:database_mysql_password]}"
  47. command "mysqladmin -u root password #{node[:ems][:database_mysql_password]}"
  48. action :run
  49. end
  50. execute "create db" do
  51. not_if "mysql -uroot -p#{node[:ems][:database_mysql_password]} #{node[:ems][:database_name]}"
  52. command "mysql -uroot -p#{node[:ems][:database_mysql_password]} --init-command='create database #{node[:ems][:database_name]};'"
  53. action :run
  54. end
  55. # ganglia install
  56. # yum install ganglia-gmond
  57. # chkconfig gmond on
  58. # service gmond start
  59. # yum install ganglia-gmetad
  60. # chkconfig gmetad on
  61. # service gmetad start
  62. case node["platform"]
  63. when "ubuntu", "debian"
  64. package "ganglia-monitor" do
  65. action :install
  66. end
  67. template "/etc/ganglia/gmond.conf" do
  68. source "gmond.conf.erb"
  69. variables( :cluster_name => node[:gmond][:cluster_name],
  70. :udp_send_channel_ip => node[:gmond][:udp_send_channel_ip],
  71. :udp_send_channel_port => node[:gmond][:udp_send_channel_port] )
  72. notifies :restart, "service[ganglia-monitor]"
  73. end
  74. service "ganglia-monitor" do
  75. pattern "gmond"
  76. supports :restart => true
  77. action [ :enable, :start ]
  78. end
  79. when "redhat", "centos", "fedora"
  80. package "ganglia-gmond" do
  81. action :install
  82. end
  83. template "/etc/ganglia/gmond.conf" do
  84. source "gmond.conf.erb"
  85. variables( :cluster_name => node[:gmond][:cluster_name],
  86. :udp_send_channel_ip => node[:gmond][:udp_send_channel_ip],
  87. :udp_send_channel_port => node[:gmond][:udp_send_channel_port] )
  88. notifies :restart, "service[ganglia-monitor]"
  89. end
  90. service "ganglia-monitor" do
  91. service_name "gmond"
  92. pattern "gmond"
  93. supports :restart => true
  94. action [ :enable, :start ]
  95. end
  96. end
  97. case node["platform"]
  98. when "ubuntu", "debian"
  99. package "gmetad" do
  100. action :install
  101. end
  102. template "/etc/ganglia/gmetad.conf" do
  103. source "gmetad.conf.erb"
  104. variables( :data_source => node[:gmetad][:data_source],
  105. :xml_port => node[:gmetad][:xml_port],
  106. :trusted_hosts => node[:gmetad][:trusted_hosts] )
  107. notifies :restart, "service[gmetad]"
  108. end
  109. service "gmetad" do
  110. pattern "gmetad"
  111. supports :restart => true
  112. action [ :enable, :start ]
  113. end
  114. when "redhat", "centos", "fedora"
  115. package "ganglia-gmetad" do
  116. action :install
  117. end
  118. template "/etc/ganglia/gmetad.conf" do
  119. source "gmetad.conf.erb"
  120. variables( :data_source => node[:gmetad][:data_source],
  121. :xml_port => node[:gmetad][:xml_port],
  122. :trusted_hosts => node[:gmetad][:trusted_hosts] )
  123. notifies :restart, "service[gmetad]"
  124. end
  125. service "gmetad" do
  126. service_name "gmetad"
  127. pattern "gmetad"
  128. supports :restart => true
  129. action [ :enable, :start ]
  130. end
  131. end
  132. package "fabric" do
  133. action :install
  134. end
  135. package "rrdtool" do
  136. action :install
  137. end
  138. package "python-rrdtool" do
  139. action :install
  140. end
  141. # python moudle pip
  142. package "python-pip" do
  143. action :install
  144. end
  145. case node["platform"]
  146. when "ubuntu", "debian"
  147. execute "django_nose-pip" do
  148. command "pip install django_nose"
  149. action :run
  150. end
  151. execute "pytz-pip" do
  152. command "pip install pytz"
  153. action :run
  154. end
  155. execute "django" do
  156. not_if "django-admin.py"
  157. command "pip install -U django"
  158. action :run
  159. end
  160. when "redhat", "centos", "fedora"
  161. execute "django_nose-pip" do
  162. command "easy_install django-nose"
  163. action :run
  164. end
  165. execute "pytz-pip" do
  166. command "easy_install pytz"
  167. action :run
  168. end
  169. execute "django" do
  170. not_if "django-admin.py"
  171. command "easy_install -U django"
  172. action :run
  173. end
  174. end
  175. # python module apt-get
  176. case node["platform"]
  177. when "ubuntu", "debian"
  178. package "python-scipy" do
  179. action :install
  180. end
  181. package "python-mysqldb" do
  182. action :install
  183. end
  184. package "python-matplotlib" do
  185. action :install
  186. end
  187. when "redhat", "centos", "fedora"
  188. execute "scipy.x86_64" do
  189. command "yum install -y scipy.x86_64"
  190. end
  191. package "MySQL-python" do
  192. action :install
  193. end
  194. package "yum-utils" do
  195. action :install
  196. end
  197. execute "python-matplotlib.x86_64" do
  198. command "yum-builddep -y python-matplotlib"
  199. end
  200. execute "clone matplotlib" do
  201. cwd "/root"
  202. command "git clone git://github.com/matplotlib/matplotlib.git"
  203. action :run
  204. not_if do
  205. File.exists?("/root/matplotlib")
  206. end
  207. end
  208. execute "setup matplotlib" do
  209. cwd "/root/matplotlib"
  210. command "python setup.py install"
  211. action :run
  212. end
  213. end
  214. # install wadofstuff
  215. execute "get wadofstuff" do
  216. not_if = "find /usr/local/lib/python2.7/dist-packages/ -name wadofstuff"
  217. wadofstuff_url = "http://wadofstuff.googlecode.com/files/wadofstuff-django-serializers-1.1.0.tar.gz"
  218. cwd "/root"
  219. command "wget #{wadofstuff_url}"
  220. action :run
  221. end
  222. execute "tar wadofstuff" do
  223. not_if = "find /usr/local/lib/python2.7/dist-packages/ -name wadofstuff"
  224. cwd "/root"
  225. command "tar -xvf wadofstuff-django-serializers-1.1.0.tar.gz"
  226. action :run
  227. end
  228. execute "setup wadofstuff" do
  229. not_if = "find /usr/local/lib/python2.7/dist-packages/ -name wadofstuff"
  230. cwd "/root/wadofstuff-django-serializers-1.1.0"
  231. command "python setup.py install"
  232. action :run
  233. end
  234. execute "ems syncdb" do
  235. cwd "/root/welcomerain"
  236. command "python manage.py syncdb --noinput"
  237. action :run
  238. end