#
# Cookbook:: timezone_iii
# Recipe:: suse
#
# Copyright:: 2017, Brad Beveridge
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This sets the timezone on SUSE distributions

v_major, _v_minor = node['platform_version'].split(/\./)

template '/etc/sysconfig/clock' do
  v_major.to_i == 11 ? source 'suse/clock.suse11.erb' : source 'suse/clock.erb'
  owner 'root'
  group 'root'
  mode '0644'
  notifies :run, 'execute[tz-update]'
end

execute 'tz-update' do
  command "/usr/sbin/zic -l #{node['timezone_iii']['timezone']}"
  action :nothing
end

#
# Cookbook:: timezone_iii
# Recipe:: suse
#
# Copyright:: 2017, Brad Beveridge
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This sets the timezone on SUSE distributions

v_major, _v_minor = node['platform_version'].split(/\./)
template_file = v_major.to_i == 11 ? 'suse/clock.suse11.erb' : 'suse/clock.erb'

template '/etc/sysconfig/clock' do
  source template_file
  owner 'root'
  group 'root'
  mode '0644'
  notifies :run, 'execute[tz-update]'
end

execute 'tz-update' do
  command "/usr/sbin/zic -l #{node['timezone_iii']['timezone']}"
  action :nothing
end

Fix definition of source file in resource
Fix definition of source file in resource

Fix syntax of defining either of 2 source files for the template, based on SUSE major release