Skip to content
This repository has been archived by the owner on Mar 19, 2022. It is now read-only.

Allow configuration of solo.rb via knife.rb #199

Merged
merged 34 commits into from
Apr 6, 2013

Conversation

matschaffer
Copy link
Owner

The latest rendition of this uses .chef/knife.rb entirely and munges all paths into a generated solo.rb.

Changing the root "provisioning path" (name borrowed from vagrant) can be done via command line switch.

The rest is not customizable on the node and is considered an implementation detail. Instead this will read all of the local knife.rb configurations and use them as the source path during rsync.

This is working well in my testing so far, but the downside is that we now rsync everything separately which makes all this even slower given the ssh connection overhead.

I'm inclined to accept that for now since it's puts more pressure on the planned ssh-connection refactoring which should really happen anyway.

My hope is that this will also allow us to integrate with berkshelf without having to copy cookbooks into the kitchen explicitly. Which would be awesome.

For testing the latest version, just remove solo.rb and re-run knife solo init . to generate .chef/knife.rb. Or if you have one already just make sure it includes the items listed in the example.

@tmatilai
Copy link
Collaborator

My suggestion (like in this comment) is to use the standard Knife configuration options from knife.rb/Chef::Config. For example each directory in Chef::Config[:cookbook_path] would be uploaded to own index based directory. And thus we could add berkshelf directory to it dynamically.

I guess we just have to make a spike to see how this works out.

@tknerr
Copy link

tknerr commented Feb 20, 2013

Btw: I'm just playing around with how to adapt the cookbooks path, so my first attempt was to add this to knife.rb

knife[:solo_path] = "/tmp/foo"

and then use a customized solo.rb:

base = File.expand_path('..', __FILE__)

data_bag_path             base + '/my_data_bags_path'
encrypted_data_bag_secret base + '/data_bag_key'
role_path                 base + '/roles'
cookbook_path             base + '/some/other/cookbooks/path'

While this works for now, I'd definitely prefer to override only a specific parts, i.e. only adapt cookbooks_path rather than providing the whole solo.rb file.

In my ideal world:

  • defaults are defined in this solo.rb which is generated on the server by default
  • if .chef/knife.rb or ~/.chef/knife.rb is present the standard knife configurations will override the defaults (big +1 for the previous comment)
  • if (for whatever reason) a different configuration should be used for knife-solo then it could be overridden via knife[:solo][:cookbook_path] = ["a", "b"] (but that may be YAGNI already)

I also noticed that adding knife[:solo_path] does not work if added to solo.rb instead of knife.rb (and I don't think it belongs there, but it was mentioned in the Wiki and thus I updated the Wiki description)

@tknerr
Copy link

tknerr commented Feb 20, 2013

Just to give you a heads-up about the current state master:

  • adding knife[:solo][:cookbook_path] = "xz" to knife.rb fails with NoMethodError: undefined method '[]=' for nil:NilClass on the client
  • adding cookbook_path = 'xyz' (standard knife configuration) to knife.rb is not honored in the server-generated solo.rb

It seems like it is just not implemented yet (I thought so because of the "1 - Ready" label on this issue).

@tknerr
Copy link

tknerr commented Feb 20, 2013

btw: any plans on pushing out another pre version (0.3.0.pre2 I guess) to rubygems.org in the next days?

@matschaffer
Copy link
Owner Author

Yeah, let me run one now. It should at least fix the windows issues we've
been seeing. Won't fix up this knife.rb/solo.rb mess I've made of course ;)

-Mat

about.me/matschaffer

On Wed, Feb 20, 2013 at 5:01 AM, tknerr notifications@github.com wrote:

btw: any plans on pushing out another pre version (0.3.0.pre2 I guess) to
rubygems.org in the next days?


Reply to this email directly or view it on GitHubhttps://github.com//issues/199#issuecomment-13824103.

@matschaffer
Copy link
Owner Author

@tknerr the 'ready' tag means it's on the backlog (http://huboard.com/matschaffer/knife-solo/board). 'Done' would be actually finished and merged. The prototype is on this branch but it will probably change again. I'm struggling quite a bit trying to get this one right.

@tknerr
Copy link

tknerr commented Feb 20, 2013

@matschaffer thanks for pushing 0.3.0.pre2!

Didn't know about huboard yet, but looks nice :-)

@matschaffer
Copy link
Owner Author

Thank @tmatilai for that find. So far so good. I'm also using it on a
private project with reasonable success. The UI took a little getting used
to though.

-Mat

about.me/matschaffer

On Wed, Feb 20, 2013 at 9:46 AM, tknerr notifications@github.com wrote:

@matschaffer https://github.com/matschaffer thanks for pushing
0.3.0.pre2!

