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 chef_version = node[:chef][:client][:version]
21 chef_package = "chef_#{chef_version}-1_amd64.deb"
23 directory "/var/cache/chef" do
29 Dir.glob("/var/cache/chef/chef_*.deb").each do |deb|
30 next if deb == "/var/cache/chef/#{chef_package}"
38 remote_file "/var/cache/chef/#{chef_package}" do
39 source "https://packages.chef.io/files/stable/chef/#{chef_version}/ubuntu/#{node[:lsb][:release]}/#{chef_package}"
47 dpkg_package "chef" do
48 source "/var/cache/chef/#{chef_package}"
49 version "#{chef_version}-1"
52 directory "/etc/chef" do
58 template "/etc/chef/client.rb" do
59 source "client.rb.erb"
65 file "/etc/chef/client.pem" do
71 template "/etc/chef/report.rb" do
72 source "report.rb.erb"
78 template "/etc/logrotate.d/chef" do
79 source "logrotate.erb"
85 directory "/etc/chef/trusted_certs" do
91 template "/etc/chef/trusted_certs/verisign.pem" do
92 source "verisign.pem.erb"
98 directory node[:ohai][:plugin_dir] do
104 directory "/var/log/chef" do
110 if node[:lsb][:release].to_f >= 15.10
111 systemd_service "chef-client" do
112 description "Chef client"
113 after "network.target"
114 exec_start "/usr/bin/chef-client -i 1800 -s 20"
118 template "/etc/init/chef-client.conf" do
119 source "chef-client.conf.erb"
126 service "chef-client" do
127 action [:enable, :start]
128 if node[:lsb][:release].to_f >= 15.10
129 restart_command "systemctl kill --signal=TERM chef-client.service"
131 supports :status => true, :restart => true, :reload => true
132 subscribes :restart, "dpkg_package[chef]"
133 subscribes :restart, "template[/etc/init/chef-client.conf]"
134 subscribes :restart, "template[/etc/chef/client.rb]"
135 subscribes :restart, "template[/etc/chef/report.rb]"