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


Chronological Thread 
  • From: Hedge Hog < >
  • To:
  • Subject: [chef] How to use Chef::Knife.run(...) ?
  • Date: Fri, 8 Apr 2011 15:18:53 +1000
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=SRpxzONIXbuMxZJ8nJpL4K41KfSXU7mhQuOuSYr0SM4gjkafgHv1vTSuqZSi1OzG/U SO82+n1GobM7BqVpks4X97dd3VD07geZtDDTCwsqy0RmerPMIPSXEYHDFk4onxeZikh2 zxtZxH3iYNLIulhofsyvbI+7UQHhXAbXxRVYg=

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.

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



Archive powered by MHonArc 2.6.16.

§