dens.one

let the machines do the work for you

  • Crude Ruby Script to Jumpstart a Chef Server on ec2

    • 18 Sep 2011
    • 0 Responses
    •  views
    • Edit
    • Delete
    • Tags
    • Autopost

    Just wanted to share a script I hacked together. Mainly from the the AWS gem docs. This script builds a new ec2 server and jumpstarts a chef server for you. You can pull it from my

    Github: https://github.com/densone/chef-server-jumpstart 

     

    • Tweet
  • rails3 MySQL and taps error on OSX Snow Leopard

    • 7 Feb 2011
    • 0 Responses
    •  views
    • Edit
    • Delete
    • Tags
    • Autopost

    I recently tried to get the mysql library gem working for rails3 and taps. This would allow me to pull from heroku's postgres database and push data to my local dev mysql db. 

    I was getting the most annoying error: 

    This issue can also be seen here by a bunch of other taps users(including me): 

     

    https://github.com/ricardochimal/taps/issues#issue/47/comment/748899

     

    Solution: 

    • Uninstall MySql from you mac. Just google it to learn how. 
    • Download and install the MySQL install of OSX 10.5 (I know you are on 10.6, just do it) 
      http://dev.mysql.com/downloads/mysql/ <-- Scroll down for 10.5 
    • Install your gem with x86_64 arch flags. It's not going to work if you don't. 
      sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
       

     

    • Tweet
  • Pan Seared Chicken Reduced With Narragansett

    • 7 Feb 2011
    • 0 Responses
    •  views
    • Edit
    • Delete
    • Tags
    • Autopost

    One of my New Years resolutions this year is to cook a lot more. I am so used to eating out all of the time, that I basically spend a ton of money on shitty food. This past weekend I went to Trader Joe's and Foodies, bought a bunch of random food. This is one of my dishes. 

     

    Pan Seared Chicken & Narragansett

     

    Pan Seared Chicken Reduced With Narragansett

     

     

    Ingredients

    1. chopped sage
    2. chopped garlic
    3. sea salt 
    4. pepper
    5. onion
    6. unsalted butter
    7. whole wheat pasta
    8. chicken breast
    9. spinach 
    10. feta cheese
    11. narragansett beer

     

     

    pan seared chicken reduced with narragansett

    Instructions 

    1. Chop the onions/sage and cook in a pan with the butter.
    2. Once the onions are mostly cooked, add the garlic and make sure not to burn it.  
    3. In another pan boil, cook, and strain whole wheat pasta. 
    4. Grab your chicken breast and try to slice it into more cutlet like pieces. Make sure you use a sharp non-serated knife.  
    5. Crank the heat up and sear the chicken in the pan with the spices and onion.
    6. Once the the chicken is browned on both sides, add some narragansett. 
    7. Take a fork and scrape all the goodies that burned into the pan. This will enhance the taste of the reduction.  
    8. Once you have reduced by half,  throw the spinach in the pan and let it cook for about 10 seconds.
    9. Mix the spinach with the pasta.  
    10. Add some feta into the the reduction and let it cream up. I kinda mooshed it up with a fork.
    11. Mix the reduction and chicken into the pasta and spinach.  

     

    • Tweet
  • Using The Grinder 3 to Load Test a Ruby on Rails Application

    • 27 Jan 2011
    • 0 Responses
    •  views
    • Edit
    • Delete
    • Tags
    • Autopost

    I've been using The Grinder3 to run some rails performance tests and ran into an issue where I could not parse some html to submit Ruby on Rails forms. Every form in a Ruby on Rails application has an authenticity_token. This keeps jerks from messing around.

     

    The process: 

    1) Go to the sign_in page.
    2) Parse the authenticity token from the response
    3) Post and login to the applicaiton.

     

    The Errors

     1) The Grinder does not support the re module out of the box. Grinder uses Jython, but its slimmed down. I fixed this by downloading the latest Jython installation and dropping it in to $GRINDER_HOME/lib. Make sure to copy jython's Lib directory also. Yes that was Lib with a capital "L". 

    2) You need to compile your regular expression outside of the test thread. At least this was the case for me. See line 7 in the following gist. 

    3) You need to import the re module into each test thread along with importing re into the agent. See lines 5 and 45 of the test. 

     

    Test Away

    Once you parse the authenticity_token, you will be able to load test your rails apps with the grinder. I am using devise for authentication in this sample. 

    Also notice I have cookies enabled in the gist. 

     

    The Gist

     

    Links

    http://grinder.sourceforge.net/
    http://rubyonrails.org 

    • Tweet
  • Manage iptables Firewalls on RackSpace Cloud with Chef

    • 24 Oct 2010
    • 0 Responses
    •  views
    • chef firewall iptables linux rackspace cloud shorewall
    • Edit
    • Delete
    • Tags
    • Autopost

    I ran into an interesting issue with RackSpace Cloud recently. They don't have a magical firewall layer like ec2. You basically have to manage iptables with a wrapper for each machine on your network. This can be quite the pain in the ass if you have more than a few servers. In my case, I need to block the external interface on about 50 servers, so a Chef cookbook was the right approach.   

    This cookbook is written specifically for Ubuntu, but can be quickly ported to any Linux Distro.

    This article is written for a System Engineer or Developer that knows the Chef basics. Please feel free to ask questions below in the comments section for a deeper explanation of this cookbook.

     

    Clone My Chef Repo on GitHub:
    Every code snippet in this article can be grabbed from my public git repository. 

    http://github.com/densone/densone-chef

     

    Shorewall
    I decided to use an iptables wrapper called Shorewall. Shorewall is not daemonized. When running shorwall restart/stop/start, you are just running scripts that update iptables.


    Simple Installation  

    Only a single package named "shorewall" needs to be installed. Chef makes this easy with its package resource. 

    package "shorewall" 
    

     

    Shorewall Config Files 
    Shorewall has a handful of important config files. Proper configuration is essential for iptables to get updated properly. My chef GitHub Repo will work for RackSpace Cloud out of the box.  

    • interfaces -  describes the network interfaces to be firewalled.  
    • policy - defines the high level policy for connections between zones. 
    • zones - this file allows you to declare your network zones. 
    • rules - holds all of the exceptions to the firewall policy
    • shorewall.conf - this is the master shorewall config. For ease of use, this is not edited. 

     

    Let's Put the Recipe Together 
    So far we have talked about shorewall and its various files. Let's put it all together now in a Chef recipe.
     

    default.rb
    This cookbook only has one recipe, so we can name it default. 

    The preceding recipe will show you a few things. 

    • The package installation of Shorewall
    • The copy of several config files mentioned earlier 
    • The generation of an erb template for firewall rules
    • The enabling of the Shorewall service, and restarting of the service based on file triggers.

    rules.erb
    This file iterates through a node attribute defined in the cookbook default.rb 

     

    Applying The Cookbook To a Role
    The cookbook is ready. Now we need to create a role and setup some rules in it.

    • Save the role to a file "appserver.rb"
    • Upload the role: knife role from file $CHEF_REPO/roles/appserver.rb

     

    Apply The Role to an App Server, Sit Back and Let The Machine Work for You

    To connect this role to an app server run the following command: 

    knife node run_list add  <app-server-fqdn> "role[appserver]"

     

    Light Reading 

    http://wiki.opscode.com - Information about Chef.

    http://www.shorewall.net/ - Information about Shorline Firewall. 

     

     

    • Tweet
  • About

    Sean Carey is a System Engineer from Boston. He works independently and helps (mostly) startup software companies build an ideal system.

    6460 Views
  • Archive

    • 2011 (6)
      • September (1)
      • February (3)
      • January (2)
    • 2010 (1)
      • October (1)

    Get Updates

    Subscribe via RSS
    TwitterFacebookTumblr