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

Add accept_license property to chef-ingredient. #101

Merged
merged 2 commits into from
Apr 21, 2016
Merged

Conversation

sersut
Copy link
Contributor

@sersut sersut commented Apr 19, 2016

This PR add accept_license property to chef-ingredient so the users can set it to be able to reconfigure compliance, manage, reporting and analytics after the version that supports --accept-license during reconfigure ships.

@mmzyk note that this PR needs the minimum version numbers that support --accept-license CLI option. I have set them to be a minor version bump with the current existing ones. If we would like to set a different version let me know.

/cc: @chef-cookbooks/engineering-services @alexpop

#
def license_acceptance_parameter
if new_resource.accept_license &&
(new_resource.product_name == 'compliance' && version_for(new_resource.version) >= version_for('1.1.3')) ||
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for checking the version 👍

@sersut
Copy link
Contributor Author

sersut commented Apr 19, 2016

Hrmmm... Looks like there is one wrinkle for this. Do we pass the --accept-license option when version is set to :latest?

I can see two options:

  1. Do not check for the versions and add --accept-license when property is set. It is up to the user to know if their version requires this option and add it only when necessary. Note that reconfigure is going to fail if we specify this option and if the command does not support it.
  2. Merge this after all products are released and add the CLI option --accept-license when version is set to :latest all the time.

I am leaning more towards option 1 since it is a simpler case. If you see the reconfigure error (which has a clear error message) you add this option. There are complicated scenarios like what if you are on a previous version of chef-ingredient, what if you are using a custom repo and did not populate your local repositories with the version that supports this CLI option, etc...

Let me know what you think guys and I'll change the PR.

@scotthain
Copy link

Code looks good - I would also lean towards the first (simpler) option, as long as the error message is clear and there's a simple path a user can go to fix it. Looks like travis is unhappy but otherwise 👍

(new_resource.product_name == 'manage' && version_for(new_resource.version) >= version_for('1.10.0')) ||
(new_resource.product_name == 'reporting' && version_for(new_resource.version) >= version_for('1.6.0')) ||
(new_resource.product_name == 'analytics' && version_for(new_resource.version) >= version_for('1.4.0'))
'--accept_license'
Copy link
Contributor

@schisamo schisamo Apr 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So IMO we should just lay down the required /var/opt/<PROJECT>/.license.accepted if accept_license is true. This will allow us to avoid all this crazy version checking and is fully backward compatible.

Copy link

@wrightp wrightp Apr 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 to Seth's comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea. Will do that.

@sersut
Copy link
Contributor Author

sersut commented Apr 19, 2016

Updated with @schisamo's great comment!

@@ -57,6 +57,7 @@ By default, `chef_ingredient` will install using the `packages.chef.io` stable r
- `channel`: Channel to install the products from. It can be `:stable` (default), `:current` or `:unstable`.
- `package_source`: Full path to a location where the package is located. If present, this file is used for installing the package. Default `nil`.
- `timeout`: The amount of time (in seconds) to wait to fetch the installer before timing out. Default: default timeout of the Chef package resource - `900` seconds.
- `accept_license`: A boolean value that specifies if license should be accepted if it is asked for during `reconfigure`action. This option is needed only for manage, analytics, reporting and manage products. Default: `false`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manage, analytics, reporting and manage

Something is strange in that sentence. I believe we are missing a few products also like Compliance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh... double manage 😄 will fix soon.

@alexpop
Copy link

alexpop commented Apr 20, 2016

Great work guys. I've tried this against latest compliance build(1.1.4) that already requires --accept-license for reconfigure. The resource failed because of missing directory /var/opt/chef-compliance:

 ================================================================================
 Error executing action `reconfigure` on resource 'chef_ingredient[compliance]'
 ================================================================================

 Chef::Exceptions::EnclosingDirectoryDoesNotExist
 ------------------------------------------------
 file[/var/opt/chef-compliance/.license.accepted] (/tmp/kitchen/cache/cookbooks/chef-ingredient/libraries/chef_ingredient_provider.rb line 94) had an error: Chef::Exceptions::EnclosingDirectoryDoesNotExist: Parent directory /var/opt/chef-compliance does not exist.

Creating the /var/opt/chef-compliance directory before the chef_ingredient[compliance] resource made the converge successfully complete.

@sersut
Copy link
Contributor Author

sersut commented Apr 20, 2016

@alexpop you are awesome. Fixing it immediately.

@sersut
Copy link
Contributor Author

sersut commented Apr 20, 2016

Thanks to @alexpop for verifying this change for compliance.

@yzl
Copy link

yzl commented Apr 20, 2016

👍

@sersut sersut merged commit 4ee4129 into master Apr 21, 2016
@sersut sersut deleted the sersut/accept_license branch April 21, 2016 16:35
@wrightp
Copy link

wrightp commented Apr 21, 2016

As we start releasing addons and other packages to include the license accept feature I anticipate that a good portion of the integration tests will start to fail.

iennae added a commit to chef-cookbooks/chef-server that referenced this pull request Apr 29, 2016
…ker kitchen file.

Proprietary Chef products—such as Chef Compliance, Chef Delivery, Chef Analytics, Reporting, and the Chef Management Console—are governed by the Chef MLSA. [The Chef MLSA must be accepted when installing or reconfiguring the product](https://docs.chef.io/chef_license.html). Chef ingredient added the [accept_license](chef-cookbooks/chef-ingredient#101) property to provide a way to automate this. This fix adds the attribute ['chef-server']['accept_license']. The default value is _false_. Individuals must explicitly change the value to true in their environment to accept the license. Make sure you set the node attribute ['chef-server']['accept_license'] = true to resolve this error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants