[chef] Re: Re: Re: knife ec2 - knife.rb takes precedence over command line options


Chronological Thread 
  • From: Christopher Brown < >
  • To:
  • Subject: [chef] Re: Re: Re: knife ec2 - knife.rb takes precedence over command line options
  • Date: Thu, 26 Apr 2012 08:20:16 -0700

The option handling code needs to be re-examined across the board.  I recently ran into the same thing while rewriting the knife terremark plugin.  This behavior seems to surprise everyone.
-C

On Apr 26, 2012, at 7:03 AM, Jesse Campbell wrote:

The way the options parser is written,  without a custom function either knife.rb overrides command line options, or command line default values override knife.rb.

For the knife vsphere plugin I ended up writing a get_config function to force command line options > knife.rb > default values in the code.

Not the cleanest approach, but at the time the config hash is being generated, the knife.rb has not yet been parsed, so it isn't possible to set defaults from knife.rb using the built in mixlib.

See https://github.com/ezrapagel/knife-vsphere/blob/master/lib/chef/knife/BaseVsphereCommand.rb

-Jesse

On Apr 26, 2012 4:47 AM, "AJ Christensen" < " target="_blank"> > wrote:
I've had more than one occasion where it's impossible to set an option
via the knife.rb, only the CLI. There are a number of issues here. I
have occasionally resorted to medium-Ruby magic to inject my custom,
overridable settings into Knife.

Would definitely like to see both sides of this blade sharpened a little.

--AJ

On 26 April 2012 20:13, Nick Peirson < " target="_blank"> > wrote:
> Hi All,
>
> Is this the expected behaviour? I've raised it as an issue in github
> (https://github.com/opscode/knife-ec2/issues/41), but thought I'd seek
> others opinions here as well. It seems to prevent knife ec2 commands from
> being scripted effectively if there are entries in knife.rb.
>
> Use case is having defaults in knife.rb to spin up instances quickly while
> testing things without having to type a command line as long as your arm,
> but occasionally want a different AMI or to start an instance in a different
> AZ by quickly overriding on the command line. At the moment it's a case of
> having to change the knife.rb, run the command, change it back or,
> alternatively, leave the options out of knife.rb and always pass as command
> line arguments.
>
> It surprises me that this isn't affecting anyone else, so I'm wondering if
> I'm doing something to cause this behaviour?
>
> Cheers
> Nick
>




Archive powered by MHonArc 2.6.16.

§