Browse Source

FC001: Use strings in preference to symbols.

Andrew Crump 12 years ago
parent
commit
dd7413c1e6

+ 1 - 1
recipes/default.rb

@@ -20,7 +20,7 @@
 search(:apps) do |app|
   (app["server_roles"] & node.run_list.roles).each do |app_role|
     app["type"][app_role].each do |thing|
-      node.run_state[:current_app] = app
+      node.run_state['current_app'] = app
       include_recipe "application::#{thing}"
     end
   end

+ 4 - 4
recipes/django.rb

@@ -17,7 +17,7 @@
 # limitations under the License.
 #
 
-app = node.run_state[:current_app]
+app = node.run_state['current_app']
 
 include_recipe "python"
 
@@ -26,7 +26,7 @@ include_recipe "python"
 # default application recipe work it's mojo for you.
 ###
 
-node.default[:apps][app['id']][node.chef_environment][:run_migrations] = false
+node.default['apps'][app['id']][node.chef_environment]['run_migrations'] = false
 
 # the Django split-settings file name varies from project to project...+1 for standardization
 local_settings_full_path = app['local_settings_file'] || 'settings_local.py'
@@ -155,7 +155,7 @@ deploy_revision app['id'] do
   before_migrate do
     requirements_file = nil
     # look for requirements.txt files in common locations
-    if ::File.exists?(::File.join(release_path, "requirements", "#{node[:chef_environment]}.txt"))
+    if ::File.exists?(::File.join(release_path, "requirements", "#{node['chef_environment']}.txt"))
       requirements_file = ::File.join(release_path, "requirements", "#{node.chef_environment}.txt")
     elsif ::File.exists?(::File.join(release_path, "requirements.txt"))
       requirements_file = ::File.join(release_path, "requirements.txt")
@@ -175,7 +175,7 @@ deploy_revision app['id'] do
     local_settings_file_name => local_settings_full_path
   })
 
-  if app['migrate'][node.chef_environment] && node[:apps][app['id']][node.chef_environment][:run_migrations]
+  if app['migrate'][node.chef_environment] && node['apps'][app['id']][node.chef_environment]['run_migrations']
     migrate true
     migration_command app['migration_command'] || "#{::File.join(ve.path, "bin", "python")} manage.py migrate"
   else

+ 12 - 12
recipes/gunicorn.rb

@@ -17,25 +17,25 @@
 # limitations under the License.
 #
 
-app = node.run_state[:current_app] 
+app = node.run_state['current_app'] 
 
 ve = resources(:python_virtualenv => app['id'])
-node.default[:gunicorn][:virtualenv] = ve.path
+node.default['gunicorn']['virtualenv'] = ve.path
 
 include_recipe "gunicorn"
 
-node.default[:gunicorn][:worker_timeout] = 60
-node.default[:gunicorn][:preload_app] = false
-node.default[:gunicorn][:worker_processes] = [node[:cpu][:total].to_i * 4, 8].min
-node.default[:gunicorn][:server_hooks] = {:pre_fork => 'import time;time.sleep(1)'}
-node.default[:gunicorn][:port] = '8080'
+node.default['gunicorn']['worker_timeout'] = 60
+node.default['gunicorn']['preload_app'] = false
+node.default['gunicorn']['worker_processes'] = [node['cpu']['total'].to_i * 4, 8].min
+node.default['gunicorn']['server_hooks'] = {:pre_fork => 'import time;time.sleep(1)'}
+node.default['gunicorn']['port'] = '8080'
 
 gunicorn_config "/etc/gunicorn/#{app['id']}.py" do
-  listen "#{node[:ipaddress]}:#{node[:gunicorn][:port]}"
-  worker_timeout node[:gunicorn][:worker_timeout] 
-  preload_app node[:gunicorn][:preload_app] 
-  worker_processes node[:gunicorn][:worker_processes]
-  server_hooks node[:gunicorn][:server_hooks]
+  listen "#{node['ipaddress']}:#{node['gunicorn']['port']}"
+  worker_timeout node['gunicorn']['worker_timeout'] 
+  preload_app node['gunicorn']['preload_app'] 
+  worker_processes node['gunicorn']['worker_processes']
+  server_hooks node['gunicorn']['server_hooks']
   action :create
 end
  

+ 2 - 2
recipes/java_webapp.rb

@@ -17,14 +17,14 @@
 # limitations under the License.
 #
 
-app = node.run_state[:current_app]
+app = node.run_state['current_app']
 
 ###
 # You really most likely don't want to run this recipe from here - let the
 # default application recipe work it's mojo for you.
 ###
 
-node.default[:apps][app['id']][node.chef_environment][:run_migrations] = false
+node.default['apps'][app['id']][node.chef_environment]['run_migrations'] = false
 
 ## First, install any application specific packages
 if app['packages']

+ 2 - 2
recipes/mod_php_apache2.rb

@@ -17,7 +17,7 @@
 # limitations under the License.
 #
 
-app = node.run_state[:current_app]
+app = node.run_state['current_app']
 
 node.default['apache']['listen_ports'] = [ "8080" ]
 
@@ -50,4 +50,4 @@ end
 
 apache_site "000-default" do
   enable false
-end
+end

+ 3 - 3
recipes/passenger_apache2.rb

@@ -17,7 +17,7 @@
 # limitations under the License.
 #
 
-app = node.run_state[:current_app] 
+app = node.run_state['current_app'] 
 
 include_recipe "apache2"
 include_recipe "apache2::mod_ssl"
@@ -34,9 +34,9 @@ web_app app['id'] do
   docroot "#{app['deploy_to']}/current/public"
   template "#{app['id']}.conf.erb"
   cookbook "#{app['id']}"
-  server_name "#{app['id']}.#{node[:domain]}"
+  server_name "#{app['id']}.#{node['domain']}"
   server_aliases server_aliases
-  log_dir node[:apache][:log_dir]
+  log_dir node['apache']['log_dir']
   rails_env node.chef_environment
 end
 

+ 1 - 1
recipes/php.rb

@@ -17,7 +17,7 @@
 # limitations under the License.
 #
 
-app = node.run_state[:current_app]
+app = node.run_state['current_app']
 
 include_recipe "php"
 

+ 5 - 5
recipes/rails.rb

@@ -17,18 +17,18 @@
 # limitations under the License.
 #
 
-app = node.run_state[:current_app]
+app = node.run_state['current_app']
 
 # make the _default chef_environment look like the Rails production environment
 rails_env = (node.chef_environment =~ /_default/ ? "production" : node.chef_environment)
-node.run_state[:rails_env] = rails_env
+node.run_state['rails_env'] = rails_env
 
 ###
 # You really most likely don't want to run this recipe from here - let the
 # default application recipe work it's mojo for you.
 ###
 
-node.default[:apps][app['id']][node.chef_environment][:run_migrations] = false
+node.default['apps'][app['id']][node.chef_environment]['run_migrations'] = false
 
 ## First, install any application specific packages
 if app['packages']
@@ -133,7 +133,7 @@ if app["database_master_role"]
 end
 
 if app["memcached_role"]
-  results = search(:node, "role:#{app["memcached_role"][0]} AND chef_environment:#{node.chef_environment} NOT hostname:#{node[:hostname]}")
+  results = search(:node, "role:#{app["memcached_role"][0]} AND chef_environment:#{node.chef_environment} NOT hostname:#{node['hostname']}")
   if results.length == 0
     if node.run_list.roles.include?(app["memcached_role"][0])
       results << node
@@ -197,7 +197,7 @@ deploy_revision app['id'] do
     "memcached.yml" => "config/memcached.yml"
   })
 
-  if app['migrate'][node.chef_environment] && node[:apps][app['id']][node.chef_environment][:run_migrations]
+  if app['migrate'][node.chef_environment] && node['apps'][app['id']][node.chef_environment]['run_migrations']
     migrate true
     migration_command app['migration_command'] || "rake db:migrate"
   else

+ 1 - 1
recipes/tomcat.rb

@@ -17,7 +17,7 @@
 # limitations under the License.
 #
 
-app = node.run_state[:current_app]
+app = node.run_state['current_app']
 
 include_recipe "tomcat"
 

+ 14 - 14
recipes/unicorn.rb

@@ -17,25 +17,25 @@
 # limitations under the License.
 #
 
-app = node.run_state[:current_app] 
+app = node.run_state['current_app'] 
 
 include_recipe "unicorn"
 
-node.default[:unicorn][:worker_timeout] = 60
-node.default[:unicorn][:preload_app] = false
-node.default[:unicorn][:worker_processes] = [node[:cpu][:total].to_i * 4, 8].min
-node.default[:unicorn][:preload_app] = false
-node.default[:unicorn][:before_fork] = 'sleep 1' 
-node.default[:unicorn][:port] = '8080'
-node.set[:unicorn][:options] = { :tcp_nodelay => true, :backlog => 100 }
+node.default['unicorn']['worker_timeout'] = 60
+node.default['unicorn']['preload_app'] = false
+node.default['unicorn']['worker_processes'] = [node['cpu']['total'].to_i * 4, 8].min
+node.default['unicorn']['preload_app'] = false
+node.default['unicorn']['before_fork'] = 'sleep 1' 
+node.default['unicorn']['port'] = '8080'
+node.set['unicorn']['options'] = { :tcp_nodelay => true, :backlog => 100 }
 
 unicorn_config "/etc/unicorn/#{app['id']}.rb" do
-  listen({ node[:unicorn][:port] => node[:unicorn][:options] })
+  listen({ node['unicorn']['port'] => node['unicorn']['options'] })
   working_directory ::File.join(app['deploy_to'], 'current')
-  worker_timeout node[:unicorn][:worker_timeout] 
-  preload_app node[:unicorn][:preload_app] 
-  worker_processes node[:unicorn][:worker_processes]
-  before_fork node[:unicorn][:before_fork] 
+  worker_timeout node['unicorn']['worker_timeout'] 
+  preload_app node['unicorn']['preload_app'] 
+  worker_processes node['unicorn']['worker_processes']
+  before_fork node['unicorn']['before_fork'] 
 end
 
 runit_service app['id'] do
@@ -43,7 +43,7 @@ runit_service app['id'] do
   cookbook 'application'
   options(
     :app => app,
-    :rails_env => node.run_state[:rails_env] || node.chef_environment,
+    :rails_env => node.run_state['rails_env'] || node.chef_environment,
     :smells_like_rack => ::File.exists?(::File.join(app['deploy_to'], "current", "config.ru"))
   )
   run_restart false

+ 3 - 3
templates/default/myproj.conf.erb

@@ -1,13 +1,13 @@
 # nginx + passenger application vhost
 #
-# Generated by Chef for <%= node[:fqdn] %>
+# Generated by Chef for <%= node['fqdn'] %>
 # Local modifications will be overwritten.
 #
 server {
   listen 80;
   server_name <%= @server_name %><% @server_aliases.each do |a| %><%= " #{a}" %> <% end %>;
   root <%= @docroot %>;
-  error_log <%= node[:nginx][:log_dir] %>/<%= @app %>-error.log;
-  access_log <%= node[:nginx][:log_dir] %>/<%= @app %>-access.log;
+  error_log <%= node['nginx']['log_dir'] %>/<%= @app %>-error.log;
+  access_log <%= node['nginx']['log_dir'] %>/<%= @app %>-access.log;
   passenger_enabled on;
 }

+ 7 - 7
templates/default/php.conf.erb

@@ -1,10 +1,10 @@
 <VirtualHost *:8080>
-  ServerName <%= @params[:server_name] %>
-  ServerAlias <% @params[:server_aliases].each do |a| %><%= "#{a}" %> <% end %>
-  DocumentRoot <%= @params[:docroot] %>
+  ServerName <%= @params['server_name'] %>
+  ServerAlias <% @params['server_aliases'].each do |a| %><%= "#{a}" %> <% end %>
+  DocumentRoot <%= @params['docroot'] %>
   RewriteEngine On
   
-  <Directory <%= @params[:docroot] %>>
+  <Directory <%= @params['docroot'] %>>
     Options FollowSymLinks
     AllowOverride None
     Order allow,deny
@@ -25,10 +25,10 @@
   </Location>
 
   LogLevel info
-  ErrorLog <%= node[:apache][:log_dir] %>/<%= @params[:name] %>-error.log
-  CustomLog <%= node[:apache][:log_dir] %>/<%= @params[:name] %>-access.log combined
+  ErrorLog <%= node['apache']['log_dir'] %>/<%= @params['name'] %>-error.log
+  CustomLog <%= node['apache']['log_dir'] %>/<%= @params['name'] %>-access.log combined
 
   RewriteEngine On
-  RewriteLog <%= node[:apache][:log_dir] %>/<%= @application_name %>-rewrite.log
+  RewriteLog <%= node['apache']['log_dir'] %>/<%= @application_name %>-rewrite.log
   RewriteLogLevel 0
 </VirtualHost>

+ 3 - 3
templates/default/rails_nginx_passenger.conf.erb

@@ -1,13 +1,13 @@
 # nginx + passenger application vhost
 #
-# Generated by Chef for <%= node[:fqdn] %>
+# Generated by Chef for <%= node['fqdn'] %>
 # Local modifications will be overwritten.
 #
 server {
   listen 80;
   server_name <%= @server_name %><% @server_aliases.each do |a| %><%= " #{a}" %> <% end %>;
   root <%= @docroot %>;
-  error_log <%= node[:nginx][:log_dir] %>/<%= @app %>-error.log;
-  access_log <%= node[:nginx][:log_dir] %>/<%= @app %>-access.log;
+  error_log <%= node['nginx']['log_dir'] %>/<%= @app %>-error.log;
+  access_log <%= node['nginx']['log_dir'] %>/<%= @app %>-access.log;
   passenger_enabled on;
 }

+ 2 - 2
templates/default/sv-unicorn-run.erb

@@ -1,7 +1,7 @@
 #!/bin/bash
 
-cd <%= @options[:app]['deploy_to'] %>/current
+cd <%= @options['app']['deploy_to'] %>/current
 
 exec 2>&1
-exec chpst -u <%= @options[:app]["owner"] %>:<%= @options[:app]["group"] %> <%= @options[:smells_like_rack] ? 'unicorn' : 'unicorn_rails' %> -E <%= @options[:rails_env] %> -c /etc/unicorn/<%= @options[:app]['id'] %>.rb
+exec chpst -u <%= @options['app']['owner'] %>:<%= @options['app']['group'] %> <%= @options['smells_like_rack'] ? 'unicorn' : 'unicorn_rails' %> -E <%= @options['rails_env'] %> -c /etc/unicorn/<%= @options['app']['id'] %>.rb