NetDocuments-Archive / ad-join-cookbook

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

Leave action of domain_join not working on Chef 13 #31

Closed yamamoto52 closed 6 years ago

yamamoto52 commented 6 years ago

In windows_task resource of :leave action, it should contain the same condition as in action :join as stated by the comment:

Chef 12 uses :change, Chef 13.4.19 uses :create to modify existing tasks http://bit.ly/2wbDTzP

Join action:

# Modify the start time to make sure GP doesn't set task into future
  # https://github.com/NetDocuments/ad-join-cookbook/issues/13
  # schedtask.exe won't allow this to be combined with task creation
  windows_task 'modify sched task start time' do
    task_name 'chef ad-join' # http://bit.ly/1WDZ1kn
    start_day '06/09/2016'
    start_time '01:00'
    only_if { node['kernel']['cs_info']['domain_role'].to_i == 0 || node['kernel']['cs_info']['domain_role'].to_i == 2 }
    # Chef 12 uses :change, Chef 13.4.19 uses :create to modify existing tasks http://bit.ly/2wbDTzP
    action :change if Gem::Requirement.create('~> 12').satisfied_by?(Gem::Version.create(Chef::VERSION))
  end

Leave action:

# Modify the start time to make sure GP doesn't set task into future
  # https://github.com/NetDocuments/ad-join-cookbook/issues/13
  # schedtask.exe won't allow this to be combined with task creation
  windows_task 'chef ad-join leave start time' do
    task_name 'chef ad-join leave' # http://bit.ly/1WDZ1kn
    start_day '06/09/2016'
    start_time '01:00'
    only_if { node['kernel']['cs_info']['domain_role'].to_i == 1 || node['kernel']['cs_info']['domain_role'].to_i == 3 }
    action :change
  en

This issue generate the following error on Chef 13:

Chef::Exceptions::ValidationFailed
----------------------------------
Option action must be equal to one of: nothing, create, delete, run, end, enable, disable!  You passed :change.
spuder commented 6 years ago

Should be fixed in 5.0.2 See #32