-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
133 lines (110 loc) · 3.08 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
$:.unshift File.join(File.dirname(__FILE__), 'lib')
require 'rake_terraform'
require 'confidante'
require 'yaml'
RakeTerraform.define_installation_tasks(
path: File.join(Dir.pwd, 'vendor', 'terraform'),
version: '0.11.1')
configuration = Confidante.configuration
task :default => [
:'bootstrap:plan',
:'network:plan',
:'cluster:plan'
]
namespace :names do
task :random do
puts
puts YAML.load_file('config/names.yaml')['elements'].sample
end
end
namespace :bootstrap do
RakeTerraform.define_command_tasks do |t|
t.argument_names = [:deployment_identifier]
t.configuration_name = 'bootstrap'
t.source_directory = 'infra/bootstrap'
t.work_directory = 'build'
t.state_file = lambda do |args|
deployment_identifier =
configuration
.for_overrides(args)
.deployment_identifier
File.join(Dir.pwd, "state/bootstrap-#{deployment_identifier}.tfstate")
end
t.vars = lambda do |args|
deployment_identifier =
configuration
.for_overrides(args)
.deployment_identifier
configuration
.for_overrides(args)
.for_scope(
role: 'bootstrap',
deployment: deployment_identifier)
.vars
end
end
end
namespace :network do
RakeTerraform.define_command_tasks do |t|
t.argument_names = [:deployment_identifier]
t.configuration_name = 'network'
t.source_directory = 'infra/network'
t.work_directory = 'build'
t.backend_config = lambda do |args|
deployment_identifier =
configuration
.for_overrides(args)
.deployment_identifier
configuration
.for_overrides(args)
.for_scope(
role: 'network',
deployment: deployment_identifier)
.backend_config
end
t.vars = lambda do |args|
deployment_identifier =
configuration
.for_overrides(args)
.deployment_identifier
configuration
.for_overrides(args)
.for_scope(
role: 'network',
deployment: deployment_identifier)
.vars
end
end
end
namespace :cluster do
RakeTerraform.define_command_tasks do |t|
t.argument_names = [:deployment_identifier]
t.configuration_name = 'cluster'
t.source_directory = 'infra/cluster'
t.work_directory = 'build'
t.backend_config = lambda do |args|
deployment_identifier =
configuration
.for_overrides(args)
.deployment_identifier
configuration
.for_overrides(args)
.for_scope(
role: 'cluster',
deployment: deployment_identifier)
.backend_config
end
t.vars = lambda do |args|
deployment_identifier =
configuration
.for_overrides(args)
.deployment_identifier
configuration
.for_overrides(args)
.for_scope(
role: 'cluster',
deployment: deployment_identifier)
.vars
end
end
end