(858) 586 7777 | About | Testimonials | Contact
vteams vteams vteams vteams
  • How does it work?
    • Startup Process
    • Your First Day
  • Technologies
    • Hire PHP Developer
    • Hire App Developer
    • Hire JavaScript Developer
    • Hire ROR Developer
    • Hire IOS Developer
    • Hire .NET Developer
    • Hire AI Developer
    • Hire Robotics Engineer
  • Sample Budgets
  • Meet The Team
  • Experiments
  • Captain’s Log
  • Blog
vteams vteams
  • How does it work?
    • Startup Process
    • Your First Day
  • Technologies
    • Hire PHP Developer
    • Hire App Developer
    • Hire JavaScript Developer
    • Hire ROR Developer
    • Hire IOS Developer
    • Hire .NET Developer
    • Hire AI Developer
    • Hire Robotics Engineer
  • Sample Budgets
  • Meet The Team
  • Experiments
  • Captain’s Log
  • Blog
Blog
  1. vteams
  2. Blog
  3. Use Chef to Fast Track Your Remote Rails Environment Setup
May 10
use-chef-to-fast-track-your-remote-rails-environment-setup

Use Chef to Fast Track Your Remote Rails Environment Setup

  • May 10, 2017

In this tutorial, we will walk through the process of setting up Ruby on Rails server deployment with Chef – in order to automate remote server configuration. Chef is a tool that allows us to manage configurations, similar to Puppet, but it’s considerably more popular as it’s written in Ruby. This tool can help you manage your infrastructure dependencies, create folder structures (with ‘knife’) and bootstrap the entire system. It can even update configurations with just a few commands.

Step 1: Ruby, Ruby Version Manager and Gemset

Supposedly, you already have some Ruby Version Manager (RVM or rbenv most likely) and Ruby. The Ruby version used in this tutorial is Ruby 2.2.1. It is recommended that you create a separate gemset for the Chef configuration. In RVM, you can do this using the following command:

1
 $: rvm gemset create chef_article.

To use a newly created gemset, run the following command:

1
$: rvm gemset use chef_article.

This will separate your Chef gems from the other gems, which can save you from the trouble later. If everything went right, you should have RVM, Ruby and the new gemset on your local machine. To display the new gemset on the list, run the following command:

1
$: rvm gemset list

The new gemset will be marked with an asterisk (*) if it is currently used. The next item you need is a bundler gem. You can easily install it using the following command:

1
$: gem install bundler

Step 2: Knife, Chef and Berkshelf Gems

The workbench is prepared in the previous step. To start creating your Chef repo, few tools are required.

At first, you will need to create the Gemfile where the Ruby version, gemset (that we want to use) and all the needed gems will be specified. Start by creating a directory for the repo. You can name it in your own way, for example:

1
$: mkdir chef_repo && cd $_

Now, with the help of the bundler gem, initialize a Gemfile:

1
$: bundle init

Edit your Gemfile and then add the following Gems:

1
2
3
4
gem 'knife-solo', '0.3.0'
gem "chef", "~> 11.10.0"
gem 'chef-zero', '1.7.2'
gem "berkshelf", "~> 2.0.14"

Run the following command:

1
$: bundle install

Step 3: Copy SSH Key to the Target Server

Assuming that you already have the ssh-key setup, we will skip the process of creating a new ssh-key here. Start by copying and pasting your ssh-key to the target server:

1
ssh-copy-id user@hostname.example.com

Note: This will copy the public key of your default identity (use “-i identity_file” for other identities) to the remote host.

Step 4: Creating a Chef Repo

At first, you need to initialize a Chef repo. Go to your console, make sure that you are in the chefrepo_ directory and execute the following command:

1
$: knife solo init .

Your console will output these lines while creating the repo structure:

1
2
3
4
5
WARNING: No knife configuration file found
Creating kitchen...
Creating knife.rb in kitchen...
Creating cupboards...
Setting up Berkshelf...

Now, let’s see how the Chef repo structure looks; your chefrepo_ should have the following content:

1
2
3
4
5
6
7
8
9
chef_repo:
  .
  ├── Berksfile
  ├── cookbooks
  ├── data_bags
  ├── environments
  ├── nodes
  ├── roles
  └── site-cookbooks

To add cookbooks, open Berksfile. It should be populated with:

1
site :opscode

This is the site where the cookbooks will be downloaded. Now, start populating the Berksfile with cookbook names, and repositories where these cookbooks can be found. Add the following lines just below “site :opscode“:

1
2
3
4
5
6
7
8
> cookbook 'users', git: 'https://github.com/opscode-cookbooks/users.git'
> cookbook 'sudo', git: 'https://github.com/opscode-cookbooks/sudo.git'
> cookbook 'rvm', git: 'https://github.com/fnichol/chef-rvm.git'
> cookbook 'nodejs', git: 'https://github.com/mdxp/nodejs-cookbook.git'
> cookbook 'postgresql', git: 'https://github.com/hw-cookbooks/postgresql.git'
> cookbook 'redisio', git: 'https://github.com/brianbianco/redisio.git'
> cookbook 'nginx', git: 'https://github.com/opscode-cookbooks/nginx.git'
> cookbook 'imagemagick', git: 'https://github.com/someara/imagemagick.git'

This set will be sufficient for setting up the Rails environment. With the cookbooks in place, it is the time to set up some roles.

  • Facebook
  • Twitter
  • Tumblr
  • Pinterest
  • Google+
  • LinkedIn
  • E-Mail

Comments are closed.

SEARCH BLOG

Categories

  • Blog (490)
  • Captain's Log (1)
  • Closure Reports (45)
  • Experiments (7)
  • How-To (56)
  • Implementation Notes (148)
  • Learn More (156)
  • LMS (8)
  • Look Inside (10)
  • Operations Log (12)
  • Programmer Notes (20)
  • R&D (14)
  • Rescue Log (4)
  • Testimonials (25)
  • Uncategorized (4)

RECENT STORIES

  • GitHub Actions- Automate your software workflows with excellence
  • Yii Framework – Accomplish Repetitive & Iterative Projects with Ease
  • A Recipe for CRM Software Development
  • Are Agile and DevOps the same?
  • The Data Scientist’s Toolset

ARCHIVES

In Short

With the vteams model, you bypass the middleman and hire your own offshore engineers - they work exclusively for you. You pay a reasonable monthly wage and get the job done without hassles, re-negotiations, feature counts or budget overruns.

Goals for 2020

  • Open development center in Australia
  • Complete and Launch the Robot
  • Structural changes to better address Clients' needs

Contact Us

Address: NEXTWERK INC.
6790 Embarcadero Ln, Ste 100,
Carlsbad, CA 92011, USA

Tel: (858) 586 7777
Email: fahad@nextwerk.com
Web: www.vteams.com

© 2020 vteams. All Rights Reserved.

Content Protection by DMCA.com