rake_terraform 1.14.0.pre.1 → 1.16.0.pre.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +94 -14
- data/Rakefile +89 -42
- data/bin/console +4 -3
- data/lib/rake_terraform.rb +33 -114
- data/lib/rake_terraform/task_sets.rb +4 -0
- data/lib/rake_terraform/task_sets/all.rb +50 -40
- data/lib/rake_terraform/task_sets/provider.rb +168 -0
- data/lib/rake_terraform/task_sets/terraform.rb +179 -0
- data/lib/rake_terraform/tasks.rb +2 -0
- data/lib/rake_terraform/tasks/destroy.rb +42 -30
- data/lib/rake_terraform/tasks/output.rb +34 -28
- data/lib/rake_terraform/tasks/plan.rb +40 -32
- data/lib/rake_terraform/tasks/provision.rb +42 -31
- data/lib/rake_terraform/tasks/validate.rb +33 -33
- data/lib/rake_terraform/version.rb +3 -1
- data/rake_terraform.gemspec +62 -0
- metadata +130 -47
data/lib/rake_terraform/tasks.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake_factory'
|
2
4
|
require 'ruby_terraform'
|
3
5
|
require 'ostruct'
|
@@ -7,16 +9,16 @@ module RakeTerraform
|
|
7
9
|
module Tasks
|
8
10
|
class Destroy < RakeFactory::Task
|
9
11
|
default_name :destroy
|
10
|
-
default_prerequisites
|
12
|
+
default_prerequisites(RakeFactory::DynamicValue.new do |t|
|
11
13
|
[t.ensure_task_name]
|
12
|
-
|
13
|
-
default_description
|
14
|
+
end)
|
15
|
+
default_description(RakeFactory::DynamicValue.new do |t|
|
14
16
|
"Destroy #{t.configuration_name} using terraform"
|
15
|
-
|
17
|
+
end)
|
16
18
|
|
17
|
-
parameter :configuration_name, :
|
18
|
-
parameter :source_directory, :
|
19
|
-
parameter :work_directory, :
|
19
|
+
parameter :configuration_name, required: true
|
20
|
+
parameter :source_directory, required: true
|
21
|
+
parameter :work_directory, required: true
|
20
22
|
|
21
23
|
parameter :backend_config
|
22
24
|
|
@@ -24,41 +26,51 @@ module RakeTerraform
|
|
24
26
|
parameter :var_file
|
25
27
|
parameter :state_file
|
26
28
|
|
27
|
-
parameter :debug, :
|
28
|
-
parameter :
|
29
|
-
parameter :
|
29
|
+
parameter :debug, default: false
|
30
|
+
parameter :input, default: false
|
31
|
+
parameter :no_color, default: false
|
32
|
+
parameter :no_backup, default: false
|
30
33
|
|
31
34
|
parameter :backup_file
|
32
35
|
|
33
|
-
parameter :ensure_task_name, :
|
36
|
+
parameter :ensure_task_name, default: :'terraform:ensure'
|
37
|
+
|
38
|
+
# rubocop:disable Metrics/BlockLength
|
34
39
|
|
35
40
|
action do |t|
|
36
41
|
Colored2.disable! if t.no_color
|
37
42
|
|
43
|
+
module_directory =
|
44
|
+
File.join(FileUtils.pwd, t.source_directory)
|
38
45
|
configuration_directory =
|
39
|
-
|
46
|
+
File.join(t.work_directory, t.source_directory)
|
40
47
|
|
41
|
-
puts "Destroying #{t.configuration_name}".cyan
|
42
|
-
RubyTerraform.clean(
|
43
|
-
directory: configuration_directory)
|
48
|
+
Kernel.puts "Destroying #{t.configuration_name}".cyan
|
44
49
|
|
45
|
-
|
46
|
-
|
50
|
+
FileUtils.rm_rf(configuration_directory)
|
51
|
+
FileUtils.mkdir_p(configuration_directory)
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
53
|
+
RubyTerraform.init(
|
54
|
+
chdir: configuration_directory,
|
55
|
+
from_module: module_directory,
|
56
|
+
backend_config: t.backend_config,
|
57
|
+
no_color: t.no_color,
|
58
|
+
input: t.input
|
59
|
+
)
|
60
|
+
RubyTerraform.destroy(
|
61
|
+
chdir: configuration_directory,
|
62
|
+
force: true,
|
63
|
+
input: t.input,
|
64
|
+
no_color: t.no_color,
|
65
|
+
no_backup: t.no_backup,
|
66
|
+
backup: t.backup_file,
|
67
|
+
state: t.state_file,
|
68
|
+
vars: t.vars,
|
69
|
+
var_file: t.var_file
|
70
|
+
)
|
61
71
|
end
|
72
|
+
|
73
|
+
# rubocop:enable Metrics/BlockLength
|
62
74
|
end
|
63
75
|
end
|
64
76
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake_factory'
|
2
4
|
require 'ruby_terraform'
|
3
5
|
require 'ostruct'
|
@@ -7,53 +9,57 @@ module RakeTerraform
|
|
7
9
|
module Tasks
|
8
10
|
class Output < RakeFactory::Task
|
9
11
|
default_name :output
|
10
|
-
default_prerequisites
|
12
|
+
default_prerequisites(RakeFactory::DynamicValue.new do |t|
|
11
13
|
[t.ensure_task_name]
|
12
|
-
|
13
|
-
default_description
|
14
|
+
end)
|
15
|
+
default_description(RakeFactory::DynamicValue.new do |t|
|
14
16
|
"Output #{t.configuration_name} using terraform"
|
15
|
-
|
17
|
+
end)
|
16
18
|
|
17
|
-
parameter :configuration_name, :
|
18
|
-
parameter :source_directory, :
|
19
|
-
parameter :work_directory, :
|
19
|
+
parameter :configuration_name, required: true
|
20
|
+
parameter :source_directory, required: true
|
21
|
+
parameter :work_directory, required: true
|
20
22
|
|
21
23
|
parameter :backend_config
|
22
24
|
|
23
25
|
parameter :state_file
|
24
26
|
|
25
|
-
parameter :debug, :
|
26
|
-
parameter :
|
27
|
-
parameter :
|
27
|
+
parameter :debug, default: false
|
28
|
+
parameter :input, default: false
|
29
|
+
parameter :no_color, default: false
|
30
|
+
parameter :no_print_output, default: false
|
28
31
|
|
29
|
-
parameter :ensure_task_name, :
|
32
|
+
parameter :ensure_task_name, default: :'terraform:ensure'
|
30
33
|
|
31
34
|
action do |t|
|
32
35
|
Colored2.disable! if t.no_color
|
33
36
|
|
37
|
+
module_directory =
|
38
|
+
File.join(FileUtils.pwd, t.source_directory)
|
34
39
|
configuration_directory =
|
35
|
-
|
36
|
-
|
37
|
-
puts "Output of #{t.configuration_name}".cyan
|
38
|
-
RubyTerraform.clean(
|
39
|
-
directory: configuration_directory)
|
40
|
+
File.join(t.work_directory, t.source_directory)
|
40
41
|
|
41
|
-
|
42
|
-
cp_r t.source_directory, configuration_directory
|
42
|
+
Kernel.puts("Output of #{t.configuration_name}".cyan)
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
backend_config: t.backend_config,
|
47
|
-
no_color: t.no_color)
|
44
|
+
FileUtils.rm_rf(configuration_directory)
|
45
|
+
FileUtils.mkdir_p(configuration_directory)
|
48
46
|
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
RubyTerraform.init(
|
48
|
+
chdir: configuration_directory,
|
49
|
+
from_module: module_directory,
|
50
|
+
backend_config: t.backend_config,
|
51
|
+
no_color: t.no_color,
|
52
|
+
input: t.input
|
53
|
+
)
|
54
|
+
output = RubyTerraform.output(
|
55
|
+
chdir: configuration_directory,
|
56
|
+
no_color: t.no_color,
|
57
|
+
state: t.state_file
|
58
|
+
)
|
52
59
|
|
53
|
-
|
60
|
+
Kernel.puts(output) unless t.no_print_output
|
54
61
|
|
55
|
-
|
56
|
-
end
|
62
|
+
output
|
57
63
|
end
|
58
64
|
end
|
59
65
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake_factory'
|
2
4
|
require 'ruby_terraform'
|
3
5
|
require 'ostruct'
|
@@ -7,16 +9,16 @@ module RakeTerraform
|
|
7
9
|
module Tasks
|
8
10
|
class Plan < RakeFactory::Task
|
9
11
|
default_name :plan
|
10
|
-
default_prerequisites
|
12
|
+
default_prerequisites(RakeFactory::DynamicValue.new do |t|
|
11
13
|
[t.ensure_task_name]
|
12
|
-
|
13
|
-
default_description
|
14
|
+
end)
|
15
|
+
default_description(RakeFactory::DynamicValue.new do |t|
|
14
16
|
"Plan #{t.configuration_name} using terraform"
|
15
|
-
|
17
|
+
end)
|
16
18
|
|
17
|
-
parameter :configuration_name, :
|
18
|
-
parameter :source_directory, :
|
19
|
-
parameter :work_directory, :
|
19
|
+
parameter :configuration_name, required: true
|
20
|
+
parameter :source_directory, required: true
|
21
|
+
parameter :work_directory, required: true
|
20
22
|
|
21
23
|
parameter :backend_config
|
22
24
|
|
@@ -24,39 +26,45 @@ module RakeTerraform
|
|
24
26
|
parameter :var_file
|
25
27
|
parameter :state_file
|
26
28
|
|
27
|
-
parameter :debug, :
|
28
|
-
parameter :
|
29
|
+
parameter :debug, default: false
|
30
|
+
parameter :input, default: false
|
31
|
+
parameter :no_color, default: false
|
29
32
|
|
30
33
|
parameter :plan_file
|
31
|
-
parameter :destroy, :
|
34
|
+
parameter :destroy, default: false
|
32
35
|
|
33
|
-
parameter :ensure_task_name, :
|
36
|
+
parameter :ensure_task_name, default: :'terraform:ensure'
|
34
37
|
|
35
38
|
action do |t|
|
36
39
|
Colored2.disable! if t.no_color
|
37
40
|
|
41
|
+
module_directory =
|
42
|
+
File.join(FileUtils.pwd, t.source_directory)
|
38
43
|
configuration_directory =
|
39
|
-
|
40
|
-
|
41
|
-
puts
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
44
|
+
File.join(t.work_directory, t.source_directory)
|
45
|
+
|
46
|
+
Kernel.puts("Planning #{configuration_name}".cyan)
|
47
|
+
|
48
|
+
FileUtils.rm_rf(configuration_directory)
|
49
|
+
FileUtils.mkdir_p(configuration_directory)
|
50
|
+
|
51
|
+
RubyTerraform.init(
|
52
|
+
chdir: configuration_directory,
|
53
|
+
from_module: module_directory,
|
54
|
+
backend_config: t.backend_config,
|
55
|
+
no_color: t.no_color,
|
56
|
+
input: t.input
|
57
|
+
)
|
58
|
+
RubyTerraform.plan(
|
59
|
+
chdir: configuration_directory,
|
60
|
+
input: t.input,
|
61
|
+
no_color: t.no_color,
|
62
|
+
destroy: t.destroy,
|
63
|
+
state: t.state_file,
|
64
|
+
plan: t.plan_file,
|
65
|
+
vars: t.vars,
|
66
|
+
var_file: t.var_file
|
67
|
+
)
|
60
68
|
end
|
61
69
|
end
|
62
70
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake_factory'
|
2
4
|
require 'ruby_terraform'
|
3
5
|
require 'ostruct'
|
@@ -7,16 +9,16 @@ module RakeTerraform
|
|
7
9
|
module Tasks
|
8
10
|
class Provision < RakeFactory::Task
|
9
11
|
default_name :provision
|
10
|
-
default_prerequisites
|
12
|
+
default_prerequisites(RakeFactory::DynamicValue.new do |t|
|
11
13
|
[t.ensure_task_name]
|
12
|
-
|
13
|
-
default_description
|
14
|
+
end)
|
15
|
+
default_description(RakeFactory::DynamicValue.new do |t|
|
14
16
|
"Provision #{t.configuration_name} using terraform"
|
15
|
-
|
17
|
+
end)
|
16
18
|
|
17
|
-
parameter :configuration_name, :
|
18
|
-
parameter :source_directory, :
|
19
|
-
parameter :work_directory, :
|
19
|
+
parameter :configuration_name, required: true
|
20
|
+
parameter :source_directory, required: true
|
21
|
+
parameter :work_directory, required: true
|
20
22
|
|
21
23
|
parameter :backend_config
|
22
24
|
|
@@ -24,42 +26,51 @@ module RakeTerraform
|
|
24
26
|
parameter :var_file
|
25
27
|
parameter :state_file
|
26
28
|
|
27
|
-
parameter :debug, :
|
28
|
-
parameter :
|
29
|
-
parameter :
|
29
|
+
parameter :debug, default: false
|
30
|
+
parameter :input, default: false
|
31
|
+
parameter :no_color, default: false
|
32
|
+
parameter :no_backup, default: false
|
30
33
|
|
31
34
|
parameter :backup_file
|
32
35
|
|
33
|
-
parameter :ensure_task_name, :
|
36
|
+
parameter :ensure_task_name, default: :'terraform:ensure'
|
37
|
+
|
38
|
+
# rubocop:disable Metrics/BlockLength
|
34
39
|
|
35
40
|
action do |t|
|
36
41
|
Colored2.disable! if t.no_color
|
37
42
|
|
43
|
+
module_directory =
|
44
|
+
File.join(FileUtils.pwd, t.source_directory)
|
38
45
|
configuration_directory =
|
39
|
-
|
46
|
+
File.join(t.work_directory, t.source_directory)
|
40
47
|
|
41
|
-
puts
|
42
|
-
RubyTerraform.clean(
|
43
|
-
directory: configuration_directory)
|
48
|
+
Kernel.puts("Provisioning #{t.configuration_name}".cyan)
|
44
49
|
|
45
|
-
|
46
|
-
|
50
|
+
FileUtils.rm_rf(configuration_directory)
|
51
|
+
FileUtils.mkdir_p(configuration_directory)
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
53
|
+
RubyTerraform.init(
|
54
|
+
chdir: configuration_directory,
|
55
|
+
from_module: module_directory,
|
56
|
+
backend_config: t.backend_config,
|
57
|
+
no_color: t.no_color,
|
58
|
+
input: t.input
|
59
|
+
)
|
60
|
+
RubyTerraform.apply(
|
61
|
+
chdir: configuration_directory,
|
62
|
+
auto_approve: true,
|
63
|
+
input: t.input,
|
64
|
+
no_color: t.no_color,
|
65
|
+
no_backup: t.no_backup,
|
66
|
+
backup: t.backup_file,
|
67
|
+
state: t.state_file,
|
68
|
+
vars: t.vars,
|
69
|
+
var_file: t.var_file
|
70
|
+
)
|
62
71
|
end
|
72
|
+
|
73
|
+
# rubocop:enable Metrics/BlockLength
|
63
74
|
end
|
64
75
|
end
|
65
76
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake_factory'
|
2
4
|
require 'ruby_terraform'
|
3
5
|
require 'ostruct'
|
@@ -7,51 +9,49 @@ module RakeTerraform
|
|
7
9
|
module Tasks
|
8
10
|
class Validate < RakeFactory::Task
|
9
11
|
default_name :validate
|
10
|
-
default_prerequisites
|
12
|
+
default_prerequisites(RakeFactory::DynamicValue.new do |t|
|
11
13
|
[t.ensure_task_name]
|
12
|
-
|
13
|
-
default_description
|
14
|
+
end)
|
15
|
+
default_description(RakeFactory::DynamicValue.new do |t|
|
14
16
|
"Validate #{t.configuration_name} using terraform"
|
15
|
-
|
17
|
+
end)
|
16
18
|
|
17
|
-
parameter :configuration_name, :
|
18
|
-
parameter :source_directory, :
|
19
|
-
parameter :work_directory, :
|
19
|
+
parameter :configuration_name, required: true
|
20
|
+
parameter :source_directory, required: true
|
21
|
+
parameter :work_directory, required: true
|
20
22
|
|
21
23
|
parameter :backend_config
|
22
24
|
|
23
|
-
parameter :
|
24
|
-
parameter :
|
25
|
-
parameter :
|
26
|
-
|
27
|
-
parameter :debug, :default => false
|
28
|
-
parameter :no_color, :default => false
|
25
|
+
parameter :debug, default: false
|
26
|
+
parameter :input, default: false
|
27
|
+
parameter :no_color, default: false
|
29
28
|
|
30
|
-
parameter :ensure_task_name, :
|
29
|
+
parameter :ensure_task_name, default: :'terraform:ensure'
|
31
30
|
|
32
31
|
action do |t|
|
33
32
|
Colored2.disable! if t.no_color
|
34
33
|
|
34
|
+
module_directory =
|
35
|
+
File.join(FileUtils.pwd, t.source_directory)
|
35
36
|
configuration_directory =
|
36
|
-
|
37
|
-
|
38
|
-
puts
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
37
|
+
File.join(t.work_directory, t.source_directory)
|
38
|
+
|
39
|
+
Kernel.puts("Validating #{t.configuration_name}".cyan)
|
40
|
+
|
41
|
+
FileUtils.rm_rf(configuration_directory)
|
42
|
+
FileUtils.mkdir_p(configuration_directory)
|
43
|
+
|
44
|
+
RubyTerraform.init(
|
45
|
+
chdir: configuration_directory,
|
46
|
+
from_module: module_directory,
|
47
|
+
backend_config: t.backend_config,
|
48
|
+
no_color: t.no_color,
|
49
|
+
input: t.input
|
50
|
+
)
|
51
|
+
RubyTerraform.validate(
|
52
|
+
chdir: configuration_directory,
|
53
|
+
no_color: t.no_color
|
54
|
+
)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|