Chef-provisioning / knife / test-kitchen support for running chef-client on windows via schtask

Using winrm for bootstrapping windows via chef-provisioning, knife
bootstrap, and test-kitchen seems to be the norm, but it also seems to be
the wrong way to run chef on windows.

It’s been heavily suggested that we run chef-client as a schtask and not
via winrm. (or even as a windows service)

I’d like to utilize all of our existing toolchain if possible, and one
thought I had was to:

  1. create a schtask for chef-client
  2. find a way to run the schtask immediately, grab the output, and exit code
  3. wrap all that up in a command to run via winrm, call it
    chef-client-task.bat
  4. ???
  5. Profit for our existing chef tooling!!!

I’m going to start looking into this approach, but I suspect there may be
better alternative and would love to hear how other windows chef users do
their day to day development and production work.

Thanks,
@hippiehacker
(from an RV in Burlington Vermont this week)

It’s not especially hard to cause a scheduled task to run:
https://github.com/smurawski/chef-zero-scheduled-task/blob/master/lib/kitchen/provisioner/chef_zero_scheduled_task.rb is a scheduled task provisioner for t-k; i’m aiming to bring that down into mixlib-install this week so that it’s accessible to t-k’s core winrm provisioner and chef-provisioning.


Thom May

On 14 September 2015 at 13:31:18, Chris McClimans (chef@hippiehacker.org) wrote:

Using winrm for bootstrapping windows via chef-provisioning, knife bootstrap, and test-kitchen seems to be the norm, but it also seems to be the wrong way to run chef on windows.

It’s been heavily suggested that we run chef-client as a schtask and not via winrm. (or even as a windows service)

I’d like to utilize all of our existing toolchain if possible, and one thought I had was to:

  1. create a schtask for chef-client
  2. find a way to run the schtask immediately, grab the output, and exit code
  3. wrap all that up in a command to run via winrm, call it chef-client-task.bat
  4. ???
  5. Profit for our existing chef tooling!!!

I’m going to start looking into this approach, but I suspect there may be better alternative and would love to hear how other windows chef users do their day to day development and production work.

Thanks,
@hippiehacker
(from an RV in Burlington Vermont this week)