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/ruby-1.9.2-p180@cucken/gems/mixlib-cli-1.2.0/lib/mixlib/cli.rb:95:in
dup' /home/hedge/.rvm/gems/ruby-1.9.2-p180@cucken/gems/mixlib-cli-1.2.0/lib/mixlib/cli.rb:95:in
block in initialize’
/home/hedge/.rvm/gems/ruby-1.9.2-p180@cucken/gems/mixlib-cli-1.2.0/lib/mixlib/cli.rb:94:in
each' /home/hedge/.rvm/gems/ruby-1.9.2-p180@cucken/gems/mixlib-cli-1.2.0/lib/mixlib/cli.rb:94:in
inject’
/home/hedge/.rvm/gems/ruby-1.9.2-p180@cucken/gems/mixlib-cli-1.2.0/lib/mixlib/cli.rb:94:in
initialize' /home/hedge/.rvm/gems/ruby-1.9.2-p180@cucken/gems/chef-0.9.12/lib/chef/knife.rb:191:in
initialize’
/home/hedge/.rvm/gems/ruby-1.9.2-p180@cucken/gems/chef-0.9.12/lib/chef/knife.rb:125:in
new' /home/hedge/.rvm/gems/ruby-1.9.2-p180@cucken/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