Class: RakeCloudspin::Tasks::All
Instance Method Summary
collapse
#check_required, check_required_for, #initialize, parameter, parameter_definitions, #process_arguments, #process_block, #setup_defaults, setup_defaults_for
Instance Method Details
#define ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 10
def define
@configuration = Confidante.configuration(
:hiera => Hiera.new(config: hiera_file)
)
@deployment_statebucket_required = false
discover_deployment_stacks
discover_delivery_stacks
discover_account_stacks
define_terraform_installation_tasks
define_deployment_stacks_tasks
define_delivery_stacks_tasks
define_account_stacks_tasks
define_statebucket_tasks
define_top_level_deployment_tasks
define_top_level_delivery_tasks
define_top_level_account_tasks
end
|
#define_account_stacks_tasks ⇒ Object
73
74
75
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 73
def define_account_stacks_tasks
define_stack_tasks('account', @account_stacks)
end
|
#define_delivery_stacks_tasks ⇒ Object
69
70
71
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 69
def define_delivery_stacks_tasks
define_stack_tasks('delivery', @delivery_stacks)
end
|
#define_deployment_stacks_tasks ⇒ Object
65
66
67
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 65
def define_deployment_stacks_tasks
define_stack_tasks('deployment', @deployment_stacks)
end
|
#define_stack_tasks(stack_type, stacks) ⇒ Object
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
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 77
def define_stack_tasks(stack_type, stacks)
namespace stack_type do
stacks.each { |stack_name|
namespace stack_name do
StackTask.new do |t|
t.stack_name = stack_name
t.stack_type = stack_type
t.configuration = configuration
end
if deployment_statebucket_required?(stack_type, stack_name)
@deployment_statebucket_required = true
end
if stack_needs_ssh_keys?(stack_type, stack_name)
SshKeyTask.new do |t|
t.stack_name = stack_name
t.stack_type = stack_type
t.configuration = configuration
end
end
StackTestTask.new do |t|
t.stack_name = stack_name
t.stack_type = stack_type
t.configuration = configuration
end
end
}
end
end
|
#define_statebucket_tasks ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 106
def define_statebucket_tasks
if @deployment_statebucket_required
namespace 'deployment' do
namespace 'statebucket' do
DeploymentStatebucketTask.new do |t|
t.configuration = configuration
end
end
@deployment_stacks.each {|stack_name|
task "#{stack_name}:plan" => [ 'statebucket:plan' ]
task "#{stack_name}:provision" => [ 'statebucket:provision' ]
task "#{stack_name}:vars" => [ 'statebucket:vars' ]
}
end
end
end
|
58
59
60
61
62
63
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 58
def define_terraform_installation_tasks
RakeTerraform.define_installation_tasks(
path: File.join(Dir.pwd, 'vendor', 'terraform'),
version: '0.11.7'
)
end
|
#define_top_level_account_tasks ⇒ Object
144
145
146
147
148
149
150
151
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 144
def define_top_level_account_tasks
['plan', 'provision', 'destroy', 'test', 'vars'].each { |action|
desc "#{action} for all account stacks"
task "delivery_#{action}" => @delivery_stacks.map { |stack|
:"account:#{stack}:#{action}"
}
}
end
|
#define_top_level_delivery_tasks ⇒ Object
135
136
137
138
139
140
141
142
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 135
def define_top_level_delivery_tasks
['plan', 'provision', 'destroy', 'test', 'vars'].each { |action|
desc "#{action} for all delivery stacks"
task "delivery_#{action}" => @delivery_stacks.map { |stack|
:"delivery:#{stack}:#{action}"
}
}
end
|
#define_top_level_deployment_tasks ⇒ Object
126
127
128
129
130
131
132
133
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 126
def define_top_level_deployment_tasks
['plan', 'provision', 'destroy', 'test', 'vars'].each { |action|
desc "#{action} for all deployment stacks"
task action => @deployment_stacks.map { |stack|
:"deployment:#{stack}:#{action}"
}
}
end
|
#deployment_statebucket_required?(stack_type, stack_name) ⇒ Boolean
164
165
166
167
168
169
170
171
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 164
def deployment_statebucket_required?(stack_type, stack_name)
state_config = configuration
.for_scope(stack_type => stack_name).state
! state_config.nil? &&
state_config['type'] == 's3' &&
state_config['scope'] == 'deployment'
end
|
#discover_account_stacks ⇒ Object
44
45
46
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 44
def discover_account_stacks
@account_stacks = discover_stacks('account')
end
|
#discover_delivery_stacks ⇒ Object
40
41
42
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 40
def discover_delivery_stacks
@delivery_stacks = discover_stacks('delivery')
end
|
#discover_deployment_stacks ⇒ Object
36
37
38
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 36
def discover_deployment_stacks
@deployment_stacks = discover_stacks('deployment')
end
|
#discover_stacks(stack_type) ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 48
def discover_stacks(stack_type)
if Dir.exist?(stack_type)
Dir.entries(stack_type).select { |stack|
File.directory? File.join(stack_type, stack) and File.exists?("#{stack_type}/#{stack}/stack.yaml")
}
else
[]
end
end
|
#hiera_file ⇒ Object
32
33
34
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 32
def hiera_file
File.expand_path(File.join(File.dirname(__FILE__), 'hiera.yaml'))
end
|
#stack_needs_ssh_keys?(stack_type, stack) ⇒ Boolean
153
154
155
156
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 153
def stack_needs_ssh_keys?(stack_type, stack)
! configuration
.for_scope(stack_type => stack).ssh_keys.nil?
end
|
#stack_uses_remote_state?(stack_type, stack_name) ⇒ Boolean
158
159
160
161
162
|
# File 'lib/rake_cloudspin/tasks/all.rb', line 158
def stack_uses_remote_state?(stack_type, stack_name)
state_config = configuration
.for_scope(stack_type => stack_name).state
! state_config.nil? && state_config['type'] == 's3'
end
|