Class: Chef::Knife::CloudformationCreate
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::CloudformationCreate
- Includes:
- KnifeCloudformation::Knife::Base, KnifeCloudformation::Knife::Stack, KnifeCloudformation::Knife::Template
- Defined in:
- lib/chef/knife/cloudformation_create.rb
Overview
Cloudformation create command
Constant Summary
Constants included from KnifeCloudformation::Knife::Template
KnifeCloudformation::Knife::Template::TEMPLATE_IGNORE_DIRECTORIES
Instance Method Summary collapse
-
#_run ⇒ Object
Run the stack creation command.
Methods included from KnifeCloudformation::Knife::Stack
Methods included from KnifeCloudformation::Knife::Template
Methods included from KnifeCloudformation::Knife::Base
Instance Method Details
#_run ⇒ Object
Run the stack creation command
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/chef/knife/cloudformation_create.rb', line 64 def _run name = name_args.first unless(name) ui.fatal "Formation name must be specified!" exit 1 end if(Chef::Config[:knife][:cloudformation][:template]) file = Chef::Config[:knife][:cloudformation][:template] else file = load_template_file nested_stacks_unpack = file.delete('sfn_nested_stack') end ui.info "#{ui.color('Cloud Formation:', :bold)} #{ui.color('create', :green)}" stack_info = "#{ui.color('Name:', :bold)} #{name}" if(Chef::Config[:knife][:cloudformation][:path]) stack_info << " #{ui.color('Path:', :bold)} #{Chef::Config[:knife][:cloudformation][:file]}" if(Chef::Config[:knife][:cloudformation][:disable_processing]) stack_info << " #{ui.color('(not pre-processed)', :yellow)}" end end unless(config[:print_only]) ui.info " -> #{stack_info}" end if(nested_stacks_unpack) unpack_nesting(name, file, :create) else stack = provider.connection.stacks.build( Chef::Config[:knife][:cloudformation][:options].dup.merge( :name => name, :template => file ) ) apply_stacks!(stack) stack.template = KnifeCloudformation::Utils::StackParameterScrubber.scrub!(stack.template) if(config[:print_only]) ui.info _format_json(translate_template(stack.template)) return end populate_parameters!(stack.template) stack.parameters = Chef::Config[:knife][:cloudformation][:options][:parameters] stack.template = translate_template(stack.template) stack.save end if(stack) if(Chef::Config[:knife][:cloudformation][:poll]) poll_stack(stack.name) stack = provider.connection.stacks.get(name) if(stack.reload.success?) ui.info "Stack create complete: #{ui.color('SUCCESS', :green)}" knife_output = Chef::Knife::CloudformationDescribe.new knife_output.name_args.push(name) knife_output.config[:outputs] = true knife_output.run else ui.fatal "Create of new stack #{ui.color(name, :bold)}: #{ui.color('FAILED', :red, :bold)}" ui.info "" knife_inspect = Chef::Knife::CloudformationInspect.new knife_inspect.name_args.push(name) knife_inspect.config[:instance_failure] = true knife_inspect.run exit 1 end else ui.warn 'Stack state polling has been disabled.' ui.info "Stack creation initialized for #{ui.color(name, :green)}" end end end |