Coder Social home page Coder Social logo

chef-repo's Introduction

Chef notes

  • chef-apply - runs a single recipe from the command line
  • chef-client - uploads policy on your node. Typically downloads and runs the latest Chef code from the Chef server. However, possible to run in the local mode
  • kitchen - enabled to run cookbooks in a temporary environment. Steps: kitchen create -> kitchen converge -> kitchen login -> verify -> kitchen destroy
  • knife - enables you to communicate with the Chef server from your workstation.
  • berks - dependency management tool

Apply particular recipe

$ chef-apply file_name.rp

or

$ chef-client --local-mode hello.rb

Cookbooks

To reference a cookbook from inside another, put it's name into metadata.rb file, e.g. put depends 'apt', '~> 4.0', then include it into recipe recipes/default.rb include_recipe 'apt::default'

Create a cookbook

$ chef generate cookbook cookbooks/learn_chef_apache

Generates new template inside given cookbook

$ chef generate template cookbooks/learn_chef_apache2 index.html

Write recipe in the file 'COOKBOOK_NAME/recipes/default.rba'

Run the cookbook

$ sudo chef-client --local-mode --runlist 'recipe[learn_chef_apache2]'

Create the recipe

$ chef generate recipe cookbooks/awesome_customers_ubuntu firewall

Create the custom attributes file

$ chef generate attribute cookbooks/awesome_customers_ubuntu default

#Knife Use file ./chef/knife.rb for Knife configuration Download cookbook from supermaket.chef.io

$ knife cookbook site download COOKBOOK_NAME_IN_supermarket.chef.io

Upload cookbook to the Chef server

$ knife cookbook upload COOKBOOK_NAME

Bootstrap node

$ knife bootstrap NODE_IP_ADDRESS --ssh-user USER --ssh-password 'PASSWORD' --sudo -use-sudo-password -N cnode1 --run-list 'recipe[COOKBOOK_NAME]' -E ENVIRONMENT_NAME -V

Node list (inside folder where is unzipped starter kit)

$ knife node list

Particular node

$ knife node show NODE_NAME

Upload cookbook to node

knife ssh localhost --ssh-port 2200 'sudo chef-client' --manual-list --ssh-user vagrant --identity-file /home/vytautas/learn-chef/chef-server/.vagrant/machines/node1-ubuntu/virtualbox/private_key
knife ssh 'name:NODE_NAME' 'sudo chef-client' --ssh-user root --identity-file ~/.ssh/id_rsa --attribute ipaddress --run-list='cookbook[COOKBOOK_NAME]'

Berks

Set up a file named Berksfile.lock that helps Test Kitchen manage dependent cookbooks

$ berks install

Upload cookbooks and dependencies to the Chef server

$ SSL_CERT_FILE='.chef/trusted_certs/chef-server_test.crt' berks upload

Upload role to Chef server

$ knife role from file roles/web.json

Test Kitchen

Command chef generate cookbook which creates cookbooks, creates file named .kitchen.yml provisioner chef_zero enables you to mimic a Chef server environment on the local machine

Create the Test Kitchen instance

See what's in the kitchen:

$ kitchen list

Create the instance

$ kitchen create

Converge

$ kitchen converge

Test kitchen runs chef-client on the instance. When chef-client run completes cuccessfully, Test Kitchen exits with code 0 (to check exit code run echo $?)

Verify

Login using ssh

$ kitchen login

Execute single command

$ kitchen exec -c 'wget -qO- localhost

Destroy

Destroy instance

$ kitchen destroy

Vagrant

Check Vagrant version

$ vagrant --version

Download specific Vagrant box

$ vagrant box add bento/ubuntu-14.04 --provider=virtualbox

Create configuration file named Vagrantfile

$ vagrant init bento/ubuntu-14.04

Bring up an instance (create and configure VM instance)

$ vagrant up

Connect to the instance

vagrant ssh

Cleaning up

$ vagrant destroy --force

chef-repo's People

Contributors

varminas avatar

Watchers

James Cloos avatar  avatar

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.