My goal is to be able to write scripts around "knife ec2 server create" without actually having to execute the knife command line utility. I'm trying to understand the classes involved and do it through Ruby (e.g., Chef::Knife::Ec2ServerCreate).
In the related ticket (http://help.opscode.com/discussions/problems/1261-invalid-image-value-error-in-knife-exec), Jessica clarified that the only config options supported are:
However, many more options are available on the "knife ec2 server" command line. I can't find a way to access all options through Ruby code, but clearly "knife ec2 server create ..." has some way of doing it. How are we suppose to use these classes?
In my own attempts to answer this question, I've found different ways of going about the Chef::Knife::Ec2Server* classes. For example, in the docs there is this example on how to use Ec2ServerDelete within a knife exec script:
# Delete the Server
delete_ec2 = Chef::Knife::Ec2ServerDelete.new()
delete_ec2.name_args = [nodes.show(name)['ec2']['instance_id']]
But in the ticket, Jessica recommends using Chef::Config directly for Chef::Knife::Ec2ServerCreate.new. Example:
create = Chef::Knife::Ec2ServerCreate.new
Chef::Config[:knife][:distro] = "centos5-gems"
Chef::Config[:knife][:image] = "ami-43c2032a"
Chef::Config[:knife][:aws_ssh_key_id] = "KEY_PAIR_NAME"
Chef::Config[:knife][:flavor] = "m1.small"
However, using this method I still can't make use of all of the options available on the command line.
How are we suppose to make use of these classes? What's the "official" API, if any? The code documentation is sparse (http://rubydoc.info/gems/knife-ec2/0.5.10/frames) and doesn't provide much direction.