Class: Formatron::Chef::WinRM
- Inherits:
-
Object
- Object
- Formatron::Chef::WinRM
- Defined in:
- lib/formatron/chef/winrm.rb
Overview
Perform commands on chef nodes over WinRM
Instance Method Summary collapse
- #bootstrapped?(hostname:) ⇒ Boolean
-
#initialize(administrator_name:, administrator_password:) ⇒ WinRM
constructor
A new instance of WinRM.
- #run_chef_client(hostname:) ⇒ Object
Constructor Details
#initialize(administrator_name:, administrator_password:) ⇒ WinRM
Returns a new instance of WinRM.
7 8 9 10 |
# File 'lib/formatron/chef/winrm.rb', line 7 def initialize(administrator_name:, administrator_password:) @administrator_name = administrator_name @administrator_password = administrator_password end |
Instance Method Details
#bootstrapped?(hostname:) ⇒ Boolean
24 25 26 27 28 29 30 31 32 33 34 |
# 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:) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# 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 |