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

Fix for s3 secret not getting copied on target vm #428

Merged
merged 4 commits into from
Jul 28, 2016

Conversation

dheerajd-msys
Copy link
Contributor

No description provided.

@@ -689,6 +689,8 @@ def bootstrap_common_params(bootstrap)
bootstrap.config[:first_boot_attributes_from_file] = locate_config_value(:first_boot_attributes_from_file)
bootstrap.config[:encrypted_data_bag_secret] = s3_secret || locate_config_value(:secret)
bootstrap.config[:encrypted_data_bag_secret_file] = locate_config_value(:secret_file)
#cl_secret needs to be set as chef checks for this key
Chef::Config[:knife][:cl_secret] = s3_secret if locate_config_value(:s3_secret)
Copy link
Contributor

Choose a reason for hiding this comment

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

This code is a little confusing. I'm not sure that it might need a little refactor. At least might consider something like this:

# retrieving the secret from S3 is unique to knife-ec2, so we need to set "command line secret" to the value fetched from S3
Chef::Knife::DataBagSecretOptions.set_cl_secret(s3_secret)

We should add a test either way.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dheerajd-msys please improve the comment here. can you answer "why does chef need this key?" in the 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.

@btm,
yes, I will be improving the comment and code as per your suggestion and have added tests also.
When secret option is passed for Linux vm, instead of knife-windows, chef module is imported.
In chef code mentioned here, when secret option is passed, its proc function sets the value using set_cl_secret method in Chef::Config[:knife][:cl_secret].
And later the chef code instead of checking if value is present in bootstrap.config also, it checks for value in Chef::Config[:knife][:cl_secret] code here
Hence only setting the s3 secret value in bootstrap.config[:secret] doesn't work, as only upon verification that cl_secret is set, the code uses bootstrap.config[:secret] value.

@@ -486,6 +486,30 @@
end
end

description 'S3 secret test cases' do
Copy link
Contributor

Choose a reason for hiding this comment

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

this is causing travis to fail. I think you mean describe

@btm
Copy link
Contributor

btm commented Jul 26, 2016

please rebase, fix the tests, and improve the comments around why we need to set cl_secret.

@dheerajd-msys
Copy link
Contributor Author

@btm,
Thanks for review comments.
I have rebased the code, fixed the specs issue, and improved the comment.

expect(Chef::Config[:knife][:cl_secret]).to eql(@secret_content)
end

it 'should set the cl_secret key to nil' do

Choose a reason for hiding this comment

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

The description of the spec is not complete. When should the cl_secret be set to nil? Please add context here.

Also avoid using should and should not in the beginning of it block. Please refer https:/reachlocal/rspec-style-guide#should-it-or-should-not-in-it-statements

@btm
Copy link
Contributor

btm commented Jul 27, 2016

👍

@NimishaS NimishaS merged commit 901cfee into chef:master Jul 28, 2016
@NimishaS NimishaS deleted the dh/fix_for_s3_secret_issue branch July 28, 2016 07:28
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.

4 participants