convection 0.2.34.pre.beta.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/convection +7 -4
- data/example/demo-cloud/Cloudfile +49 -0
- data/lib/convection/control/cloud.rb +43 -9
- data/lib/convection/model/cloudfile.rb +6 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd846eec3c4ac7ee0d3e4e2053ae0952a23955a5
|
4
|
+
data.tar.gz: 19e03ceb6351b1f136efb020de67b76abef91e9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da357166bb2b7a0f37a56c4af42266b23d7e9330a52c2aefa83e963825f8530d5ba33c97e388c86cc4656548057aab6da68053e4b0219bd0c0ac738d5959635b
|
7
|
+
data.tar.gz: 44feaba9519541d70f1808185d1faea01b8b13c712a7d9ba042882f54c8ee3e6334d30a1b3d8de59a3c2d67dd318d9fb34d4e839e3ef9e30d3012d5b6c1188fd
|
data/bin/convection
CHANGED
@@ -15,9 +15,11 @@ module Convection
|
|
15
15
|
end
|
16
16
|
|
17
17
|
desc 'converge STACK', 'Converge your cloud'
|
18
|
+
option :stack_group, :type => :string, :desc => 'The name of a stack group defined in your cloudfile to converge'
|
19
|
+
option :stacks, :type => :array, :desc => 'A ordered space separated list of stacks to converge'
|
18
20
|
def converge(stack = nil)
|
19
21
|
@cloud.configure(File.absolute_path(options['cloudfile'], @cwd))
|
20
|
-
@cloud.converge(stack) do |event, errors|
|
22
|
+
@cloud.converge(stack, stack_group: options[:stack_group], stacks: options[:stacks]) do |event, errors|
|
21
23
|
say_status(*event.to_thor)
|
22
24
|
errors.each do |error|
|
23
25
|
say "* #{ error.message }"
|
@@ -29,14 +31,15 @@ module Convection
|
|
29
31
|
desc 'diff STACK', 'Show changes that will be applied by converge'
|
30
32
|
option :verbose, :type => :boolean, :aliases => '--v', :desc => 'Show stack progress'
|
31
33
|
option :'very-verbose', :type => :boolean, :aliases => '--vv', :desc => 'Show unchanged stacks'
|
34
|
+
option :stack_group, :type => :string, :desc => 'The name of a stack group defined in your cloudfile to diff'
|
35
|
+
option :stacks, :type => :array, :desc => 'A ordered space separated list of stacks to diff'
|
32
36
|
def diff(stack = nil)
|
33
37
|
@cloud.configure(File.absolute_path(options['cloudfile'], @cwd))
|
34
|
-
|
35
38
|
last_event = nil
|
36
39
|
|
37
|
-
@cloud.diff(stack) do |d|
|
40
|
+
@cloud.diff(stack, stack_group: options[:stack_group], stacks: options[:stacks]) do |d|
|
38
41
|
if d.is_a? Model::Event
|
39
|
-
if options[:'very-verbose']
|
42
|
+
if options[:'very-verbose'] || d.name == :error
|
40
43
|
say_status(*d.to_thor)
|
41
44
|
elsif options[:verbose]
|
42
45
|
say_status(*d.to_thor) if d.name == :compare
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#See the getting started guide for a description of this file and what it does.
|
2
|
+
#to run this file make sure you are following the project layout in the getting started guide
|
3
|
+
Dir.glob('./../../templates/**.rb') do |file|
|
4
|
+
require_relative file
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'convection'
|
8
|
+
|
9
|
+
region 'us-east-1'
|
10
|
+
prefix = ENV['USER'] || 'anon-'
|
11
|
+
name "#{prefix}-convection-demo"
|
12
|
+
|
13
|
+
module Templates
|
14
|
+
INSTANCE1 = Convection.template {
|
15
|
+
ec2_instance('FooInstance') {
|
16
|
+
image_id 'ami-c02b04a8'
|
17
|
+
}
|
18
|
+
}
|
19
|
+
INSTANCE2 = Convection.template {
|
20
|
+
ec2_instance('BarInstance') {
|
21
|
+
image_id 'ami-c02b04a8'
|
22
|
+
}
|
23
|
+
}
|
24
|
+
INSTANCE3 = Convection.template {
|
25
|
+
ec2_instance('BazInstance') {
|
26
|
+
image_id 'ami-c02b04a8'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
VPC1 = Convection.template {
|
30
|
+
ec2_vpc('FooVpc') {
|
31
|
+
network '10.1.1.0/24'
|
32
|
+
}
|
33
|
+
}
|
34
|
+
VPC2 = Convection.template {
|
35
|
+
ec2_vpc('BarVpc') {
|
36
|
+
network '10.1.2.0/24'
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
stack 'vpc1', Templates::VPC1
|
42
|
+
stack 'vpc2', Templates::VPC2
|
43
|
+
stack_group 'vpcs', %w(vpc1 vpc2)
|
44
|
+
|
45
|
+
stack 'instance1', Templates::INSTANCE1
|
46
|
+
stack 'instance2', Templates::INSTANCE2
|
47
|
+
stack_group 'primary-instances', %w(instance1 instance2)
|
48
|
+
|
49
|
+
stack 'instance3', Templates::INSTANCE3
|
@@ -16,17 +16,46 @@ module Convection
|
|
16
16
|
@cloudfile.stacks
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
@cloudfile.
|
19
|
+
def stack_groups
|
20
|
+
@cloudfile.stack_groups
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
23
|
+
def filter_deck(options = {}, &block)
|
24
|
+
# throw an error if the user specifies both a stack group and list of stacks
|
25
|
+
if options[:stack_group] && options[:stacks]
|
26
|
+
block.call(Model::Event.new(:error, 'Cannot specify --stack-group and --stack-list at the same time', :error)) if block
|
27
|
+
return {}
|
28
|
+
end
|
29
|
+
|
30
|
+
# throw an error if the user specifies a nonexistent stack groups
|
31
|
+
if options[:stack_group] && !stack_groups.key?(options[:stack_group])
|
32
|
+
block.call(Model::Event.new(:error, "Unknown stack group: #{options[:stack_group]}", :error)) if block
|
33
|
+
return {}
|
34
|
+
end
|
35
|
+
|
36
|
+
# throw an error if the user specifies nonexistent stacks
|
37
|
+
if Array(options[:stacks]).any? { |name| !@cloudfile.stacks.key?(name) }
|
38
|
+
bad_stack_names = options[:stacks].reject { |name| @cloudfile.stacks.key?(name) }
|
39
|
+
block.call(Model::Event.new(:error, "Undefined Stack(s) #{bad_stack_names.join(', ')}", :error)) if block
|
40
|
+
return {}
|
41
|
+
end
|
42
|
+
|
43
|
+
filter = Array(stack_groups[options[:stack_group]] || options[:stacks])
|
44
|
+
|
45
|
+
# if no filter is specified, return the entire deck
|
46
|
+
return stacks if filter.empty?
|
47
|
+
filter.reduce({}) do |result, stack_name|
|
48
|
+
result.merge(stack_name => @cloudfile.stacks[stack_name])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def converge(to_stack, options = {}, &block)
|
53
|
+
if to_stack && !stacks.include?(to_stack)
|
54
|
+
block.call(Model::Event.new(:error, "Undefined Stack #{ to_stack }", :error)) if block
|
26
55
|
return
|
27
56
|
end
|
28
57
|
|
29
|
-
|
58
|
+
filter_deck(options, &block).each_value do |stack|
|
30
59
|
block.call(Model::Event.new(:converge, "Stack #{ stack.name }", :info)) if block
|
31
60
|
stack.apply(&block)
|
32
61
|
|
@@ -44,13 +73,18 @@ module Convection
|
|
44
73
|
end
|
45
74
|
end
|
46
75
|
|
47
|
-
def diff(to_stack, &block)
|
48
|
-
|
76
|
+
def diff(to_stack, options = {}, &block)
|
77
|
+
if to_stack && !stacks.include?(to_stack)
|
78
|
+
block.call(Model::Event.new(:error, "Undefined Stack #{ to_stack }", :error)) if block
|
79
|
+
return
|
80
|
+
end
|
81
|
+
|
82
|
+
filter_deck(options, &block).each_value do |stack|
|
49
83
|
block.call(Model::Event.new(:compare, "Compare local state of stack #{ stack.name } (#{ stack.cloud_name }) with remote template", :info))
|
50
84
|
|
51
85
|
difference = stack.diff
|
52
86
|
if difference.empty?
|
53
|
-
difference << Model::Event.new(:unchanged, "Stack #{ stack.cloud_name }
|
87
|
+
difference << Model::Event.new(:unchanged, "Stack #{ stack.cloud_name } has no changes", :info)
|
54
88
|
end
|
55
89
|
|
56
90
|
difference.each { |diff| block.call(diff) }
|
@@ -35,6 +35,10 @@ module Convection
|
|
35
35
|
@stacks[stack_name] = Control::Stack.new(stack_name, template, options, &block)
|
36
36
|
@deck << @stacks[stack_name]
|
37
37
|
end
|
38
|
+
|
39
|
+
def stack_group(group_name, group_list)
|
40
|
+
@stack_groups[group_name] = group_list
|
41
|
+
end
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
@@ -48,11 +52,13 @@ module Convection
|
|
48
52
|
attr_reader :attributes
|
49
53
|
attr_reader :stacks
|
50
54
|
attr_reader :deck
|
55
|
+
attr_reader :stack_groups
|
51
56
|
|
52
57
|
def initialize(cloudfile)
|
53
58
|
@attributes = Model::Attributes.new
|
54
59
|
@stacks = {}
|
55
60
|
@deck = []
|
61
|
+
@stack_groups = {}
|
56
62
|
|
57
63
|
instance_eval(IO.read(cloudfile), cloudfile, 1)
|
58
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Manero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- docs/stacks.md
|
101
101
|
- docs/template.html
|
102
102
|
- example/.ruby-version
|
103
|
+
- example/demo-cloud/Cloudfile
|
103
104
|
- example/getting-started-guide/Cloudfile
|
104
105
|
- example/getting-started-guide/vpc.rb
|
105
106
|
- example/stacks/Cloudfile
|
@@ -274,12 +275,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
274
275
|
version: '0'
|
275
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
276
277
|
requirements:
|
277
|
-
- - "
|
278
|
+
- - ">="
|
278
279
|
- !ruby/object:Gem::Version
|
279
|
-
version:
|
280
|
+
version: '0'
|
280
281
|
requirements: []
|
281
282
|
rubyforge_project:
|
282
|
-
rubygems_version: 2.4.
|
283
|
+
rubygems_version: 2.4.3
|
283
284
|
signing_key:
|
284
285
|
specification_version: 4
|
285
286
|
summary: A fully generic, modular DSL for AWS CloudFormation
|