[chef] Re: How to use Chef::Knife.run(...) ?


Chronological Thread 
  • From: Hedge Hog < >
  • To:
  • Subject: [chef] Re: How to use Chef::Knife.run(...) ?
  • Date: Mon, 11 Apr 2011 12:13:50 +1000
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=DByOCI2mrQ9fR63uGAsgoS6kuQvOra0obYNFrju3wLjula5ygPzsIFATglpr72APp+ gZjxj4SztIKKKK3asOp7pt2TCZIazD1AL+gTHdnCK2tyMiYWFRAc6VM6fl5iwZxQP8LD plW1K8MIK7qgH2DpofeN4IRzZg5yyIeT4Bt7Y=

On Fri, Apr 8, 2011 at 3:18 PM, Hedge Hog 
< >
 wrote:
> Hi,
> Rather than shell out of a script to execute Knife commands, it should
> be possible to call
> Chef::Knife.run(cmd_arry, opts)
> from within your script.
>
> Maybe I'm tired, or too dense to see the wood for the trees.
> But I'm having a devil of a time trying to work out how to pass in the 
> options.
>
> If I pass in "{:no_editor=>true, :file=>"/some/sekret.pem",
> :admin=>true, :config_file=>"/etc/chef/knife.rb"}" I get
>
> TypeError: can't dup TrueClass
> /home/hedge/.rvm/gems/ /gems/mixlib-cli-1.2.0/lib/mixlib/cli.rb:95:in
> `dup'
> /home/hedge/.rvm/gems/ /gems/mixlib-cli-1.2.0/lib/mixlib/cli.rb:95:in
> `block in initialize'
> /home/hedge/.rvm/gems/ /gems/mixlib-cli-1.2.0/lib/mixlib/cli.rb:94:in
> `each'
> /home/hedge/.rvm/gems/ /gems/mixlib-cli-1.2.0/lib/mixlib/cli.rb:94:in
> `inject'
> /home/hedge/.rvm/gems/ /gems/mixlib-cli-1.2.0/lib/mixlib/cli.rb:94:in
> `initialize'
> /home/hedge/.rvm/gems/ /gems/chef-0.9.12/lib/chef/knife.rb:191:in
> `initialize'
> /home/hedge/.rvm/gems/ /gems/chef-0.9.12/lib/chef/knife.rb:125:in
> `new'
> /home/hedge/.rvm/gems/ /gems/chef-0.9.12/lib/chef/knife.rb:125:in
> `run'
>
> and if I convert all the booleans to strings, I get:
>
> TypeError: can't convert Symbol into Integer
>
> Appreciate if any one could show how this usage should be written.
>

In case anyone else wishes to use Knife's cli without shelling out,
this should get you heading in the right direction:

https://gist.github.com/912977

HTH

> Best wishes
>
> --
> πόλλ' οἶδ ἀλώπηξ, ἀλλ' ἐχῖνος ἓν μέγα
> [The fox knows many things, but the hedgehog knows one big thing.]
>   Archilochus, Greek poet (c. 680 BC – c. 645 BC)
> http://wiki.hedgehogshiatus.com
>



-- 
πόλλ' οἶδ ἀλώπηξ, ἀλλ' ἐχῖνος ἓν μέγα
[The fox knows many things, but the hedgehog knows one big thing.]
  Archilochus, Greek poet (c. 680 BC – c. 645 BC)
http://wiki.hedgehogshiatus.com



Archive powered by MHonArc 2.6.16.

§