Chef Infra Automation Commands

Chef Infra Automation Commands
Quick Command Guide reference:

 

knife bootstrap IPADDRESS(hostname) –sudo -x username -P password -N target1 (This installs chef-client and validates)

knife bootstrap WIN-I2R3V7Q9AFV –sudo -x username -P passwd -N nodename

 

Bootstrap Virtual box

**********************

knife bootstrap 192.168.1.101 –ssh-user vasanth –ssh-password ‘vasanth123’ –sudo –use-sudo-password –node-name virtuenode

knife bootstrap x.x.x.x –ssh-user ubuntu –sudo –identity-file ./.chef/mykey.pem –run-list webserver

knife bootstrap 172.31.51.157 –ssh-user ec2-user –sudo –identity-file ./.chef/user.pem

knife bootstrap 172.31.51.157 –ssh-user ec2-user –sudo –identity-file “C:Usersuser.sshid_rsa”

 

knife bootstrap windows winrm ADDRESS –winrm-user USER –winrm-password ‘PASSWORD’ –node-name target3 –run-list ‘recipe[learn_chef_iis]’ –winrm-transport ssl –winrm-ssl-verify-mode verify_none

knife bootstrap windows winrm WIN-I2R3V7Q9AFV –winrm-user username –winrm-password ‘passwd’ –node-name target3 –run-list ‘recipe[learn_chef_iis]’ –winrm-transport ssl –winrm-ssl-verify-mode verify_none

knife cookbook create apache

knife cookbook upload apache

Login via putty and run “sudo chef-client”

knife node show target1

knife node show target1 -l

knife node show target1 -Fj

knife node show target1 -a fqdn

knife search node “*:*” -a fqdn

 

From workstation

*******************

Using Chefdk

chef generate repo chef-repo

chef generate cookbook webserver

 

Installing and configuring kitchen

**********************************

Under your Chef local repo

gem install test-kitchen

gem install test-kitchen

kitchen init –create-gemfile /          kitchen init –driver=kitchen-vagrant

kitchen –version

kitchen list

kitchen create default-ubuntu-1404

kitchen list

kitchen converge default-ubuntu-1404

kitchen login default-ubuntu-1404

kitchen verify default-ubuntu-1404

kitchen verify 64 (centos)

kitchen test default-ubuntu-1404

kitchen help

kitchen help init

kitchen destroy

gem install test-kitchen

kitchen init –create-gemfile /          kitchen init –driver=kitchen-vagrant

kitchen –version

kitchen list

kitchen create default-ubuntu-1404

kitchen list

kitchen converge default-ubuntu-1404

kitchen login default-ubuntu-1404

kitchen verify default-ubuntu-1404

kitchen verify 64 (centos)

kitchen test default-ubuntu-1404

kitchen help

kitchen help init

kitchen destroy

Data bag

*********

knife data bag create databagname 1.x.x

Browsing the supermarket

*************************

knife cookbook site list

knife cookbook site search mysql

knife cookbook site show mysql

knife cookbook site show mysql 0.10.0

knife cookbook site download mysql

knife cookbook site install mysql

knife -v

Uploading cookbooks to Supermarket

*****************************************

knife cookbook site share “my_apache2_cookbook” “Web Servers”

Delete Node from Chef server

*****************************

knife node delete my_node (delete node in server)

knife node client my_node (delete client object in server)

Create Roles and environment

*****************************

subl roles/web_server.rb

knife role from file web_server.rb

knife node edit server

sudo chef-client

knife environment create book

knife environment list

knife node list

knife node list -E book

knife node edit my_server

knife node list -E book

knife environment edit book

 

Leave a Comment

Your email address will not be published. Required fields are marked *