Cooking on Windows Sever..

Hi guys!

I have to manage Windows Server 2008 using Chef..

First of all, I need to choose the strategy for bootstrapping the new node and I am going to use an unattended bootstrap..

Configuring network card to talk with 33.33.33.10 (my Chef server)

Screen Shot 2016-08-04 at 18.19.09

Download and install  chef-client for Windows from https://downloads.chef.io/chef-client/windows/

Screen Shot 2016-08-04 at 15.41.06.png

Copy client.rb and validation.pem to c:\chef and launch chef-client from the command line.

This my new Windows node!

Screen Shot 2016-08-04 at 18.09.15

Let’s prepare a simple cookbook named mywindows:

knife cookbook create mywindows

Let’s insert the following resources in recipes/default.rb

#Modify the hosts file
template "C:\\Windows\\System32\\drivers\\etc\\hosts" do
  source "hosts.erb"
  action :create
end

 

#Restart an array of services
[ "Dnscache" , "UxSms" ].each do |s|
 service s do
    action :restart
   end
end

 

#Update Group Policy
execute 'gpupdate' do
  command "gpupdate.exe"
end

 

#Create a key into the registry
windows_registry 'HKCU\Software\Test' do
  values 'MySuperKEy' => Time.now
  action :create
end

 

#Install Putty
windows_package 'Putty' do
  source 'C:\\putty-0.60-installer.exe'
  installer_type :inno
  action :install
end

 

#Enable a Windows Feature
windows_feature "WindowsServerBackup" do
  action :install
end

Run chef-client and all works fine!

Screen Shot 2016-08-04 at 18.34.08.png

Bye!

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s