CHEF-3954 Extended config block usage - Enabling kitchen usage with chef licensing#153
CHEF-3954 Extended config block usage - Enabling kitchen usage with chef licensing#153
Conversation
Signed-off-by: Nik08 <nikita.mathur@progress.com>
Signed-off-by: Nik08 <nikita.mathur@progress.com>
Signed-off-by: Nik08 <nikita.mathur@progress.com>
…l using config block Signed-off-by: Nik08 <nikita.mathur@progress.com>
76f53d1 to
15e5686
Compare
There was a problem hiding this comment.
I have the following changes on inspec's end
diff --git a/lib/inspec/utils/licensing_config.rb b/lib/inspec/utils/licensing_config.rb
index 191e9865c..77b2eae19 100644
--- a/lib/inspec/utils/licensing_config.rb
+++ b/lib/inspec/utils/licensing_config.rb
@@ -6,4 +6,8 @@ ChefLicensing.configure do |config|
config.chef_executable_name = "inspec"
config.license_server_url = "https://licensing.chef.co/License"
config.logger = Inspec::Log
+ config.license_server_url_check_in_file = false
+ config.license_server_url_in_config_file = true
+ config.license_server_url = "https://custom-licensing-server-2.com/License"
+ config.chef_license_key = "free-81547704-490b-4cb2-a7f3-ab0268d025d7-390"
end
In my terminal, I have set the following environment:
❯ echo $CHEF_LICENSE_SERVER
https://licensing-acceptance.chef.co/License
Executing inspec for more than 2 runs shows the following behavior:
❯ bundle exec inspec exec
[2023-08-16T14:45:22+05:30] WARN: Connection failed to https://custom-licensing-server-2.com/License
[2023-08-16T14:45:22+05:30] ERROR: Unable to connect to the licensing server. InSpec requires server communication to operate.
The following URL(s) were tried:
1. https://custom-licensing-server-2.com/License
❯ bundle exec inspec exec
Test Summary: 0 successful, 0 failures, 0 skipped
❯ bundle exec inspec exec
[2023-08-16T14:45:33+05:30] WARN: Connection failed to https://custom-licensing-server-2.com/License
[2023-08-16T14:45:33+05:30] ERROR: Unable to connect to the licensing server. InSpec requires server communication to operate.
The following URL(s) were tried:
1. https://custom-licensing-server-2.com/License
❯ bundle exec inspec exec
Test Summary: 0 successful, 0 failures, 0 skipped
It executes in one run, and it gives an error in the other.
Edit
❯ cat ~/.chef/licenses.yaml
cat: /Users/sosaha/.chef/licenses.yaml: No such file or directory
❯ bundle exec inspec exec
Test Summary: 0 successful, 0 failures, 0 skipped
❯ cat ~/.chef/licenses.yaml
---
:file_format_version: 4.0.0
:licenses:
- :license_key: free-81547704-490b-4cb2-a7f3-ab0268d025d7-390
:license_type: :free
:update_time: '2023-08-16T14:48:33+05:30'
:license_server_url: https://licensing-acceptance.chef.co/License
❯ bundle exec inspec exec
[2023-08-16T14:48:44+05:30] WARN: Connection failed to https://custom-licensing-server-2.com/License
[2023-08-16T14:48:44+05:30] ERROR: Unable to connect to the licensing server. InSpec requires server communication to operate.
The following URL(s) were tried:
1. https://custom-licensing-server-2.com/License
❯ cat ~/.chef/licenses.yaml
---
:file_format_version: 4.0.0
:licenses:
- :license_key: free-81547704-490b-4cb2-a7f3-ab0268d025d7-390
:license_type: :free
:update_time: '2023-08-16T14:48:33+05:30'
:license_server_url: https://custom-licensing-server-2.com/License
It updates the license server url alternately, leading to the issue.
|
So I see you are trying to set the server URL through both system (using ENV) and also through the config block using The flow goes like this using kitchen:
So on your 2 runs, first it gave precedence to system value, and on a later run since the URLs are different, it gave precedence to config value.
|
Signed-off-by: Nik08 <nikita.mathur@progress.com>
| config.chef_executable_name = "inspec" | ||
| config.chef_entitlement_id = "chef123" | ||
| config.chef_license_key="free-t0832est-1111-1te1-b1e5-011t182test3-111" | ||
| config.license_server_url_in_config_file = true |
There was a problem hiding this comment.
maybe we can use set_license_server_url_fron_config_file or 'use_license_server_url_from_config_file`
Signed-off-by: Nik08 <nikita.mathur@progress.com>
ahasunos
left a comment
There was a problem hiding this comment.
Given I understand the usage of license_server_url_in_config_file. I approve the changes in this PR.
Description
Extended config block usage for following cases:
chef_license_keyusing config block. This case will be useful if someone tries to set chef license key value using kitchen.license_server_urlusing config block by introducing an additional parameterlicense_server_url_in_config_file. This case will be useful if someone tries to reset chef licensing server value using kitchen.Related Issue
Types of changes
Checklist: