NetDocuments-Archive / ad-join-cookbook

Chef cookbook to join windows computer to AD
Apache License 2.0
14 stars 12 forks source link

Chef 13 compat: windows_task now a built-in resource #23

Closed mattlqx closed 6 years ago

mattlqx commented 7 years ago

Chef 13 now has a built-in windows_task resource that gets preferred over the windows cookbook's resource. The new resource no longer has a :change action so a join will fail under Chef 13.

           * windows_task[modify sched task start time] action change

             ================================================================================
             Error executing action `change` on resource 'windows_task[modify sched task start time]'
             ================================================================================

             NoMethodError
             -------------
             undefined method `action_change' for #<Chef::Provider::WindowsTask:0x00000005285d70>
             Did you mean?  action_enable
                     action_create

             Resource Declaration:
             ---------------------
             # In C:/Users/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/ad-join/resources/domain_join.rb

       72:     windows_task 'modify sched task start time' do
       73:       task_name 'chef ad-join' # http://bit.ly/1WDZ1kn
       74:       start_day '06/09/2016'
       75:       start_time '01:00'
       76:       only_if { node['kernel']['cs_info']['domain_role'].to_i == 0 || node['kernel']['cs_info']['domain_role'].to_i == 2 }
       77:       action :change
       78:     end
       79: 
casey-robertson commented 7 years ago

Beat me by 5 minutes.... cookbook worked before vacation, came back and broken. For now, including this in my kitchen.yml solves the problem (at least for local testing).

require_chef_omnibus: 12.19.36

spuder commented 7 years ago

Yes, this is why you should always pin your versions.

knife bootstrap --bootstrap-version 12.19.96

There is issue #20 to add support for chef 13 which hasn't been implemented yet. Pull requests welcome.

The purpose of the :change is to work around an issue where the windows scheduled task would be created at a time in the future.

I've opened an issue with chef https://github.com/chef/chef/issues/6059

This will be fixed in this cookbook, but since we won't be moving to chef 13 for atleast a few more months I can't give an exact time frame for how quickly it will be fixed here.

NimishaS commented 7 years ago

:change action has been removed as it was redundant. Please refer https://github.com/chef/chef/issues/6059#issuecomment-293842575

spuder commented 7 years ago

Starting testing on this.

spuder commented 7 years ago

Removing the :change action breaks chef 12 Pushed 4.12.1 as temporary work around until I figure out how to support both chef 12 and chef 13. Trying to avoid binding chef versions to cookbook versions since it will prevent users from having mixed environments.

mattlqx commented 7 years ago

How about just determining the action based on Chef version?

node['chef_packages']['chef']['version'].split('.').first.to_i <= 12 ? :change : :create

spuder commented 7 years ago

I think querying the running version of chef would be theoretically more reliable that querying the installed version of chef. (since it is possible with the omnibus cookbook to change that mid chef run).

Currently testing something like this

action :change if Chef::VERSION.split('.')[0] = 12

or

 action :change if Gem::Requirement.create('>= 13').satisfied_by?(Gem::Version.create(Chef::VERSION))
spuder commented 7 years ago

This isn't a simple one line change like I would have hoped. This will require a rewrite of the scheduled tasks and a release of cookbook 5.0.0.

spuder commented 6 years ago

Chef 13.4.19 appears to have fixed the windows tasks. Hoping to have this fixed in the 5.0.0 release of ad-join

spuder commented 6 years ago

Fixed in #29