-
Notifications
You must be signed in to change notification settings - Fork 79
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
Relocate License Logic on Windows systems into Ruby #212
base: main
Are you sure you want to change the base?
Conversation
---------- Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as Indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Signed-off-by: Jeff Dean <jwdean@scriptpro.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a good change to me, but I can't tell if the CI failures are related to this PR.
TravisCI seems to be failing on this repo for about a year now with the same error. So i dont think it's related to this PR. |
providers/default.rb
Outdated
post_action = if (new_resource.post_install_action == 'exec') && (desired_version.major >= 15) | ||
"#{new_resource.exec_command} --chef-license #{license_provided}" | ||
elsif desired_version.major < '15' | ||
new_resource.exec_command | ||
else | ||
'' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
post_action = if (new_resource.post_install_action == 'exec') && (desired_version.major >= 15) | |
"#{new_resource.exec_command} --chef-license #{license_provided}" | |
elsif desired_version.major < '15' | |
new_resource.exec_command | |
else | |
'' | |
end | |
post_action = if new_resource.post_install_action != 'exec' | |
'' | |
elsif desired_version.major >= 15 | |
"#{new_resource.exec_command} --chef-license #{license_provided}" | |
else | |
new_resource.exec_command | |
end |
I think this conditional needs to change to maintain the old behavior.
The whitespace is probably all wrong because I'm trying to do this in github's comment box.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. Thank you.
---------- Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as Indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Signed-off-by: Jeff Dean <jwdean@scriptpro.com>
Previous logic used PowerShell to call ruby.exe, with the ruby being an embedded string within the PowerShell script. That ruby used LicenseAcceptance::Acceptor to apply the license acceptance condition. This also used chef_install_dir to determine where Chef was located.
The new logic eliminates the embedded Ruby by determining if there is license acceptance before starting PowerShell to modify the command line of the post-action ChefClient execution. This now will use the --chef-license command line parameter to affect the license state. Instead of using chef_install_dir to determine where Chef is installed it will use the exec_command resource.
Description
There are two desired impacts of this change
Stylistically it is poor form to embed Ruby in PowerShell that is effectively called by Ruby. If there were tests for this code, it would be untestable.
The use of chef_install_dir is used for two non-congruent purposes in the cookbook:
-- determines the directory where the PowerShell script to be run is located.
chef_client_updater/providers/default.rb
Line 309 in a709307
That location would (by default) be C:\OpsCode.
-- determines where ruby.exe is located (in PowerShell).
chef_client_updater/providers/default.rb
Line 571 in a709307
The need this addresses is to allow the PowerShell script to be run from a directory other than that in which Chef is installed. This is a security requirement for us. While the more obvious change may have been to modify the behavior of the first case above, the, changing the second is a light touch that does should not change the current, expected behavior.
Issues Resolved
None
Check List
I've been so far unsuccessful at setting up testing for community cookbooks outside of my own lab. Working on it still.