Skip to content

Instantly share code, notes, and snippets.

@bigkraig
Created September 6, 2012 01:06
Show Gist options
  • Save bigkraig/3649331 to your computer and use it in GitHub Desktop.
Save bigkraig/3649331 to your computer and use it in GitHub Desktop.
modification to knife cs create server to allow a default run_list to be set in knife.rb
diff --git a/lib/chef/knife/cs_server_create.rb b/lib/chef/knife/cs_server_create.rb
index 240dd51..eb357b6 100644
--- a/lib/chef/knife/cs_server_create.rb
+++ b/lib/chef/knife/cs_server_create.rb
@@ -135,8 +135,8 @@ module KnifeCloudstack
:short => "-r RUN_LIST",
:long => "--run-list RUN_LIST",
:description => "Comma separated list of roles/recipes to apply",
- :proc => lambda { |o| o.split(/[\s,]+/) },
- :default => []
+ :proc => Proc.new { |t| Chef::Config[:knife][:run_list] = t },
+ :default => ""
option :no_host_key_verify,
:long => "--no-host-key-verify",
@@ -169,7 +169,6 @@ module KnifeCloudstack
validate_options
$stdout.sync = true
-
connection = CloudstackClient::Connection.new(
locate_config_value(:cloudstack_url),
locate_config_value(:cloudstack_api_key),
@@ -231,6 +230,12 @@ module KnifeCloudstack
ui.error("You must specify either an ssh identity file or an ssh user and password")
exit 1
end
+
+ if config[:run_list].empty? and Chef::Config[:knife].has_key?(:run_list)
+ config[:run_list] = Chef::Config[:knife][:run_list].split(/[\s,]+/)
+ else
+ config[:run_list] =config[:run_list].split(/[\s,]+/)
+ end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment