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
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
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
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:
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
If you know ahead of time which knife subcommand you're running, can
call #run on the subclass directly instead of on Chef::Knife, and just
pass in the array of arguments without the explicit CliTemplate.
If you know ahead of time which knife subcommand you're running, can
call #run on the subclass directly instead of on Chef::Knife, and just
pass in the array of arguments without the explicit CliTemplate.
Actually it is a little easier than all the above, you can call:
::Chef::Application::Knife.new.run
However. Care has to be taken to reset ARGV after you've clobbered it
with your desired knife array.
While setting this up is not trivial, if someone comes this way, there
are (in a few days) examples in the cuken API.
--
πόλλ' οἶδ ἀλώπηξ, ἀλλ' ἐχῖνος ἓν μέγα
[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