Advertisement
Advertisement

More Related Content

Advertisement

An Introduction to Shef, the Chef Shell

  1. Shef: The Chef Shell Julian C. Dunn Senior Systems Operations Engineer jdunn@secondmarket.com
  2. What is SecondMarket? Since 2004, SecondMarket has been committed to connecting the world’s qualified investors with alternative investments. Our Vision: To revolutionize the financial markets by creating a Trading trusted global platform to more efficiently allocate capital Providing institutional investors with access to through technology-enabled solutions. unique fixed income products, independent market perspective, and superior client service SecondMarket is organized into three business segments: Markets Creating an enterprise solution for private issuers to help them facilitate secondary trading and raising primary capital in a company-controlled manner neXus Aggregating, standardizing and promoting next generation investments to make them available to the broadest group of investors ever assembled Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  3. What is Shef? Chef running within IRB Three modes: Standalone ("-a") Solo ("-s") Client ("-z") Use existing config file or shef.rb Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  4. SecondMarket Infrastructure 75-100 servers Hosting: Amazon EC2 Technologies: Java (Spring MVC), Scala, Play! Framework, PostgreSQL, Mongo, Redis, Couchbase Server, ActiveMQ Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  5. Main Uses of Shef Quick prototyping Syntax checking Debugging recipes Poke around Chef Server in familiar Ruby environment Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  6. Shef Standalone Demo 6
  7. Commands and Modes Default prompt Attribute mode Recipe mode Run Chef Other useful commands Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  8. Debugging Recipes 8
  9. Summary Setting breakpoints chef_run.rewind chef_run.skip_forward and skip_backwards resources command Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  10. Using Shef as a Client 10
  11. Shef as a Client Interactive testing of node searches Step through one or more recipes Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  12. Debugging Production Issues 12
  13. HipChat Chef Room Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  14. zones.erb 29: <% @members.each do |member| -%> 30: <%= member['hostname'] %> IN CNAME <%= member['ec2']['public_hostname'] %>. 31: <% end -%> Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  15. Which member is causing this to screw up? Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  16. Which member is causing this to screw up? Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  17. [jdunn@dns1 ~]$ shef -z loading configuration: /etc/chef/client.rb Session type: client . . chef > echo off chef > members = search('node', "domain:epicfail.com") chef > members.each do |m| chef > pp "#{m['hostname']}, #{m['ec2'] ['public_hostname']}" chef ?> end "host1, ec2-50-17-43-13.compute-1.amazonaws.com" "host37, ec2-23-23-145-243.compute-1.amazonaws.com" "host3, " NoMethodError: undefined method `[]' for nil:NilClass Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  18. Limitations of Shef Can’t modify run list w/o resetting Attributes mode changes don’t propagate to recipes Client mode can't operate on local cookbooks - must upload to the server (just like a regular Chef client) And yes, the name is confusing. It’s being changed: http:// tickets.opscode.com/browse/CHEF-2925 Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  19. Thanks! @julian_dunn jdunn@secondmarket.com http://engineering.secondmarket.com/ Yes, we’re hiring! Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.
  20. Disclosure This document is intended for those with an in-depth understanding of the high risk nature of alternative investments and these investments may not be suitable for you. This document may not be distributed in either excerpts or in its entirety beyond its intended audience and SecondMarket will not be held responsible if this document is used or is distributed beyond its initial recipient or if it used for any unintended purpose. This document is not a solicitation for an order, and there is not enough information contained in this message in which to make an investment decision and any information contained herein should not be used as a basis for this purpose. To the best of our knowledge, this document and relevant pages are: current as of the date of distribution; subject to change without notice; directed solely at eligible institutional buyside and/or sellside clients, qualified purchasers, qualified institutional brokers and other professional clients; not directed at, may not be suitable for and should not be relied on by general retail clients. SecondMarket does not: produce in-house research; make recommendations to purchase or sell specific securities; provide investment advisory services; and conduct a general retail business. By reading this document you acknowledge that you are not a general retail client. If you are a general retail client then this document is not intended for you. Alternative investments may not be suitable investments for you and you may not possess the sophistication to rely on its contents and should either shred or return to SecondMarket. Neither SecondMarket, its affiliates, nor any of its directors, officers, employees or agents shall have any liability, howsoever arising, for any error or incompleteness of fact or opinion in it or lack of care in its preparation or publication; provided that this shall not exclude liability to the extent that this is impermissible under securities laws. All statements and opinions are liable to change without notice. The SecondMarket logos, graphics, icons, trademarks, service marks and headers appearing herein are service marks, trademarks (whether registered or not) and/or trade dress of SecondMarket Holdings, Inc. (the “Marks”). All other trademarks, company names, logos, service marks and/or trade dress mentioned, displayed, cited or otherwise indicated herein (“Third Party Marks”) are the sole property of their respective owners. The Marks or the Third Party Marks may not be copied, downloaded, displayed, used as metatags, misused, or otherwise exploited in any manner without the prior express written permission of SecondMarket or the owner of such Third Party Mark. Member FINRA | MSRB | SIPC © 2012 SecondMarket Holdings, Inc.

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. Basic Usage\n\nrecipe\nfile &quot;/tmp/ohai2u_chefs.txt&quot; do\n&amp;#xA0; action :create\nend\nrun_chef\n\nShow That It Worked\n\nls(&quot;/tmp&quot;)\n\nTurn Off Echo\n\necho off\n\nUsage with Attributes\n\nattributes\nset[:lolcats]=&apos;Elliot&apos;\nrecipe\nfile &quot;/tmp/#{node[:lolcats]}.txt&quot; do\n&amp;#xA0; content &quot;Meow meow Chefs!&quot;\n&amp;#xA0; action :create\nend\nrun_chef\n\nShow That It Worked Again\n\nls(&quot;/tmp&quot;)\n\nReset The Run List\n\nreset\n\nShow That Chef Primitives Are Available\n\nChef::Log.level = :debug\nrecipe\nChef::Log.debug (&quot;hello&quot;)\n\n
  8. \n
  9. Setting Breakpoints\n\nreset\nrecipe\necho off\nfile &quot;/tmp/breakpoint-demo.txt&quot; do\n&amp;#xA0; action :create\nend\n\nbreakpoint &quot;stopping here&quot;\n\nfile &quot;/tmp/breakpoint-demo.txt&quot; do\n&amp;#xA0; action :delete\nend\n\n
  10. \n
  11. Interactive Testing of Node Searches\n\nGo to server, &quot;shef -z&quot;\n\nresult = search(:node, &quot;fqdn:whatever&quot;)\npp result[0][:kernel][:release]\n\nCan also show result as JSON or YAML, e.g\n\nresult[0].to_json\nresult[0].to_yaml\n\nRunning Chef Recipes in Run List Interactively\n\nOn server, in shef -z do\n\nrecipe\ninclude_recipe &quot;selinux::permissive&quot;\nrun_chef\n\nchef_run.rewind\nchef_run.step\n
  12. \n
  13. We use the Chef HipChat handler to send failure notices to our HipChat room. Very elementary cookbook here: https://github.com/secondmarket/chef-hipchat_handler\n\nThis was on our production DNS server.\n
  14. Here is the recipe. We do a search for members matching a domain of interest and iterate over them to create a CNAME to their EC2 public hostname. Clearly, one of the members is missing this attribute due to some runtime error.\n
  15. \n
  16. Shef to the rescue!\n
  17. Run Shef on production DNS master, literally start typing in the recipe that is failing. Look, host3 is the one which is broken. Now I can log into host3 and see what is wrong with it.\n
  18. \n
  19. \n
  20. \n
Advertisement