misc.rb 1.69 KB
#
# Author:: Earth U (<sysadmin @ chromedia.com>)
# Cookbook Name:: cfe-server
# Recipes:: misc
#
# Copyright 2016, Chromedia Far East, Inc.
#
# 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.
#

node[cookbook_name]['misc']['cronjobs'].each do |cjob|
  sched = cjob[:sched].split(' ')
  is_enable = cjob.has_key?(:enable) ? cjob[:enable] : true
  cron_d cjob[:name] do
    command cjob[:command]
    minute  sched[0]
    hour    sched[1]
    day     sched[2]
    month   sched[3]
    weekday sched[4]
    mailto  cjob[:mailto]
    path    '/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin'
    action( is_enable ? :create : :delete )
  end
end

package 'logrotate'

node[cookbook_name]['misc']['logrotatejobs'].each do |ljob|
  jname = "#{node[cookbook_name]['misc']['logrotate']['conf_dir']}/"\
          "#{ljob[:name]}"
  is_enable = ljob.has_key?(:enable) ? ljob[:enable] : true
  template jname do
    source 'logrotate.erb'
    variables(
      :path    => ljob[:path],
      :options => ljob[:options]
    )
    action( is_enable ? :create : :delete )
  end
end

template node[cookbook_name]['misc']['sshd']['conf_path'] do
  mode 0644
  variables(
    :ports => node[cookbook_name]['misc']['sshd']['ports']
  )
end