Last active
December 30, 2015 03:48
-
-
Save cpuguy83/7771365 to your computer and use it in GitHub Desktop.
Custom Chef bootstrap for Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'winrm' | |
IP=ARGV[0] | |
USER=ARGV[1] | |
endpoint = "http://#{IP}:5985/wsman" | |
winrm = WinRM::WinRMWebService.new endpoint, :plaintext, user: USER, pass: 'secret', basic_auth_only: true | |
winrm.set_timeout 1800 | |
installer_file = "c:\\Users\\#{USER}\\Downloads\\chef_client.msi" | |
installer_cmd = "msiexec /qn /i #{installer_file} ADDLOCAL=\"ChefServiceFeature,ChefClientFeature\"" | |
puts 'Installating Chef' | |
install_output = winrm.cmd installer_cmd | |
sleep 300 | |
puts 'Configuring Chef' | |
winrm.cmd %Q(mv c:\\Users\\#{USER}\\Downloads\\client.rb c:\\chef\\client.rb) | |
winrm.cmd %Q(mv c:\\Users\\#{USER}\\Downloads\\chef-validator.pem c:\\chef\\validation.pem) | |
winrm.cmd 'net start chef-client || net start chef-client' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment