Skip to content

Instantly share code, notes, and snippets.

@SeanSith
Last active September 23, 2022 18:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeanSith/7cc629f43858f95b44f0ab2f87af40d4 to your computer and use it in GitHub Desktop.
Save SeanSith/7cc629f43858f95b44f0ab2f87af40d4 to your computer and use it in GitHub Desktop.
Update Chef-Client to Cinc-Client using chef_client_updater cookbook
node.override['chef_client']['bin'] = '/usr/bin/cinc-client'
node.override['chef_client']['conf_dir'] = '/etc/cinc'
node.override['chef_client']['log_dir'] = '/var/log/cinc'
node.override['chef_client']['log_file'] = 'client.log'
node.override['chef_client']['cron']['log_file'] = "#{node['chef_client']['log_dir']}/#{node['chef_client']['log_file']}"
node.override['chef_client']['run_path'] = '/var/run/cinc'
node.override['chef_client']['file_backup_path'] = '/var/lib/cinc'
node.override['chef_client']['log_rotation']['postrotate'] = 'systemctl reload cinc-client.service >/dev/null || :'
if node[:packages][:chef]
directory '/etc/cinc' do
owner 'root'
group 'root'
mode '0755'
recursive true
action :create
end
[ 'client.rb',
'first-boot.json'].each do |name|
remote_file "/etc/cinc/#{name}" do
source "file:///etc/chef/#{name}"
owner 'root'
group 'root'
mode '0644'
action :create_if_missing
ignore_failure true
end
end
remote_file '/etc/cinc/client.pem' do
source 'file:///etc/chef/client.pem'
owner 'root'
group 'root'
mode '0600'
action :create_if_missing
ignore_failure true
end
chef_gem 'mixlib-install' do
action :purge
end
end
chef_client_updater 'cinc-client' do
product_name 'cinc'
rubygems_url 'https://packagecloud.io/cinc-project/stable'
end
# In theory, this shouldn't run until the second time.
if node[:packages][:cinc]
package 'chef' do
action :purge
end
[
'/opt/chef',
'/etc/chef',
'/var/lib/chef',
'/var/log/chef',
'/var/run/chef'].each do |dir|
directory dir do
action :delete
recursive true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment