Skip to content

Instantly share code, notes, and snippets.

@andrewgross
Created May 9, 2012 17:07
Show Gist options
  • Save andrewgross/2646785 to your computer and use it in GitHub Desktop.
Save andrewgross/2646785 to your computer and use it in GitHub Desktop.
No Host Key Verify Monkey Patch
class Chef::Knife::Ec2ServerCreate < Chef::Knife
alias :original_run :run
def run
@initial_sleep_delay = 30
original_run
end
option :attrs,
:long => "--attrs ATTRS",
:description => "Atttibutes to be added to the node",
:proc => lambda { |o| eval(o) },
:default => {}
def bootstrap_for_node(server, unknownarg)
bootstrap = Chef::Knife::Bootstrap.new
bootstrap.name_args = [vpc_mode? ? server.private_ip_address : server.dns_name ]
bootstrap.config[:run_list] = config[:run_list]
bootstrap.config[:ssh_user] = config[:ssh_user]
bootstrap.config[:identity_file] = config[:identity_file]
bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.id
bootstrap.config[:prerelease] = config[:prerelease]
bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
bootstrap.config[:distro] = locate_config_value(:distro)
bootstrap.config[:use_sudo] = true
bootstrap.config[:template_file] = locate_config_value(:template_file)
bootstrap.config[:environment] = config[:environment]
# This is the only life that differs from the original definition. It passes
# It passes our attributes through to the bootstrapping script
bootstrap.config[:attrs] = config[:attrs]
# may be needed for vpc_mode
bootstrap.config[:no_host_key_verify] = config[:no_host_key_verify]
bootstrap
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment