Sha256: 926c2be382b42badcc3e5ab82ae3dffbeab16d7364006f425078562061d50bfc

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

# Install packages on hosts tagged 'rails_servers' or 'myapp_servers'
if tagged?("rails_servers | myapp_servers")
  # Install platform-specific packages, queries system-provided tags
  if tagged?("ubuntu | debian")
    package_manager.install(%w(build-essential ruby1.8-dev libsqlite3-dev))
  elsif tagged?("fedoracore | fedora | centos")
    package_manager.install(%w(gcc ruby-devel sqlite-devel))
  else
    raise NotImplementedError.new("no packages specified for this platform")
  end

  # Install Gems
  package_manager.install(%w(rails sqlite3-ruby mongrel),
    :with => :gem, :docs => false)
end

# Setup the myapp server
if tagged?(:myapp_servers)
  # Create user for the application
  account_manager.add_user(lookup(:user))

  # Create a directory for the application
  mkdir_p(lookup(:path)) do
    # Run shell commands to create the app and database
    sh("rails --database=sqlite3 . > /dev/null") \
      unless File.exists?("config/routes.rb")

    sh("rake db:migrate") if Dir["db/*.sqlite3"].empty?

    # Edit the homepage
    edit(:file => "public/index.html") do
      append("<!-- Edited by AutomateIt -->")
      replace("Welcome aboard", "This is MyAppServer")
    end

    # Change the ownership for the files
    chown_R(lookup(:user), nil, ".")

    # Generate a service startup file from a template
    render(:file => dist+"myapp_server.erb",
           :to => "/etc/init.d/myapp_server",
           :mode => 0555,
           :locals => {
              :path => lookup(:path),
              :user => lookup(:user),
              :port => lookup(:port),
           }
    )

    # Start the service
    service_manager.start("myapp_server")
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
automateit-0.70923 examples/basic/recipes/install.rb