Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Chef 12.5 custom resources #235

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
AllCops:
TargetChefVersion: 11
TargetChefVersion: 12.5
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This file is used to list changes made in each version of the chef_client_updater cookbook.

## Unreleased

- Switch to Chef 12.5 custom resources - [@detjensrobert](https://github.com/detjensrobert)
- Enable unified_mode (if supported) - [@detjensrobert](https://github.com/detjensrobert)

## 3.12.0 (2021-04-14)

- Bump version of mixlib-install we install to 3.12 - [@gscho](https://github.com/gscho)
Expand Down
37 changes: 2 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This cookbook updates the Chef Infra Client

### Chef

- Chef 11.6.2+
- Chef 12.5+

## Usage

Expand Down Expand Up @@ -47,39 +47,6 @@ If you run Chef Infra Client as a service, things get a tiny bit more complicate

If you run Chef Infra Client as a service, but want to upgrade to a version of the client with an MSI unstaller that supports running as a scheduled task (any Chef Infra Client >= 12.18) it is now possible with the `install_command_options` property (added in version 3.8.0 of the chef_client_updater cookbook). This property accepts a Hash of key/value pairs, with {daemon: 'task'} the necessary pair to notify the MSI Installer to install Chef Infra Client as a scheduled task.

### Upgrading from Chef Infra Client 11

Moving from Chef Infra Client 11 has a few challenges when we are dealing with public update sources. Chef Infra Client 11 ships with a very old `cacert.pem`. To work through this, we need to get a more current `cacert.pem` file and point OpenSSL to it. Unfortunately, for this to work consistently on Windows, we'll need to reboot. Chef Infra Client 11 does not have the reboot resource, so this isn't a graceful process. However, on the next Chef run after the reboot, things will be back on track and the upgrade will perform as on other platforms.

Below is an example of a recipe that can set up Chef Infra Client 11 to work using public update sources.

```ruby
if platform_family?('windows') && (Chef::VERSION < '12')
new_cert_file = File.join(ENV['USERPROFILE'], 'cacert.pem')

remote_file new_cert_file do
source 'https://curl.haxx.se/ca/cacert.pem'
action :create
end

powershell_script 'restart' do
code <<-EOH
restart-computer -force
EOH
action :nothing
end

env 'SSL_CERT_FILE' do
value new_cert_file
notifies :run, 'powershell_script[restart]', :immediately
end
end

chef_client_updater 'Install latest Chef' do
post_install_action 'kill'
end
```

## Chef EULA

Set the `node['chef_client']['chef_license']` attribute to `accept` or `accept-no-persist` to accept the Chef EULA
Expand Down Expand Up @@ -141,7 +108,7 @@ You can use 'exec' in production if you are running from cron or some other proc

## A note about purpose

While this cookbook supports running on Chef Infra Client versions back to 11/12, the supported behavior of the cookbook is to upgrade those versions to 13/14 or newer. It is not intended that users would maintain old Chef-11/12 versions with this cookbook. The latest released version of Chef Infra Client 12 (12.22.1 or later) is still be supported as a target. Older versions of Chef Infra Client will have their embedded rubygems force upgraded by this cookbook to avoid having to regression test against 5+ years of rubygems bugs and establish a stable basis for the cookbook to use.
While this cookbook supports running on Chef Infra Client versions back to 12, the supported behavior of the cookbook is to upgrade those versions to 13/14 or newer. It is not intended that users would maintain old Chef 12 versions with this cookbook. The latest released version of Chef Infra Client 12 (12.22.1 or later) is still be supported as a target. Older versions of Chef Infra Client will have their embedded rubygems force upgraded by this cookbook to avoid having to regression test against 5+ years of rubygems bugs and establish a stable basis for the cookbook to use.

## License

Expand Down
2 changes: 1 addition & 1 deletion attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Cookbook:: chef_client_updater
# Attributes:: default
#
# Copyright:: 2016-2020, Chef Software Inc.
# Copyright:: Chef Software Inc.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
Expand Down
8 changes: 0 additions & 8 deletions libraries/matchers.rb

This file was deleted.

10 changes: 4 additions & 6 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
description 'Upgrades chef-client to specified releases'
version '3.12.0'

chef_version '>= 11' if respond_to?(:chef_version) # cookstyle: disable ChefModernize/RespondToInMetadata
source_url 'https://github.com/chef-cookbooks/chef_client_updater' if respond_to?(:source_url) # cookstyle: disable Chef/Modernize/RespondToInMetadata
issues_url 'https://github.com/chef-cookbooks/chef_client_updater/issues' if respond_to?(:issues_url) # cookstyle: disable Chef/Modernize/RespondToInMetadata

chef_version '>= 12.5' if respond_to?(:chef_version) # cookstyle: disable Chef/Modernize/RespondToInMetadata

%w(amazon centos debian mac_os_x opensuseleap oracle redhat scientific solaris2 suse ubuntu windows aix).each do |os|
supports os
end

unless defined?(Ridley) # cookstyle: disable ChefModernize/RespondToInMetadata
source_url 'https://github.com/chef-cookbooks/chef_client_updater' if respond_to?(:source_url) # cookstyle: disable ChefModernize/RespondToInMetadata
issues_url 'https://github.com/chef-cookbooks/chef_client_updater/issues' if respond_to?(:issues_url) # cookstyle: disable ChefModernize/RespondToInMetadata
end
Loading