class Formatron::Chef::WinRM
Perform commands on chef nodes over WinRM
Public Class Methods
new(administrator_name:, administrator_password:)
click to toggle source
# File lib/formatron/chef/winrm.rb, line 7 def initialize(administrator_name:, administrator_password:) @administrator_name = administrator_name @administrator_password = administrator_password end
Public Instance Methods
bootstrapped?(hostname:)
click to toggle source
# File lib/formatron/chef/winrm.rb, line 24 def bootstrapped?(hostname:) Formatron::Util::WinRM.exec( hostname: hostname, administrator_name: @administrator_name, administrator_password: @administrator_password, command: 'if (-not (Test-Path C:\chef\client.pem)) { exit 1 }' ) true rescue false end
run_chef_client(hostname:)
click to toggle source
# File lib/formatron/chef/winrm.rb, line 12 def run_chef_client(hostname:) # use the first-boot.json to ensure the runlist is correct # if the node fails to converge the first time (in which case # the server will show an empty run list for the node) Formatron::Util::WinRM.exec( hostname: hostname, administrator_name: @administrator_name, administrator_password: @administrator_password, command: 'chef-client -j C:\chef\first-boot.json' ) end