Class: Chef::Knife::AppInstanceCreate
- Inherits:
-
Bootstrap
- Object
- Bootstrap
- Chef::Knife::AppInstanceCreate
- Defined in:
- lib/chef/knife/app_instance_create.rb
Instance Method Summary collapse
-
#initialize(arguments) ⇒ AppInstanceCreate
constructor
A new instance of AppInstanceCreate.
-
#run ⇒ Object
This method will be executed when you run this knife command.
Constructor Details
#initialize(arguments) ⇒ AppInstanceCreate
Returns a new instance of AppInstanceCreate.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/chef/knife/app_instance_create.rb', line 13 def initialize arguments bootstrap = Chef::Knife::Bootstrap.new bootstrap..each do |name, args| AppInstanceCreate.option name, args end Chef::Knife::Bootstrap.load_deps super arguments end |
Instance Method Details
#run ⇒ Object
This method will be executed when you run this knife command.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/chef/knife/app_instance_create.rb', line 26 def run # Get Arguments if @name_args.size < 1 ui.info("Please specify an app_id") show_usage exit 1 end app_id = @name_args[0] properties = parse_properties @name_args[1, @name_args.size] db = Chapp.database provisioner = Chapp.provisioner app_config = db.app_config app_id # TODO: May need something better than Time node_name = "chapp_#{app_id}_#{Time.now.to_i}" # Provision the server and retrieve the host name host = provisioner.build_server app_config, properties # Tells bootstrap what environment to use Chef::Config[:environment] = app_config.environment_name # Tells bootstrap what run_list to use @config[:run_list] = "role[#{app_config.role_name}]" # Tells bootstrap what node name to use @config[:chef_node_name] = node_name # Tells bootstrap what ip/fqdn to use @name_args = host # Runs bootstrap super # We have to save the node here since bootstrap wont actually assign the run_list node = Node.new node.name node_name node.run_list = Chef::RunList.new "role[#{app_config.role_name}]" node.chef_environment = app_config.environment_name node.save end |