Didn't know about huboard yet, but looks nice :-)


Reply to this email directly or view it on GitHubhttps://github.com//issues/199#issuecomment-13835151.

@tknerr
Copy link

tknerr commented Feb 20, 2013

Thanks @tmatilai :-)

@tmatilai
Copy link
Collaborator

No, thanks to my twitter feed. =)

@matschaffer
Copy link
Owner Author

url

option :provisioning_path,
:long => '--provisioning-path path',
:description => 'Where to store kitchen data on the node',
:default => '~/chef-solo'
Copy link
Collaborator

Choose a reason for hiding this comment

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

The current handling for this option works fine with Chef 11, but in Chef 10 this does not make possible to set the default value in knife.rb. There are many ways to fix it, but I think a good one would be to follow this (with a fix for --no-options). I.e. remove the :default attribute here, and add methods:

def locate_config_value(key)
  key = key.to_sym
  config[key].nil? ? Chef::Config[:knife][key] : config[key]
end

def provisioning_path
  locate_config_value(:provisioning_path) || '~/chef-solo'
end

I had a plan to unify the option handling overall after this issue is merged, but this is a good place start.

jasherai added a commit to jasherai/knife-solo that referenced this pull request Mar 19, 2013
NOTE: This is redundant after matschaffer#199 is merged

rel matschaffer#212. Ohai doesn't like relative reference to solo.rb
Currently this is unix only. Not sure if this issue is still valid on
windows. Need to adjust fix to return original path on windows boxes.
@tmatilai
Copy link
Collaborator

@matschaffer I guess you are quite busy, so would you like that I try to address the issues I found? I should have some spare time in Easter.

@tmatilai
Copy link
Collaborator

tmatilai commented Apr 4, 2013

@matschaffer Here are my suggestions for this branch: tmatilai/knife-solo@3c4b2d0...issue;knife-rb-configuration-199
What say you?

@matschaffer
Copy link
Owner Author

Love it. Do you feel like it's ready to go otherwise? If so perhaps it's
time to merge in. I'm gonna be pretty busy till 5/1, so I'm happy to trust
your judgement in the name of moving this along.

-Mat

about.me/matschaffer

On Thu, Apr 4, 2013 at 12:02 AM, Teemu Matilainen
notifications@github.comwrote:

@matschaffer https://github.com/matschaffer Here are my suggestions for
this branch:
tmatilai/knife-solo@3c4b2d0...issue;knife-rb-configuration-199
What say you?


Reply to this email directly or view it on GitHubhttps://github.com//pull/199#issuecomment-15878871
.

@tmatilai
Copy link
Collaborator

tmatilai commented Apr 4, 2013

I think this is quite ready. I'll make the last changes to #207 and merge it first. Then merge the new master before my changes. My branch is now built on top of #207.

I'll try to do all this later today. After that a new pre-release would be a good idea. Documentation and upgrade instructions need some attention, too. And I think it would be a good idea to warn and inform the user if solo.rb is found in the kitchen, no?

@matschaffer
Copy link
Owner Author

Agreed with all above. Including the solo.rb presence.

-Mat

about.me/matschaffer

On Thu, Apr 4, 2013 at 9:33 AM, Teemu Matilainen
notifications@github.comwrote:

I think this is quite ready. I'll make the last changes to #207https://github.com/matschaffer/knife-solo/issues/207and merge it first. Then merge the new master before my changes. My branch
is now built on top of #207#207
.

I'll try to do all this later today. After that a new pre-release would be
a good idea. Documentation and upgrade instructions need some attention,
too. And I think it would be a good idea to warn and inform the user if *
solo.rb* is found in the kitchen, no?


Reply to this email directly or view it on GitHubhttps://github.com//pull/199#issuecomment-15897166
.

Conflicts:
	Manifest.txt
	knife-solo.gemspec
	lib/chef/knife/solo_cook.rb
Allows setting the value in knife.rb with Chef 10, too.
Set the provisioning_path dir mode so that it is not world-readable.
Fixes #1.
Avoid possible collisions between user cookbook directories, our patch
cookbooks and future Berkshelf integration.
It is common to specify it as a string if there is only one cookbook
directory.
Chef/Knife configuration for cookbook_path etc. defaults to system
paths. So unless the user has configured her knife.rb, the paths
don't normally exist.
tmatilai added a commit that referenced this pull request Apr 6, 2013
…-199

- Generate solo.rb from knife.rb settings. Fixes #86, #125, #128, #177, #197.
- Read protect the uploaded directory. Fixes #1.
- Convert chef-solo-search as a submodule and upgrade it to v0.4.0. Should fix #216.
@tmatilai tmatilai merged commit 84edc5f into master Apr 6, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants