ckelner / twc-chef-intermediate-training

OpsCode Chef Intermediate training at TWC Dec 2015 -- clone of https://github.com/chef-training/chef-fundamentals-repo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

twc-chef-intermediate-training

This is a clone of chef-training/chef-fundamentals-repo for The Weather Company (weather.com) Intermediate Chef training.

Training PDF (internal TWC Google Drive) Chef_Intermediate_v1.2.1.pdf Replace section 6 with 06-implementing_chef_handlers-file_handler.pptx.pdf

Notes

Common commands

Knife

  • knife cookbook upload -a
    • uploads all cookbooks in this repo
  • knife role from file base.rb web.rb
    • uploads all roles in this repo
  • knife environment from file dev.rb production.rb
    • uploads all the environments in this repo
  • knife upload data_bags
    • uploads all data bags in this repo
  • knife bootstrap <ipaddr> -x <user> -P <pass> --sudo -N <nodename> -r 'role[<rolename>]' --bootstrap-version <ver>
    • bootstraps an existing node using user/name password and users key from Chef org. Does not use the validator key.
  • knife ssh "name:<nodename>" -x <user> -P <pass> "sudo chef-client"

Chef

  • chef generate cookbook <path-to-cookbook-and-file-name>
    • guess? :)
  • chef generate file <path-to-cookbook> <filename>
    • guess again?

Foodcritic

A cookbook linter

  • foodcritic <cookbook-path>
    • Runs foodcritic against a cookbook
    • example output:
      FC003: Check whether you are running with chef server before using server-specific features: cookbooks/apache/recipes/ip-logger.rb:1
      FC016: LWRP does not declare a default action: cookbooks/apache/resources/vhost.rb:1
      FC034: Unused template variables: cookbooks/apache/templates/default/index.html.erb:1
      

Rubocop

A Ruby static code analyzer

  • rubocop
    • Runs rubocop
  • rubocop --auto-gen-config
    • generates a rubocop ignore file

Rspec // Chefspec

See: https://docs.chef.io/chefspec.html

  • rspec --init
    • Initialize rspec in a cookbook
  • rspec
    • Runs rspec

==========================

Original Readme from chef-training/chef-fundamentals-repo

==========================

All installations require a central workspace known as the chef-repo. This is a place where primitive objects--cookbooks, roles, environments, data bags, and chef-repo configuration files--are stored and managed.

The chef-repo should be kept under version control, such as git, and then managed as if it were source code.

Knife Configuration

Knife is the command line interface for Chef. The chef-repo contains a .chef directory (which is a hidden directory by default) in which the Knife configuration file (knife.rb) is located. This file contains configuration settings for the chef-repo.

The knife.rb file is automatically created by the starter kit. This file can be customized to support configuration settings used by cloud provider options and custom knife plugins.

Also located inside the .chef directory are .pem files, which contain private keys used to authenticate requests made to the Chef server. The USERNAME.pem file contains a private key unique to the user (and should never be shared with anyone). The ORGANIZATION-validator.pem file contains a private key that is global to the entire organization (and is used by all nodes and workstations that send requests to the Chef server).

More information about knife.rb configuration options can be found in the documentation for knife.

Cookbooks

A cookbook is the fundamental unit of configuration and policy distribution. A sample cookbook can be found in cookbooks/starter. After making changes to any cookbook, you must upload it to the Chef server using knife:

$ knife upload cookbooks/starter

For more information about cookbooks, see the example files in the starter cookbook.

Roles

Roles provide logical grouping of cookbooks and other roles. A sample role can be found at roles/starter.rb.

Getting Started

Now that you have the chef-repo ready to go, check out Learn Chef to proceed with your workstation setup. If you have any questions about Enterprise Chef you can always ask our support team for a helping hand.

About

OpsCode Chef Intermediate training at TWC Dec 2015 -- clone of https://github.com/chef-training/chef-fundamentals-repo


Languages

Language:Ruby 85.7%Language:HTML 9.2%Language:Shell 5.1%