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

Integrate knife-solo to knife bootstrap #207

Merged
merged 7 commits into from
Apr 4, 2013

Conversation

tmatilai
Copy link
Collaborator

Monkey patch Knife::Bootstrap to include --solo option (and knife[:solo] configuration options) to trigger knife solo bootstrap instead of the normal template based bootstrap.

This addresses also #121.

TODO:

  • integration test
  • documentation

@matschaffer
Copy link
Owner

Ah yes, this guy. I'm cool to merge, but it would be nice to get those integration & doc points covered. Of course if you'd rather open those as separate issues that's fine too.

@tmatilai
Copy link
Collaborator Author

I'm not in a hurry with this. I'll write the test and a couple of lines to the readme soon. Of course any help especially with the documentation is appreciated. =)

@tmatilai
Copy link
Collaborator Author

Oh, this one... I try to document this soon. I already have an integration test but it does not work before #221 is fixed.

tmatilai added a commit to tmatilai/knife-solo that referenced this pull request Mar 24, 2013
Librarian-Chef was not run by default when SoloCook/Bootstrap was
invoked by for example `knife bootstrap --solo` (from matschaffer#207) or `knife
digital_ocean droplet create --solo` (from knife-digital_ocean).

This is probably caused by a Knife/mixlib-cli issue about handling
boolean values, but we can work around it by using our own helper.
tmatilai added a commit to tmatilai/knife-solo that referenced this pull request Mar 24, 2013
Librarian-Chef was not run by default when SoloCook/Bootstrap was
invoked by for example `knife bootstrap --solo` (from matschaffer#207) or `knife
digital_ocean droplet create --solo` (from knife-digital_ocean).

This is probably caused by a Knife/mixlib-cli issue about handling
boolean values, but we can work around it by using our own helper.
tmatilai added a commit to tmatilai/knife-solo that referenced this pull request Mar 25, 2013
Librarian-Chef was not run by default when SoloCook/Bootstrap was
invoked by for example `knife bootstrap --solo` (from matschaffer#207) or `knife
digital_ocean droplet create --solo` (from knife-digital_ocean).

The reason is that the `Knife.config` is not loaded by default values
when the Knife class is initialized. While this could be fixed in
the invoking code it is much cleaner to do moving the default value
setting to later in the code.

As an extra bonus, by using our `config_value` helper we also make it
possible to use `knife[:librarian]` configuration option with Chef 10,
too.
Add `--solo` command line option and `knife[:solo]` configuration
parameter to `Knife::Bootstrap` that can be used for triggering
`Knife::SoloBootstrap` instead of the normal template based chef-client
bootstrap.

This is especially useful with other knife plugins like knife-ec2 that
invoke `knife bootstrap` after creating an server instance. Even if
these plugins do not have the `--solo` option, you can put
`knife[:solo] = true` in knife.rb.
Convert Debian 7 test for this.
@tmatilai
Copy link
Collaborator Author

Here we go. The integration test depends on #221 but otherwise this is ready from my part. All comments obviously welcome.

:description => 'Bootstrap using knife-solo'

# Rename and override run method
alias_method :orig_run, :run
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@matschaffer So... orig_run, run_without_knife_solo, run_with_chef_client, run_with_template? =)

Copy link
Owner

Choose a reason for hiding this comment

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

Oh actually. run_with_chef_client is nice especially if we wrap the knife
solo stuff in a run_with_knife_solo method.

-Mat

On Apr 3, 2013, at 21:23, Teemu Matilainen notifications@github.com wrote:

In lib/chef/knife/bootstrap_solo.rb:

  • class Knife
  • class Bootstrap
  •  def self.load_deps
    
  •    super
    
  •    require 'chef/knife/solo_bootstrap'
    
  •    require 'knife-solo/tools'
    
  •    SoloBootstrap.load_deps
    
  •  end
    
  •  option :solo,
    
  •    :long        => '--[no-]solo',
    
  •    :description => 'Bootstrap using knife-solo'
    
  •  # Rename and override run method
    
  •  alias_method :orig_run, :run
    

@matschaffer https://github.com/matschaffer So... orig_run,
run_without_knife_solo, run_with_chef_client, run_with_template? =)


Reply to this email directly or view it on
GitHubhttps://github.com//pull/207/files#r3648480
.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Roger. Originally I was using another method but then after the line count had reduced (while knife-solo gained more and more compatibility), I put all back to run not to pollute Knife::Bootstrap's namespace. But I don't think the risk for collision is significative here.

Copy link
Owner

Choose a reason for hiding this comment

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

Makes sense. I agree with the sentiment, but I think one extra method in
the name of clarity is probably worth it.

-Mat

about.me/matschaffer

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

In lib/chef/knife/bootstrap_solo.rb:

  • class Knife
  • class Bootstrap
  •  def self.load_deps
    
  •    super
    
  •    require 'chef/knife/solo_bootstrap'
    
  •    require 'knife-solo/tools'
    
  •    SoloBootstrap.load_deps
    
  •  end
    
  •  option :solo,
    
  •    :long        => '--[no-]solo',
    
  •    :description => 'Bootstrap using knife-solo'
    
  •  # Rename and override run method
    
  •  alias_method :orig_run, :run
    

Roger. Originally I was using another method but then after the line count
had reduced (while knife-solo gained more and more compatibility), I put
all back to run not to pollute Knife::Bootstrap's namespace. But I don't
think the risk for collision is significative here.


Reply to this email directly or view it on GitHubhttps://github.com//pull/207/files#r3653608
.

tmatilai added a commit that referenced this pull request Apr 4, 2013
Integrate knife-solo to `knife bootstrap`

Monkey patch Knife::Bootstrap to include `--solo` option (and `knife[:solo]` configuration options) to trigger `knife solo bootstrap` instead of the normal template based bootstrap.
@tmatilai tmatilai merged commit 30af6d9 into matschaffer:master Apr 4, 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.

2 participants