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 # http://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_package = "chef_#{node[:chef][:client][:version]}_amd64.deb"
22 directory "/var/cache/chef" do
28 Dir.glob("/var/cache/chef/chef_*.deb").each do |deb|
29 next if deb == "/var/cache/chef/#{chef_package}"
37 remote_file "/var/cache/chef/#{chef_package}" do
38 source "https://packages.chef.io/stable/ubuntu/10.04/#{chef_package}"
46 dpkg_package "chef" do
47 source "/var/cache/chef/#{chef_package}"
48 version node[:chef][:client][:version]
51 directory "/etc/chef" do
57 template "/etc/chef/client.rb" do
58 source "client.rb.erb"
64 file "/etc/chef/client.pem" do
70 template "/etc/chef/report.rb" do
71 source "report.rb.erb"
77 template "/etc/logrotate.d/chef" do
78 source "logrotate.erb"
84 directory "/etc/chef/trusted_certs" do
90 template "/etc/chef/trusted_certs/verisign.pem" do
91 source "verisign.pem.erb"
97 directory node[:ohai][:plugin_dir] do
103 directory "/var/log/chef" do
109 if node[:lsb][:release].to_f >= 15.10
110 systemd_service "chef-client" do
111 description "Chef client"
112 after "network.target"
113 exec_start "/usr/bin/chef-client -i 1800 -s 20"
117 service "chef-client" do
118 provider Chef::Provider::Service::Systemd
119 action [:enable, :start]
120 supports :status => true, :restart => true, :reload => true
121 subscribes :restart, "dpkg_package[chef]"
122 subscribes :restart, "systemd_service[chef-client]"
123 subscribes :restart, "template[/etc/chef/client.rb]"
124 subscribes :restart, "template[/etc/chef/report.rb]"
127 template "/etc/init/chef-client.conf" do
128 source "chef-client.conf.erb"
134 service "chef-client" do
135 provider Chef::Provider::Service::Upstart
136 action [:enable, :start]
137 supports :status => true, :restart => true, :reload => true
138 subscribes :restart, "dpkg_package[chef]"
139 subscribes :restart, "template[/etc/init/chef-client.conf]"
140 subscribes :restart, "template[/etc/chef/client.rb]"
141 subscribes :restart, "template[/etc/chef/report.rb]"