From f27c9f1d88137897a9d9bdd23c8c0f845a4cd2c1 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Wed, 19 Jan 2022 19:21:30 +0000 Subject: [PATCH 1/3] Remove homebrew recipe and require Chef 15.3+ Signed-off-by: Dan Webb --- resources/definition.rb | 7 +--- resources/homebrew_update.rb | 77 ------------------------------------ resources/install.rb | 4 +- 3 files changed, 4 insertions(+), 84 deletions(-) delete mode 100644 resources/homebrew_update.rb diff --git a/resources/definition.rb b/resources/definition.rb index 73ecc20..c78e08c 100644 --- a/resources/definition.rb +++ b/resources/definition.rb @@ -1,9 +1,8 @@ include Chef::Rbenv::MacOs +unified_mode true -# for compatibility with earlier incarnations -# of this resource -# provides :ruby_build_ruby +provides :ruby_build_definition property :definition, String, name_property: true, @@ -34,8 +33,6 @@ property :group, String, description: 'Group to install as' -unified_mode true if respond_to? :unified_mode - action :install do Chef::Log.fatal('JRuby is not a supported definition') \ if new_resource.definition.include? 'jruby' diff --git a/resources/homebrew_update.rb b/resources/homebrew_update.rb deleted file mode 100644 index de88d53..0000000 --- a/resources/homebrew_update.rb +++ /dev/null @@ -1,77 +0,0 @@ -unified_mode true if respond_to? :unified_mode - -provides :homebrew_update - -description 'Use the **homebrew_update** resource to manage Homebrew repository updates on MacOS.' -introduced '16.2' -examples <<~DOC - **Update the hombrew repository data at a specified interval**: - ```ruby - homebrew_update 'all platforms' do - frequency 86400 - action :periodic - end - ``` - **Update the Homebrew repository at the start of a Chef Infra Client run**: - ```ruby - homebrew_update 'update' - ``` -DOC - -# allow bare homebrew_update with no name -property :name, String, default: '' - -property :frequency, Integer, - description: 'Determines how frequently (in seconds) Homebrew updates are made. Use this property when the `:periodic` action is specified.', - default: 86_400 - -default_action :periodic - -action_class do - BREW_STAMP_DIR = '/var/lib/homebrew/periodic'.freeze - BREW_STAMP = "#{BREW_STAMP_DIR}/update-success-stamp".freeze - - # Determines whether we need to run `homebrew update` - # - # @return [Boolean] - def brew_up_to_date? - ::File.exist?(BREW_STAMP) && - ::File.mtime(BREW_STAMP) > Time.now - new_resource.frequency - end - - def do_update - directory BREW_STAMP_DIR do - recursive true - end - - file BREW_STAMP do - content "BREW::Update::Post-Invoke-Success\n" - action :create_if_missing - end - - execute 'brew update' do - command %w(brew update) - default_env true - user Homebrew.owner - notifies :touch, "file[#{BREW_STAMP}]", :immediately - end - end -end - -action :periodic do - return unless mac_os_x? - - unless brew_up_to_date? - converge_by 'update new lists of packages' do - do_update - end - end -end - -action :update do - return unless mac_os_x? - - converge_by 'force update new lists of packages' do - do_update - end -end diff --git a/resources/install.rb b/resources/install.rb index 8fb8a21..0065d55 100644 --- a/resources/install.rb +++ b/resources/install.rb @@ -1,11 +1,11 @@ +unified_mode true + property :name, String, default: '' property :git_ref, String, default: 'master', description: 'Git reference to download, set to a tag to get a specific version' -unified_mode true if respond_to? :unified_mode - action :install do src_path = "#{Chef::Config['file_cache_path']}/ruby-build" From 8c4c18f31e7bfc55774e3308aad49cb7bf4c3bd2 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Wed, 19 Jan 2022 19:23:44 +0000 Subject: [PATCH 2/3] Require Chef 15.3 rather than 15.0 Signed-off-by: Dan Webb --- metadata.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/metadata.rb b/metadata.rb index 3e09619..5464f51 100644 --- a/metadata.rb +++ b/metadata.rb @@ -5,7 +5,7 @@ description 'Manages the ruby-build framework and its installed rubies. A LWRP is also defined.' source_url 'https://github.com/sous-chefs/ruby_build' issues_url 'https://github.com/sous-chefs/ruby_build/issues' -chef_version '>= 15.0' +chef_version '>= 15.3' version '2.2.0' supports 'ubuntu' @@ -23,4 +23,3 @@ depends 'yum-epel' depends 'yum-centos' -depends 'homebrew' From 0b0b91f6df23f14bd0a477d9aed5f590c3a1f068 Mon Sep 17 00:00:00 2001 From: Dan Webb Date: Wed, 19 Jan 2022 19:24:57 +0000 Subject: [PATCH 3/3] CHANGELOG update Signed-off-by: Dan Webb --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bafb444..75d5d2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Require Chef 15.3+ + - Require unified_mode is always enabled for Chef 17 support + - Remove the homebrew resource + ## 2.2.0 - *2021-12-27* - support Chef temporary directory being located on a volume mounted `noexec`