Ruby on Rails application deployment on multiple servers - ruby-on-rails

What are the useful gems or softwares that will help deployment of RoR 3.2 application on the clouds?
There is no specific requirements since I just want to get experience with it. But I am thinking of Amazon EC2 as a primary environment to test the application. The goal is to deploy it in the multiple servers.
I guess the most naive way would be launching the same application on multiple servers at the same time, but that will requires a lot of manual restart/reboot which requires a lot of human resources.
Is a single application of ruby on rails just not suited well for deployment on multiple servers?

We use Capistrano (https://github.com/capistrano/capistrano) to communicate with multiple EC2 instances on AWS.
We use Chef (https://github.com/opscode/chef) to do the system management configuration.
You can get cookbooks for various applications that you want to install (eg nginx, monit, logrotate...) from Opscode (http://community.opscode.com/cookbooks)
You will need both Capistrano and Chef to setup and deploy to AWS.
Puppet is another system management configuration that you can use too. (https://github.com/puppetlabs/puppet)

This is what Capistrano is for.
https://github.com/capistrano/capistrano/wiki/

Related

Ruby on Rails application deployment on local computer with postgresql

I am new to Ruby on Rails. We have developed an small application with Postgresql. Now we have to deploy it. But when i searched over internet i found lot of suggestion is to deploy them on Heroku or some premium servers. where we are not in a position now to deploy it on cloud.
How can i deploy the application on local computer? Is this similar to setting up a development environment?
Any link or lead will be much appreciated!
I hope you have your application already running on your development environment.
Create another database in your postgres, to use it for production in local system. And make necessary changes in database.yml
I feel passenger is the easiest way to deploy application, you can follow the steps in this link https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-passenger-and-apache-on-ubuntu-14-04 to deploy your app.
Heroku also have free deployment for few application. You can use heroku.
There are some more option like AWS, Digital Ocean. AWS is also free for one year.
Yes setting up a development environment is like set up your environment. But best practice is use a deployment automation like capistrano.
You can run it in a production environment and make it public. I had written a blog post regarding this.
Please check here
ps - Make sure your system is up for public access and i am hoping that this is for test purpose only and to show it to your clients.
Yes, it would be fairly similar to setting up your development environment.
In addition to setting up Passenger as described in the Digital Ocean post from Rajuk's answer, I use Capistrano for deployment to my Ubuntu servers. You can set up the Capistrano deployment configuration to deploy to any machine.
The possible configuration variables are too numerous to address here without further details about your specific situation.
Check out Railscast #335 Deploying to a VPS where Ryan talks about deploying to a Linux machine (a cloud VPS in this case) with Capistrano.

automating firewall config deployment

I wanted to develop a script (probably using Ruby) and with leveraging vendor provided REST APIs which should configure firewalls into Edge systems.
For example, these are various values I would need to read and use for configurations.
source:
destination:
port:
There would be several number of rules which includes different sources, destinations, ports to be mentioned in the file read. What would be the best way to save all this info and read by the script?
How are such deployments handled today using scripts? Sorry, I am quite new in automated deployments and scripting, could you please help with some pointers so that start with?
Thanks!
I use Chef - http://gettingstartedwithchef.com
There are many other tools out there for automated deployments and infrastructure provisioning. Here are some more I've encounted:
Capistrano - http://capistranorb.com/
Puppet - http://puppetlabs.com/
AWS Cloud Formation or Elastic Beanstalk - http://aws.amazon.com/cloudformation
Well you might want to take a look at Capistrano which is what's generally used in the ruby world for deploying web applications:
https://github.com/capistrano/capistrano
If you want something more generic, then you might want to investigate SSHKit (which is what Capistrano is built upon). SSHKit lets you deploy and run tasks on remote machines:
https://github.com/capistrano/sshkit

Rails Production Environment

I'm new to rails have been searching for deployment guides on the web - it's quite fragmented. I see some which recommend deploying as a sudo enabled user. I was thinking you would create a user with no sudo powers to run the app for security reasons. It would need it's own home directory for RVM and bundler but having sudo powers seems redundant and a security risk. I'm doing this all manually as it's a tricky beta level application and deploying it is not yet straightforward, so capistrano would only be a layer of obfuscation at this point.
I'm using thin as the server with Nginx as the proxy and redis and Postgres as the database. Clockwork and sidekiq as well.
Capistrano seems like a lot of work even for a small project but it's worth getting setup anyway if you have hopes of the application growing (and thus the complexity of deployment increasing).
I personally like the idea of separating the distribution specific Ruby available (and gems) to an RVM deployment specific to the application. Furthermore, requiring bundler to manage gem dependencies and ensuring compliance is invaluable. I wouldn't suggest enabling sudo for that user; it'll expose the whole stack from HTTP requests to root level OS control. Applications shouldn't require administrative access, deployment scripts might.
If you're new to Rails I'd recommend something simple for your first deployment. Heroku allows you to deploy apps by simply doing a git push to their repository. They handle all the steps necessary to make your app available on the Internet. Best of all it's free as long as you don't need heavy resources.
EngineYard is another hosting solution that's easy to deploy to and step up from Heroku in terms of flexibility (and cost).
Once you're comfortable with deploying production apps then you can look to using your own servers and using capistrano for the ultimate in customization.
I have production websites running in both environments and I've yet to need to go to the trouble of migrating to my own hosted server.

How to deploy multiple applications to the same server with capistrano?

I've just finished setting up my server with phusion passenger and nginx, complete with ruby on rails that are all running swimmingly. Now I can and I have deployed an application with capistrano and I got that working right.
My issue is that I want to host several applications on different domains and deploy them with capistrano on the same server. Is this even possible or am I just hoping for too much? I couldn't seem to find anything on this so any help is appreciated.
If your applications are just standalone applications that don't have dependencies on each other (i.e. you deploy them individually) then just deploy them with capistrano as you normally would.
By default capistrano will deploy to a folder such as /var/www/app_name so as long as all of the apps have a different name configured in their app_name.rb they will be blissfully unaware of each other.
You may need to be a little bit more careful with some of the services you may use, e.g. you may wish to namespace your memcache keys (or run separate memcache instances) so as to avoid clashes between apps.

Hosting rails on ec2

I want to deploy a rails onto amazon ec2. I've had a look at poolparty and ec2onrails but neither seem to be maintained anymore.
What are people using to do this? Is it all homebrewed puppet and capistrano or is there a project that will get me going?
I can recommend two projects:
If you have a single Rails app, take a look at Rubber. It's a gem that can provision EC2 instances for you, install software and deploy your app. It's based on Capistrano. There are recipes for the most common components (mysql, apache, passenger, postgres, etc.).
In case you have more complex setup (e.g. multiple apps or specific needs that aren't covered by Rubber) I recommend Chef. It does have quite a learning curve, so prepare yourself. Take a look at OpsCode to get started with Chef.
You may want to take a look at our Rubystack AMIs. They are free and we keep them up to date. You still need to do work for automating deployment and integrating in your workflow, the AMIs mainly address the environment and runtime setup.

Resources