From 872cca3ade6dc504367c3c73709f78499ec5bc35 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Tue, 15 Aug 2023 13:27:48 -0400 Subject: [PATCH 01/35] Reopen #219 Signed-off-by: Thomas Powell --- .github/workflows/unit_specs.yml | 6 +++--- Gemfile | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unit_specs.yml b/.github/workflows/unit_specs.yml index 632e0a3..468c1a2 100644 --- a/.github/workflows/unit_specs.yml +++ b/.github/workflows/unit_specs.yml @@ -5,16 +5,16 @@ name: unit_specs pull_request: push: branches: - - master + - main jobs: unit: strategy: fail-fast: false matrix: - os: [ubuntu-18.04, windows-2016, macos-10.15] + os: [ubuntu-latest, windows-latest, macos-latest] # Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0' - ruby: ['3.0'] + ruby: ['3.0', '3.1'] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 diff --git a/Gemfile b/Gemfile index ffe9c71..93af1a3 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ if ENV["GEMFILE_MOD"] else group :development do # temporarily we only support building against master - gem "chef", github: "chef/chef", branch: "master" - gem "ohai", github: "chef/ohai", branch: "master" + gem "chef", github: "chef/chef", branch: "main" + gem "ohai", github: "chef/ohai", branch: "main" end end From 0af9de2a357fbee4e05ab38fc687245d621a411a Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Wed, 28 Feb 2024 08:43:18 -0500 Subject: [PATCH 02/35] bump GA checkout to @4 Signed-off-by: Thomas Powell --- .github/workflows/unit_specs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit_specs.yml b/.github/workflows/unit_specs.yml index 468c1a2..a80d715 100644 --- a/.github/workflows/unit_specs.yml +++ b/.github/workflows/unit_specs.yml @@ -17,7 +17,7 @@ jobs: ruby: ['3.0', '3.1'] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} From 93aa88aa81408afb8f7944d15557f5c1bb6a32e6 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Wed, 28 Feb 2024 09:31:13 -0500 Subject: [PATCH 03/35] Fixed a couple of master references Signed-off-by: Thomas Powell --- .github/workflows/lint.yml | 2 +- Gemfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4950888..6dfc727 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -5,7 +5,7 @@ name: lint pull_request: push: branches: - - master + - main jobs: chefstyle: diff --git a/Gemfile b/Gemfile index 93af1a3..7385a05 100644 --- a/Gemfile +++ b/Gemfile @@ -14,7 +14,7 @@ if ENV["GEMFILE_MOD"] instance_eval(ENV["GEMFILE_MOD"]) else group :development do - # temporarily we only support building against master + # temporarily we only support building against main gem "chef", github: "chef/chef", branch: "main" gem "ohai", github: "chef/ohai", branch: "main" end From 4be5ca32516ef073f424d71f447403a06e6f068c Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Wed, 28 Feb 2024 09:33:33 -0500 Subject: [PATCH 04/35] add chef as a development dependency Signed-off-by: Thomas Powell --- cheffish.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/cheffish.gemspec b/cheffish.gemspec index ec83020..6afa64e 100644 --- a/cheffish.gemspec +++ b/cheffish.gemspec @@ -14,6 +14,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 3.0" + s.add_development_dependency "chef", ">= 17.0" s.add_dependency "chef-zero", ">= 14.0" s.add_dependency "chef-utils", ">= 17.0" s.add_dependency "net-ssh" From 16d83e42ad069361e1bb80dc96e9258b7712f36a Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Wed, 28 Feb 2024 09:38:52 -0500 Subject: [PATCH 05/35] install chef for the CI Signed-off-by: Thomas Powell --- .github/workflows/lint.yml | 10 +++++++--- cheffish.gemspec | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6dfc727..b7403f9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,10 +13,14 @@ jobs: env: BUNDLE_WITHOUT: ruby_shadow:omnibus_package steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.0' + ruby-version: '3.1' bundler-cache: true - uses: r7kamura/rubocop-problem-matchers-action@v1 # this shows the failures in the PR - - run: bundle exec rake style + + - run: | + # relative path in instance_eval has issues without chef as an explicit dependency + bundle exec gem install chef + bundle exec rake style diff --git a/cheffish.gemspec b/cheffish.gemspec index 6afa64e..ec83020 100644 --- a/cheffish.gemspec +++ b/cheffish.gemspec @@ -14,7 +14,6 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 3.0" - s.add_development_dependency "chef", ">= 17.0" s.add_dependency "chef-zero", ">= 14.0" s.add_dependency "chef-utils", ">= 17.0" s.add_dependency "net-ssh" From ede79271a0b85afd99df2c528b15a1fc609ce33c Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Wed, 28 Feb 2024 13:38:55 -0500 Subject: [PATCH 06/35] Try chef dependency instead Signed-off-by: Thomas Powell --- .github/workflows/lint.yml | 6 +----- cheffish.gemspec | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b7403f9..ea15a0e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,8 +19,4 @@ jobs: ruby-version: '3.1' bundler-cache: true - uses: r7kamura/rubocop-problem-matchers-action@v1 # this shows the failures in the PR - - - run: | - # relative path in instance_eval has issues without chef as an explicit dependency - bundle exec gem install chef - bundle exec rake style + - run: bundle exec rake style diff --git a/cheffish.gemspec b/cheffish.gemspec index ec83020..9293193 100644 --- a/cheffish.gemspec +++ b/cheffish.gemspec @@ -14,6 +14,7 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 3.0" + s.add_dependency "chef", ">= 17.0" s.add_dependency "chef-zero", ">= 14.0" s.add_dependency "chef-utils", ">= 17.0" s.add_dependency "net-ssh" From 242f7a7d5a420cfb8ce8575181b3938b54911793 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Wed, 28 Feb 2024 13:48:23 -0500 Subject: [PATCH 07/35] turn off the bundler cache? Signed-off-by: Thomas Powell --- .github/workflows/lint.yml | 2 +- cheffish.gemspec | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index ea15a0e..5d72551 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,6 +17,6 @@ jobs: - uses: ruby/setup-ruby@v1 with: ruby-version: '3.1' - bundler-cache: true + bundler-cache: false - uses: r7kamura/rubocop-problem-matchers-action@v1 # this shows the failures in the PR - run: bundle exec rake style diff --git a/cheffish.gemspec b/cheffish.gemspec index 9293193..ec83020 100644 --- a/cheffish.gemspec +++ b/cheffish.gemspec @@ -14,7 +14,6 @@ Gem::Specification.new do |s| s.required_ruby_version = ">= 3.0" - s.add_dependency "chef", ">= 17.0" s.add_dependency "chef-zero", ">= 14.0" s.add_dependency "chef-utils", ">= 17.0" s.add_dependency "net-ssh" From d32928bd72c05d80f6f1d69753bbdec1d5aff021 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Wed, 28 Feb 2024 18:06:18 -0500 Subject: [PATCH 08/35] Push a branch gem requirement for validation of tests Signed-off-by: Thomas Powell --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 7385a05..59fda0d 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,7 @@ if ENV["GEMFILE_MOD"] else group :development do # temporarily we only support building against main - gem "chef", github: "chef/chef", branch: "main" + gem "chef", github: "chef/chef", branch: "tp/cheffish-3.1" gem "ohai", github: "chef/ohai", branch: "main" end end From 63f7c479044b7a5fa264ec1c30075c480fea625c Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Wed, 28 Feb 2024 19:42:46 -0500 Subject: [PATCH 09/35] Switch on chef version requirement Signed-off-by: Thomas Powell --- Gemfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 59fda0d..3de95d4 100644 --- a/Gemfile +++ b/Gemfile @@ -15,7 +15,11 @@ if ENV["GEMFILE_MOD"] else group :development do # temporarily we only support building against main - gem "chef", github: "chef/chef", branch: "tp/cheffish-3.1" + if RUBY_VERSION =~ /^3\.1/ + gem "chef", github: "chef/chef", branch: "tp/cheffish-3.1" + else + gem "chef", github: "chef/chef", branch: "chef-17" + end gem "ohai", github: "chef/ohai", branch: "main" end end From cae814f5bf8173f657012b5c6b2cfeecade5880a Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Wed, 28 Feb 2024 19:45:00 -0500 Subject: [PATCH 10/35] Add 17-stable ohai Signed-off-by: Thomas Powell --- Gemfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3de95d4..a20e442 100644 --- a/Gemfile +++ b/Gemfile @@ -17,9 +17,10 @@ else # temporarily we only support building against main if RUBY_VERSION =~ /^3\.1/ gem "chef", github: "chef/chef", branch: "tp/cheffish-3.1" + gem "ohai", github: "chef/ohai", branch: "main" else gem "chef", github: "chef/chef", branch: "chef-17" + gem "ohai", github: "chef/ohai", branch: "17-stable" end - gem "ohai", github: "chef/ohai", branch: "main" end end From 9f1978f02f37ef9a534a7e4886f9b87a3f772f2e Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Wed, 28 Feb 2024 20:17:28 -0500 Subject: [PATCH 11/35] tilde wakka Signed-off-by: Thomas Powell --- Gemfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index a20e442..63675da 100644 --- a/Gemfile +++ b/Gemfile @@ -16,11 +16,11 @@ else group :development do # temporarily we only support building against main if RUBY_VERSION =~ /^3\.1/ - gem "chef", github: "chef/chef", branch: "tp/cheffish-3.1" - gem "ohai", github: "chef/ohai", branch: "main" + gem "chef", "~> 18.0" + gem "ohai", "~> 18.0" else - gem "chef", github: "chef/chef", branch: "chef-17" - gem "ohai", github: "chef/ohai", branch: "17-stable" + gem "chef", "~> 17.0" + gem "ohai", "~> 17.0" end end end From f73dbaa5d99535a4267d424b812ae6624bcbde50 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Thu, 29 Feb 2024 12:47:39 -0500 Subject: [PATCH 12/35] fixed version pinning for default gems on 3.1 Signed-off-by: Thomas Powell --- Gemfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 63675da..df56325 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" gemspec group :development do - gem "chefstyle", "2.0.8" + gem "cookstyle" #, "2.0.8" gem "rake" gem "rspec", "~> 3.0" end @@ -16,6 +16,10 @@ else group :development do # temporarily we only support building against main if RUBY_VERSION =~ /^3\.1/ + gem "date", "= 3.2.2" + gem "racc", "= 1.6.0" + gem "bigdecimal", "= 3.1.1" + gem "json", "= 2.6.1" gem "chef", "~> 18.0" gem "ohai", "~> 18.0" else From 2b496f68017b746b4cfc7cc377003d86455227c3 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Thu, 29 Feb 2024 16:00:38 -0500 Subject: [PATCH 13/35] Debugging traces Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 5 +++++ spec/integration/private_key_spec.rb | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index 1c03e09..9f7e719 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -64,6 +64,7 @@ def load_prior_resource(*args) action_class.class_eval do def create_key(regenerate, action) + puts "@should_create_directory #{@should_create_directory}" if @should_create_directory Cheffish.inline_resource(self, action) do directory run_context.config[:private_key_write_path] @@ -72,6 +73,7 @@ def create_key(regenerate, action) final_private_key = nil if new_source_key + puts 'new_source_key' # # Create private key from source # @@ -85,6 +87,7 @@ def create_key(regenerate, action) final_private_key = new_source_key else + puts 'else' # # Generate a new key # @@ -107,8 +110,10 @@ def create_key(regenerate, action) generated_key = true elsif !current_private_key + puts 'elsif' raise "Could not read private key from #{current_resource.path}: missing pass phrase?" else + puts 'final_private_key else' final_private_key = current_private_key generated_key = false end diff --git a/spec/integration/private_key_spec.rb b/spec/integration/private_key_spec.rb index 87abc03..a2013a1 100644 --- a/spec/integration/private_key_spec.rb +++ b/spec/integration/private_key_spec.rb @@ -41,7 +41,9 @@ context "and the private key already exists somewhere not in the write path" do before :each do + puts 'before each pre-converge' recipe { private_key "#{repo_path}/other_keys/blah" }.converge + puts 'before each post-converge' end it "the private expect(key).to not update" do From e2cdd8802d7cbb36d4328ba8096776f14ba16c9c Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Thu, 29 Feb 2024 16:10:35 -0500 Subject: [PATCH 14/35] More debug Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index 9f7e719..bbdb1cf 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -96,15 +96,18 @@ def create_key(regenerate, action) (!current_private_key || current_resource.size != new_resource.size || current_resource.type != new_resource.type)) - + puts 'generate a new key if' case new_resource.type when :rsa if new_resource.exponent + puts 'rsa new_resource.exponent' final_private_key = OpenSSL::PKey::RSA.generate(new_resource.size, new_resource.exponent) else + puts 'rsa else new_resource.exponent' final_private_key = OpenSSL::PKey::RSA.generate(new_resource.size) end when :dsa + puts 'dsa new_resource.exponent' final_private_key = OpenSSL::PKey::DSA.generate(new_resource.size) end From 1d72f75f628d31a3f7d07dc2602f1d7ebf3864ae Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Thu, 29 Feb 2024 16:54:06 -0500 Subject: [PATCH 15/35] Remove puts Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 9 --------- spec/integration/private_key_spec.rb | 2 -- 2 files changed, 11 deletions(-) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index bbdb1cf..e76f1c5 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -64,7 +64,6 @@ def load_prior_resource(*args) action_class.class_eval do def create_key(regenerate, action) - puts "@should_create_directory #{@should_create_directory}" if @should_create_directory Cheffish.inline_resource(self, action) do directory run_context.config[:private_key_write_path] @@ -73,7 +72,6 @@ def create_key(regenerate, action) final_private_key = nil if new_source_key - puts 'new_source_key' # # Create private key from source # @@ -87,7 +85,6 @@ def create_key(regenerate, action) final_private_key = new_source_key else - puts 'else' # # Generate a new key # @@ -96,27 +93,21 @@ def create_key(regenerate, action) (!current_private_key || current_resource.size != new_resource.size || current_resource.type != new_resource.type)) - puts 'generate a new key if' case new_resource.type when :rsa if new_resource.exponent - puts 'rsa new_resource.exponent' final_private_key = OpenSSL::PKey::RSA.generate(new_resource.size, new_resource.exponent) else - puts 'rsa else new_resource.exponent' final_private_key = OpenSSL::PKey::RSA.generate(new_resource.size) end when :dsa - puts 'dsa new_resource.exponent' final_private_key = OpenSSL::PKey::DSA.generate(new_resource.size) end generated_key = true elsif !current_private_key - puts 'elsif' raise "Could not read private key from #{current_resource.path}: missing pass phrase?" else - puts 'final_private_key else' final_private_key = current_private_key generated_key = false end diff --git a/spec/integration/private_key_spec.rb b/spec/integration/private_key_spec.rb index a2013a1..87abc03 100644 --- a/spec/integration/private_key_spec.rb +++ b/spec/integration/private_key_spec.rb @@ -41,9 +41,7 @@ context "and the private key already exists somewhere not in the write path" do before :each do - puts 'before each pre-converge' recipe { private_key "#{repo_path}/other_keys/blah" }.converge - puts 'before each post-converge' end it "the private expect(key).to not update" do From 592bc6b108a9b3c425be8dc5dd3335db68196735 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Thu, 29 Feb 2024 16:55:43 -0500 Subject: [PATCH 16/35] trace updated? Signed-off-by: Thomas Powell --- lib/cheffish/chef_run.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/cheffish/chef_run.rb b/lib/cheffish/chef_run.rb index 959fc5e..884aced 100644 --- a/lib/cheffish/chef_run.rb +++ b/lib/cheffish/chef_run.rb @@ -110,6 +110,7 @@ def converge_failed? end def updated? + puts client.updated? client.updated? end From 27138962dde5905a1fedbfec22ad1c53c5a1139f Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 08:48:04 -0500 Subject: [PATCH 17/35] Use cookstyle/chefstyle Signed-off-by: Thomas Powell --- Gemfile | 2 +- Rakefile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index df56325..3154c52 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" gemspec group :development do - gem "cookstyle" #, "2.0.8" + gem "cookstyle", "~> 7.32.8" gem "rake" gem "rspec", "~> 3.0" end diff --git a/Rakefile b/Rakefile index db1b7d3..55372a4 100644 --- a/Rakefile +++ b/Rakefile @@ -14,14 +14,14 @@ rescue LoadError end begin - require "chefstyle" + require "cookstyle/chefstyle" require "rubocop/rake_task" desc "Run Chefstyle tests" RuboCop::RakeTask.new(:style) do |task| task.options += ["--display-cop-names", "--no-color"] end rescue LoadError - puts "chefstyle gem is not installed. bundle install first to make sure all dependencies are installed." + puts "cookstyle gem is not installed. bundle install first to make sure all dependencies are installed." end begin From 74cfe6eb4d265e80a56314b3456735930ea5a73a Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 09:18:27 -0500 Subject: [PATCH 18/35] Turn back on bundler cache Signed-off-by: Thomas Powell --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5d72551..ea15a0e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,6 +17,6 @@ jobs: - uses: ruby/setup-ruby@v1 with: ruby-version: '3.1' - bundler-cache: false + bundler-cache: true - uses: r7kamura/rubocop-problem-matchers-action@v1 # this shows the failures in the PR - run: bundle exec rake style From ec0b42693a0fd747bf1cbea78a4823bd112b8415 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 09:32:02 -0500 Subject: [PATCH 19/35] Debug list Signed-off-by: Thomas Powell --- lib/cheffish/basic_chef_client.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/cheffish/basic_chef_client.rb b/lib/cheffish/basic_chef_client.rb index c0b4892..3471500 100644 --- a/lib/cheffish/basic_chef_client.rb +++ b/lib/cheffish/basic_chef_client.rb @@ -73,6 +73,7 @@ def updates end def updated? + puts @event_catcher.inspect @event_catcher.updates.size > 0 end From 182441de633f5cdeec60efbbbc9834a34d6fddd1 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 10:10:55 -0500 Subject: [PATCH 20/35] limit spec run and do a stack trace Signed-off-by: Thomas Powell --- .github/workflows/unit_specs.yml | 2 +- lib/chef/resource/private_key.rb | 6 ++++++ lib/cheffish/basic_chef_client.rb | 1 - lib/cheffish/chef_run.rb | 1 - 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/unit_specs.yml b/.github/workflows/unit_specs.yml index a80d715..d4c5d2d 100644 --- a/.github/workflows/unit_specs.yml +++ b/.github/workflows/unit_specs.yml @@ -22,4 +22,4 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - - run: bundle exec rake spec + - run: bundle exec rake spec SPEC=./spec/integration/private_key_spec.rb:47 diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index e76f1c5..84ac019 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -176,6 +176,12 @@ def write_private_key(key) end end + def updated_by_last_action(true_or_false) + puts caller + @updated ||= true_or_false + @updated_by_last_action = true_or_false + end + def new_source_key @new_source_key ||= if new_resource.source_key.is_a?(String) source_key, _source_key_format = Cheffish::KeyFormatter.decode(new_resource.source_key, new_resource.source_key_pass_phrase) diff --git a/lib/cheffish/basic_chef_client.rb b/lib/cheffish/basic_chef_client.rb index 3471500..c0b4892 100644 --- a/lib/cheffish/basic_chef_client.rb +++ b/lib/cheffish/basic_chef_client.rb @@ -73,7 +73,6 @@ def updates end def updated? - puts @event_catcher.inspect @event_catcher.updates.size > 0 end diff --git a/lib/cheffish/chef_run.rb b/lib/cheffish/chef_run.rb index 884aced..959fc5e 100644 --- a/lib/cheffish/chef_run.rb +++ b/lib/cheffish/chef_run.rb @@ -110,7 +110,6 @@ def converge_failed? end def updated? - puts client.updated? client.updated? end From 4b2de582655b0d9cd546138925c558d8e3196517 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 10:58:57 -0500 Subject: [PATCH 21/35] debug key creation Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index 84ac019..8ebfa73 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -204,13 +204,17 @@ def new_path def new_key_with_path path = new_resource.path - if path.is_a?(Symbol) + things = if path.is_a?(Symbol) + puts ">> is a symbol" [ nil, path ] elsif Pathname.new(path).relative? + puts ">> relative" private_key, private_key_path = Cheffish.get_private_key_with_path(path, run_context.config) if private_key + puts ">> private_key" [ private_key, (private_key_path || :none) ] elsif run_context.config[:private_key_write_path] + puts ">> else private_key" @should_create_directory = true path = ::File.join(run_context.config[:private_key_write_path], path) [ nil, path ] @@ -218,10 +222,13 @@ def new_key_with_path raise "Could not find key #{path} and Chef::Config.private_key_write_path is not set." end elsif ::File.exist?(path) + puts ">> file exist" [ IO.read(path), path ] else + puts ">> else nil" [ nil, path ] end + things.tap { |x| puts "new_key_with_path #{x}" } end def load_current_resource From 98f4efc2b344569f0011caad069c395cd9ff2661 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 11:13:14 -0500 Subject: [PATCH 22/35] Add caller traces Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index 8ebfa73..23786b8 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -228,7 +228,7 @@ def new_key_with_path puts ">> else nil" [ nil, path ] end - things.tap { |x| puts "new_key_with_path #{x}" } + things.tap { |x| puts "new_key_with_path #{x}"; puts caller } end def load_current_resource From 1f5812bcb6a39543a1896c13254abed568e72ad5 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 12:09:30 -0500 Subject: [PATCH 23/35] trace the multi return Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index 23786b8..72abd77 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -210,6 +210,7 @@ def new_key_with_path elsif Pathname.new(path).relative? puts ">> relative" private_key, private_key_path = Cheffish.get_private_key_with_path(path, run_context.config) + puts "private_key, private_key_path = #{private_key}, #{private_key_path} " if private_key puts ">> private_key" [ private_key, (private_key_path || :none) ] From 3dbe5522b0e2878a759d36cbf120d34789cf7a47 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 13:14:13 -0500 Subject: [PATCH 24/35] inspect the resource Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index 72abd77..0c0d445 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -176,12 +176,6 @@ def write_private_key(key) end end - def updated_by_last_action(true_or_false) - puts caller - @updated ||= true_or_false - @updated_by_last_action = true_or_false - end - def new_source_key @new_source_key ||= if new_resource.source_key.is_a?(String) source_key, _source_key_format = Cheffish::KeyFormatter.decode(new_resource.source_key, new_resource.source_key_pass_phrase) @@ -229,7 +223,7 @@ def new_key_with_path puts ">> else nil" [ nil, path ] end - things.tap { |x| puts "new_key_with_path #{x}"; puts caller } +# things.tap { |x| puts "new_key_with_path #{x}"; puts caller } end def load_current_resource @@ -263,6 +257,7 @@ def load_current_resource resource.action :delete end + puts resource.inspect @current_resource = resource end end From da09ff5e57bedb4a569c3bacfc7222a3c347bbcc Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 13:28:17 -0500 Subject: [PATCH 25/35] Inspect new resource Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index 0c0d445..2f7b83f 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -197,6 +197,8 @@ def new_path end def new_key_with_path + puts "<<<< new resource >>>>" + puts new_resource.inspect path = new_resource.path things = if path.is_a?(Symbol) puts ">> is a symbol" @@ -257,6 +259,7 @@ def load_current_resource resource.action :delete end + puts "<<<< current resource >>>>" puts resource.inspect @current_resource = resource end From 76353f89cb174a7bf251afb3a2af0e0ed8a1f9ea Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 13:49:07 -0500 Subject: [PATCH 26/35] trace caller for new resource Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index 2f7b83f..b26e2f5 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -197,6 +197,7 @@ def new_path end def new_key_with_path + puts caller puts "<<<< new resource >>>>" puts new_resource.inspect path = new_resource.path From ccaa8a4b0ed81ff9b5d62213ebe216cfaf0253c1 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 14:20:09 -0500 Subject: [PATCH 27/35] trace current resource Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index b26e2f5..e45ec50 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -259,7 +259,7 @@ def load_current_resource else resource.action :delete end - + puts caller puts "<<<< current resource >>>>" puts resource.inspect @current_resource = resource From 451e5834fbed1fab71b93aa389c13620b6a22be6 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 15:27:56 -0500 Subject: [PATCH 28/35] Fix windows ruby 3.1 matcher Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index e45ec50..284a1e7 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -136,7 +136,7 @@ def create_key(regenerate, action) converge_by "change format of #{new_resource.type} private key #{new_path} from #{current_resource.format} to #{new_resource.format}" do write_private_key(current_private_key) end - elsif RUBY_PLATFORM !~ /mswin|mingw32|windows/ && (@current_file_mode & 0077) != 0 + elsif RUBY_PLATFORM !~ /mswin|mingw|windows/ && (@current_file_mode & 0077) != 0 new_mode = @current_file_mode & 07700 converge_by "change mode of private key #{new_path} to #{new_mode.to_s(8)}" do ::File.chmod(new_mode, new_path) @@ -197,22 +197,14 @@ def new_path end def new_key_with_path - puts caller - puts "<<<< new resource >>>>" - puts new_resource.inspect path = new_resource.path things = if path.is_a?(Symbol) - puts ">> is a symbol" [ nil, path ] elsif Pathname.new(path).relative? - puts ">> relative" private_key, private_key_path = Cheffish.get_private_key_with_path(path, run_context.config) - puts "private_key, private_key_path = #{private_key}, #{private_key_path} " if private_key - puts ">> private_key" [ private_key, (private_key_path || :none) ] elsif run_context.config[:private_key_write_path] - puts ">> else private_key" @should_create_directory = true path = ::File.join(run_context.config[:private_key_write_path], path) [ nil, path ] @@ -220,13 +212,10 @@ def new_key_with_path raise "Could not find key #{path} and Chef::Config.private_key_write_path is not set." end elsif ::File.exist?(path) - puts ">> file exist" [ IO.read(path), path ] else - puts ">> else nil" [ nil, path ] end -# things.tap { |x| puts "new_key_with_path #{x}"; puts caller } end def load_current_resource @@ -259,9 +248,6 @@ def load_current_resource else resource.action :delete end - puts caller - puts "<<<< current resource >>>>" - puts resource.inspect @current_resource = resource end end From f27ab87562bc18ae08450cba937b2ed2e97e084a Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 15:30:34 -0500 Subject: [PATCH 29/35] Remove temp code and fix lint Signed-off-by: Thomas Powell --- lib/chef/resource/private_key.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chef/resource/private_key.rb b/lib/chef/resource/private_key.rb index 284a1e7..04981b1 100644 --- a/lib/chef/resource/private_key.rb +++ b/lib/chef/resource/private_key.rb @@ -198,7 +198,7 @@ def new_path def new_key_with_path path = new_resource.path - things = if path.is_a?(Symbol) + if path.is_a?(Symbol) [ nil, path ] elsif Pathname.new(path).relative? private_key, private_key_path = Cheffish.get_private_key_with_path(path, run_context.config) From 97fd6fdcbe2474731a57931a676326559fd800da Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 15:36:28 -0500 Subject: [PATCH 30/35] Reenable full spec run Signed-off-by: Thomas Powell --- .github/workflows/unit_specs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit_specs.yml b/.github/workflows/unit_specs.yml index d4c5d2d..a80d715 100644 --- a/.github/workflows/unit_specs.yml +++ b/.github/workflows/unit_specs.yml @@ -22,4 +22,4 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - - run: bundle exec rake spec SPEC=./spec/integration/private_key_spec.rb:47 + - run: bundle exec rake spec From e2488414b48556a12d2e94cdfbf8a98bd4bad1f9 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 15:41:10 -0500 Subject: [PATCH 31/35] Clean up comments Signed-off-by: Thomas Powell --- Gemfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3154c52..359986c 100644 --- a/Gemfile +++ b/Gemfile @@ -14,8 +14,10 @@ if ENV["GEMFILE_MOD"] instance_eval(ENV["GEMFILE_MOD"]) else group :development do - # temporarily we only support building against main + # chef 17 is on 3.0 + # chef 18 is on 3.1 if RUBY_VERSION =~ /^3\.1/ + # some magic was required for default gems for 18 gem "date", "= 3.2.2" gem "racc", "= 1.6.0" gem "bigdecimal", "= 3.1.1" From 736dc86ec6f60c62dd2810b453d3d78f62baa308 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 15:42:59 -0500 Subject: [PATCH 32/35] Try without default gems pins Signed-off-by: Thomas Powell --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 359986c..2651f6e 100644 --- a/Gemfile +++ b/Gemfile @@ -18,10 +18,12 @@ else # chef 18 is on 3.1 if RUBY_VERSION =~ /^3\.1/ # some magic was required for default gems for 18 +=begin gem "date", "= 3.2.2" gem "racc", "= 1.6.0" gem "bigdecimal", "= 3.1.1" gem "json", "= 2.6.1" +=end gem "chef", "~> 18.0" gem "ohai", "~> 18.0" else From 367f85fd0f76bf8a1db9ad1b30a1bb71eff054ef Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 15:46:25 -0500 Subject: [PATCH 33/35] Remove default gems pins Signed-off-by: Thomas Powell --- Gemfile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Gemfile b/Gemfile index 2651f6e..ef55f32 100644 --- a/Gemfile +++ b/Gemfile @@ -17,13 +17,6 @@ else # chef 17 is on 3.0 # chef 18 is on 3.1 if RUBY_VERSION =~ /^3\.1/ - # some magic was required for default gems for 18 -=begin - gem "date", "= 3.2.2" - gem "racc", "= 1.6.0" - gem "bigdecimal", "= 3.1.1" - gem "json", "= 2.6.1" -=end gem "chef", "~> 18.0" gem "ohai", "~> 18.0" else From 6737009004b934aa067474e1ea253092ecf60e56 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 16:49:19 -0500 Subject: [PATCH 34/35] 3.0, 3.1, and unbounded Signed-off-by: Thomas Powell --- Gemfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index ef55f32..5a95213 100644 --- a/Gemfile +++ b/Gemfile @@ -16,12 +16,12 @@ else group :development do # chef 17 is on 3.0 # chef 18 is on 3.1 - if RUBY_VERSION =~ /^3\.1/ - gem "chef", "~> 18.0" - gem "ohai", "~> 18.0" - else + if RUBY_VERSION =~ /^3\.0/ gem "chef", "~> 17.0" gem "ohai", "~> 17.0" + else + gem "chef" + gem "ohai" end end end From c2d0693dcc8abab989869d8b7d63550fd863e835 Mon Sep 17 00:00:00 2001 From: Thomas Powell Date: Fri, 1 Mar 2024 16:50:13 -0500 Subject: [PATCH 35/35] 3.0, 3.1, and unbounded Signed-off-by: Thomas Powell --- Gemfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 5a95213..d7d1346 100644 --- a/Gemfile +++ b/Gemfile @@ -16,10 +16,15 @@ else group :development do # chef 17 is on 3.0 # chef 18 is on 3.1 - if RUBY_VERSION =~ /^3\.0/ + case RUBY_VERSION + when /^3\.0/ gem "chef", "~> 17.0" gem "ohai", "~> 17.0" + when /^3\.1/ + gem "chef", "~> 18.0" + gem "ohai", "~> 18.0" else + # go with the latest, unbounded gem "chef" gem "ohai" end