Chef Vsphere Provisioning

Introduction

Here we are creating the new machine in Vsphere which stored in the template and make that machine as a node by using the chef.


Pre-request

Before creating a recipe directly to provision vsphere we need to follow some pre requesting steps which are needed for this process,

Install knife-vsphere, 

C:\\\\\\\\\\\\\\\\Users\\\\\\\\\\\\\\\\zippyops\\\\\\\\\\\\\\\\Pictures\\\\\\\\\\\\\\\\vc1.PNG

Add the vsphere in knife.rb,

C:\\\\\\\\\\\\\\\\Users\\\\\\\\\\\\\\\\zippyops\\\\\\\\\\\\\\\\Pictures\\\\\\\\\\\\\\\\vc2.PNG

knife[:vsphere_host] = "hostname"

knife[:vsphere_user] = "username" 

knife[:vsphere_pass] = "your password"       

knife[:vsphere_dc] = "your-datacenter"

knife[:vsphere_insecure] = true


Make my master itself node,

C:\\\\\\\\\\\\\\\\Users\\\\\\\\\\\\\\\\zippyops\\\\\\\\\\\\\\\\Pictures\\\\\\\\\\\\\\\\vc3.PNG

Create the cookbook with the name Vsphere,

C:\\\\\\\\\\\\\\\\Users\\\\\\\\\\\\\\\\zippyops\\\\\\\\\\\\\\\\Pictures\\\\\\\\\\\\\\\\vc4.PNG

Write the recipe to create the machine in Vsphere,

C:\\\\\\\\\\\\\\\\Users\\\\\\\\\\\\\\\\zippyops\\\\\\\\\\\\\\\\Pictures\\\\\\\\\\\\\\\\vc5.PNG


execute "remove machine in Vsphere" do

  command "knife vsphere vm delete cent"

  cwd "/home/zippyops/chef-repo/.chef"

  ignore_failure true

end

execute "remove the node" do

  command "knife node bulk delete cent -y"

  cwd "/home/zippyops/chef-repo/.chef"

  ignore_failure true

end

execute "remove the client" do

  command "knife client bulk delete cent -y"

  cwd "/home/zippyops/chef-repo/.chef"

  ignore_failure true

end

execute "creating new machine and adding as a node" do

  command "knife vsphere vm clone cent --template chef --datastore datastore1 -cips 192.168.1.45/24 --ccpu 2 --cram 1 --bootstrap --ssh-user root --ssh-password zippyops"

  cwd "/home/zippyops/chef-repo/.chef"

end

After creating the recipe, upload it to the server and make it to run list,

C:\\\\\\\\\\\\\\\\Users\\\\\\\\\\\\\\\\zippyops\\\\\\\\\\\\\\\\Pictures\\\\\\\\\\\\\\\\vc6.PNG

output Run chef-client in master, and while running it will delete if the machine with the name cent and the node and client, and it will create the new machine from the template and made the new machine as a node.

C:\\\\\\\\\\\\\\\\Users\\\\\\\\\\\\\\\\zippyops\\\\\\\\\\\\\\\\Pictures\\\\\\\\\\\\\\\\vc7.PNG


C:\\\\\\\\\\\\\\\\Users\\\\\\\\\\\\\\\\zippyops\\\\\\\\\\\\\\\\Pictures\\\\\\\\\\\\\\\\vc8.PNG



Recent Comments

No comments

Leave a Comment