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,
Add the vsphere in knife.rb,
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,
Create the cookbook with the name Vsphere,
Write the recipe to create the machine in Vsphere,
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,
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.
Recent Comments
No comments
Leave a Comment
We will be happy to hear what you think about this post