Skip to content

Commit

Permalink
Added parameter --user-data for cloud-init payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Thielen committed Jan 16, 2014
1 parent 8b8fd13 commit 99c56e5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/chef/knife/openstack_server_create.rb
Expand Up @@ -163,6 +163,12 @@ class OpenstackServerCreate < Knife
:proc => lambda { |o| JSON.parse(o) },
:default => {}

option :user_data,
:short => "-u USER_DATA",
:long => "--user-data USER_DATA",
:description => "The file path containing user data information for this server",
:proc => Proc.new { |user_data| open(user_data) { |f| f.read } }

def tcp_test_ssh(hostname, port)
tcp_socket = TCPSocket.new(hostname, port)
readable = IO.select([tcp_socket], nil, nil, 5)
Expand Down Expand Up @@ -255,14 +261,16 @@ def run
:image_ref => locate_config_value(:image),
:flavor_ref => locate_config_value(:flavor),
:security_groups => locate_config_value(:security_groups),
:key_name => locate_config_value(:openstack_ssh_key_id)
:key_name => locate_config_value(:openstack_ssh_key_id),
:user_data => locate_config_value(:user_data)
}

Chef::Log.debug("Name #{node_name}")
Chef::Log.debug("Image #{locate_config_value(:image)}")
Chef::Log.debug("Flavor #{locate_config_value(:flavor)}")
Chef::Log.debug("Requested Floating IP #{locate_config_value(:floating_ip)}")
Chef::Log.debug("Security Groups #{locate_config_value(:security_groups)}")
Chef::Log.debug("User Data #{locate_config_value(:user_data)}")
Chef::Log.debug("Creating server #{server_def}")

begin
Expand Down

0 comments on commit 99c56e5

Please sign in to comment.