5 # Copyright:: 2010, OpenStreetMap Foundation
 
   7 # Licensed under the Apache License, Version 2.0 (the "License");
 
   8 # you may not use this file except in compliance with the License.
 
   9 # You may obtain a copy of the License at
 
  11 #     https://www.apache.org/licenses/LICENSE-2.0
 
  13 # Unless required by applicable law or agreed to in writing, software
 
  14 # distributed under the License is distributed on an "AS IS" BASIS,
 
  15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16 # See the License for the specific language governing permissions and
 
  17 # limitations under the License.
 
  20 cache_dir = Chef::Config[:file_cache_path]
 
  22 chef_version = node[:chef][:client][:version]
 
  23 chef_package = "chef_#{chef_version}-1_amd64.deb"
 
  25 directory "/var/cache/chef" do
 
  30 Dir.glob("#{cache_dir}/chef_*.deb").each do |deb|
 
  31   next if deb == "#{cache_dir}/#{chef_package}"
 
  39 ubuntu_release = node[:lsb][:release]
 
  41 remote_file "#{cache_dir}/#{chef_package}" do
 
  42   source "https://packages.chef.io/files/stable/chef/#{chef_version}/ubuntu/#{ubuntu_release}/#{chef_package}"
 
  50 dpkg_package "chef" do
 
  51   source "#{cache_dir}/#{chef_package}"
 
  52   version "#{chef_version}-1"
 
  55 directory "/etc/chef" do
 
  61 template "/etc/chef/client.rb" do
 
  62   source "client.rb.erb"
 
  68 file "/etc/chef/client.pem" do
 
  74 template "/etc/chef/report.rb" do
 
  75   source "report.rb.erb"
 
  81 template "/etc/logrotate.d/chef" do
 
  82   source "logrotate.erb"
 
  88 directory "/etc/chef/trusted_certs" do
 
  94 template "/etc/chef/trusted_certs/verisign.pem" do
 
  95   source "verisign.pem.erb"
 
 101 directory node[:ohai][:plugin_dir] do
 
 107 directory "/var/log/chef" do
 
 113 systemd_service "chef-client" do
 
 114   description "Chef client"
 
 115   exec_start "/usr/bin/chef-client"
 
 119 systemd_timer "chef-client" do
 
 120   description "Chef client"
 
 121   after "network.target"
 
 123   on_unit_inactive_sec 25 * 60
 
 124   randomized_delay_sec 10 * 60
 
 127 service "chef-client.timer" do
 
 128   action [:enable, :start]
 
 131 service "chef-client.service" do
 
 133   subscribes :stop, "service[chef-client.timer]"