Skip to content

Instantly share code, notes, and snippets.

@srivastavarobin
Last active December 10, 2015 14:58
Show Gist options
  • Save srivastavarobin/4450600 to your computer and use it in GitHub Desktop.
Save srivastavarobin/4450600 to your computer and use it in GitHub Desktop.
Chef Installation with MacOSX Mountain Lion as workstation and EC2 client nodes

Update in progress!!

Setting up RVM and Ruby

  • Followed the Gist available here to install RVM the correct way

  • Called brew update but it gave an error related to Git. Following code snippet fixed it.

    cd `brew --prefix`
    git remote add origin https://github.com/mxcl/homebrew.git
    git fetch origin
    git reset --hard origin/master
    
  • Fire brew tap homebrew/dupes

  • Fire brew install apple-gcc42

  • Firing CC=/usr/local/opt/local/bin/gcc-apple-4.2 rvm install ruby-1.9.3-p194 --enable-shared --without-tk --without-tcl gave an error that the gcc-apple in not in path. Referred to an alternate link

  • Install the command line tools from XCode. It can done by going to the preferences Command + , -> Downloads

  • Updated RVM - rvm get head

  • rvm install 1.9.3 --with-gcc=clang

Steps for fixing the installation of Chef so that sudo -i is not required for running chef commands

  • Fix the RVM and Ruby installation as given above

  • Go to the downloaded chef-repo and do gem install chef

Chef Installation and HelloWorld

  • Follow till step 4 as mentioned here
  • Start configuring EC2 as mentioned here
  • Since the work-station is setup so now its the time to install knife on it. The doc above defines the steps for Ubuntu 12.04. The following steps were followed for installation on MacOSX Mountain Lion
    • sudo gem install knife-ec2 --no-rdoc --no-ri
    • sudo /opt/chef/embedded/bin/gem install knife-ec2
    • sudo gem install net-ssh net-ssh-multi fog highline --no-rdoc --no-ri --verbose from here
    • sudo gem install knife-ec2 --no-rdoc --no-ri --verbose
    • Finally create a server - knife ec2 server create -i <path of the Amazon's PEM file> -S <name of pem file without extension> -I ami-2d4aa444 --flavor m1.small --region us-east-1 -G default -x ubuntu -N server01
    • Login to your Opscode account and verify this node

FAQs

What happens while bootstrapping?

Solution Available here

  1. Installs Ruby and packages to support installing RubyGems with native extensions.
  2. Installs RubyGems from source.
  3. Installs Chef from RubyGems.
  4. Creates the /etc/chef directory.
  5. Writes your validation certificate to /etc/chef/validation.pem.
  6. Writes an /etc/chef/client.rb config file.
  7. Writes a JSON file, /etc/chef/first-boot.json with the roles and recipes specified as the run list.
  8. Executes chef-client with the first-boot.json, connecting to the server in the client.rb.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment