0

I am a bit new in devOps - working with Rails. I have successfully created a Vagrant/Chef configuration to replicate my development local VM machine, but now I am trying to deploy the same settings on a Digital Ocean VPS that I connect obviously by ssh.

It's a bit confusing how to trigger chef-solo from "inside" the vm without the need of an external server. I actually have one VPS for now. I am pushing my Chef files to github, then clone them from inside the remote development VPS and run chef-solo.

Steps I've followed:

  • Installed Chef-DK
  • Added some cookbooks inside Berksfile
  • Did a berks install and then a berks vendor cookbooks to create everything inside ./cookbooks
  • Created a solo.rb file

    cookbook_path File.join(File.dirname(File.expand_path(__FILE__)), "cookbooks")
    json_attribs File.join(File.dirname(File.expand_path(__FILE__)), "node.json")
    
  • Then a node.json file:

    {
       "run_list": [
         "recipe[main]",
         "recipe[apt]",
         "recipe[nginx]",
         "recipe[postgresql]",
         "recipe[git]",
         "recipe[ruby_build]",
         "recipe[rvm]",
         "recipe[rails]",
         "recipe[bundler]",
         "recipe[nodejs]"
         ]
    }
    
  • Then a metadata.rb file in the root of my tree structure:

    name             'test'
     maintainer       'Me Myself'
     maintainer_email 'me@myself.com'
     license          'All rights reserved'
     description      'Installs/Configures test'
     long_description 'Installs/Configures test'
     version          '0.1.0'
     depends 'apt', '~> 2.6.1'
     depends 'nginx', '~> 2.7.6'
     depends 'postgresql'
     depends 'git', '~> 4.3.3'
     depends 'build-essential'
     depends 'ruby_build', '~> 0.8.0'
     depends 'rvm', '~> 0.9.4'
     depends 'rails', '~> 0.9.2'
     depends 'bundler', '~> 0.2.0'
     depends 'nodejs', '~> 2.4.2'
    
  • And finally I executed:

    sudo chef-solo -c solo.rb -j node.json

My questions:

  • How does this procedure look to you ? Am I missing something ? Any good/common practices ?
  • The cookbooks folder is deleted and re-generated when I execute berks.. Am I doing something wrong ? If not,
  • What is the meaning of tweaking the default.rb file in each cookbook to customise ? For example, I want to install Ruby 2.2.2 with RVM.
  • depends doesn't seem to install cookbooks. I needed to add them inside node.jsonin order for them to work because I was getting a 'Failed dependencies' message. Why?

Any ideas/opinions will be appreciated :)

Radolino
  • 1,834
  • 4
  • 26
  • 48
  • Too much to answer on SO, take the tour at http://learn.chef.io (specifically the [web app tutorial](https://learn.chef.io/manage-a-web-app/ubuntu/) (on ubuntu here, but you'll get the idea or you can move up to the root http://learn.chef.io for the whole tutorials) – Tensibai Nov 24 '15 at 14:11
  • The RVM cookbook currently is very broken. Lots of github issues open regarding this. `depends` doesn't install dependencies, thats what the berksfile is for. You probably need to delete the Berksfile.lock and re-run `berks install` – spuder Nov 24 '15 at 14:12
  • @spuder so finally is "depends xxxxxx" needed in the metadata.rb ? Because Berks installs dependencies from Berksfile. – Radolino Nov 24 '15 at 15:18
  • You need it in both places. – spuder Nov 24 '15 at 16:54

0 Answers0