Giter VIP home page Giter VIP logo

cookbook-style-guide's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cookbook-style-guide's Issues

Don't recomend using globals.

In the "Hints" section theres a recommendation to use global variables. This seems like leading someone down a path of bad habits. In the provided use case the global seems like a bad idea. as it should be driven from an attribute. If one must provide global variables should they not be const with conditional assignment? So that the recipe can be included many times without exception. Even this screams to me of bad form, but maybe more safe/predictable ?

IMHO globals should not be something we offer as an acceptable style.

Placement of include_recipe

"Ruby include and Chef require_recipe are always put at the top of a Recipe, just after comments, and before globals and constants."

This is generally common, but may not be bad style. Here's why.

When Chef processes a recipe, it adds the resources it finds to the Resource Collection. When it encounters an "include_recipe", it begins processing that recipe, adding its resources to the Resource Collection. Order matters, and depending on what your cookbook is doing, you may want to reuse another recipe's resources before you continue on.

For example, in (Opscode's nginx::default recipe)[https://github.com/opscode-cookbooks/nginx/blob/master/recipes/default.rb#L33], we do this:

package "nginx"

service "nginx" do 
  action :enable
end

include_recipe "nginx::commons"

service "nginx" do
  action :start
end

There's a couple nuances here, and one may warrant a style guide update :).

We're enabling the service, but not starting it. The "nginx::commons" recipe contains a number of config files and other resources, so we don't want to automatically assume that the service should be started yet. It might be by the package manager, but that's a different story. At the end we make sure that the service is started, so if it were unable to start for some reason, Chef would do the right thing. The "commons" recipe contains resources that are also used by the "nginx::source" recipe, so we want to be able to include those in the right place during the Chef run.

I haven't read the whole guide, so I'm not sure if this is represented, but the placement of a service with action :enable at the top (often after package) and at the bottom with action :start (after the config file resources) is likewise a good practice, based on the ways that distributions decide to manage services with post install package scripts (or not...).

I can open a second issue if that is necessary. Hope this helps, and thank you for starting this project!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.