Skip to content

Instantly share code, notes, and snippets.

@andrewgross
Created September 12, 2012 19:43
Show Gist options
  • Save andrewgross/3709383 to your computer and use it in GitHub Desktop.
Save andrewgross/3709383 to your computer and use it in GitHub Desktop.
Fix Knife Bootstrap Run List issues
class Chef::Knife::Ec2ServerCreate < Chef::Knife
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]
bootstrap
end
end
require 'chef/knife/bootstrap'
class Chef::Knife::Bootstrap < Chef::Knife
def render_template(template=nil)
bootstrap_environment = config[:environment] || '_default'
first_boot = config[:attrs]
first_boot["run_list"] = config[:run_list]
context = Chef::Knife::Core::BootstrapContext.new(config, first_boot, Chef::Config)
Erubis::Eruby.new(template).evaluate(context)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment