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.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'tasks/validate'
2
4
  require_relative 'tasks/plan'
3
5
  require_relative 'tasks/provision'
@@ -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 RakeFactory::DynamicValue.new { |t|
12
+ default_prerequisites(RakeFactory::DynamicValue.new do |t|
11
13
  [t.ensure_task_name]
12
- }
13
- default_description RakeFactory::DynamicValue.new { |t|
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, :required => true
18
- parameter :source_directory, :required => true
19
- parameter :work_directory, :required => true
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, :default => false
28
- parameter :no_color, :default => false
29
- parameter :no_backup, :default => false
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, :default => :'terraform:ensure'
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
- File.join(t.work_directory, t.source_directory)
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
- mkdir_p File.dirname(configuration_directory)
46
- cp_r t.source_directory, configuration_directory
50
+ FileUtils.rm_rf(configuration_directory)
51
+ FileUtils.mkdir_p(configuration_directory)
47
52
 
48
- Dir.chdir(configuration_directory) do
49
- RubyTerraform.init(
50
- backend_config: t.backend_config,
51
- no_color: t.no_color)
52
- RubyTerraform.destroy(
53
- force: true,
54
- no_color: t.no_color,
55
- no_backup: t.no_backup,
56
- backup: t.backup_file,
57
- state: t.state_file,
58
- vars: t.vars,
59
- var_file: t.var_file)
60
- end
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 RakeFactory::DynamicValue.new { |t|
12
+ default_prerequisites(RakeFactory::DynamicValue.new do |t|
11
13
  [t.ensure_task_name]
12
- }
13
- default_description RakeFactory::DynamicValue.new { |t|
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, :required => true
18
- parameter :source_directory, :required => true
19
- parameter :work_directory, :required => true
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, :default => false
26
- parameter :no_color, :default => false
27
- parameter :no_print_output, :default => false
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, :default => :'terraform:ensure'
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
- File.join(t.work_directory, t.source_directory)
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
- mkdir_p File.dirname(configuration_directory)
42
- cp_r t.source_directory, configuration_directory
42
+ Kernel.puts("Output of #{t.configuration_name}".cyan)
43
43
 
44
- Dir.chdir(configuration_directory) do
45
- RubyTerraform.init(
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
- output = RubyTerraform.output(
50
- no_color: t.no_color,
51
- state: t.state_file)
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
- puts output unless t.no_print_output
60
+ Kernel.puts(output) unless t.no_print_output
54
61
 
55
- output
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 RakeFactory::DynamicValue.new { |t|
12
+ default_prerequisites(RakeFactory::DynamicValue.new do |t|
11
13
  [t.ensure_task_name]
12
- }
13
- default_description RakeFactory::DynamicValue.new { |t|
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, :required => true
18
- parameter :source_directory, :required => true
19
- parameter :work_directory, :required => true
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, :default => false
28
- parameter :no_color, :default => false
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, :default => false
34
+ parameter :destroy, default: false
32
35
 
33
- parameter :ensure_task_name, :default => :'terraform:ensure'
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
- File.join(t.work_directory, t.source_directory)
40
-
41
- puts "Planning #{configuration_name}".cyan
42
- RubyTerraform.clean(
43
- directory: configuration_directory)
44
-
45
- mkdir_p File.dirname(configuration_directory)
46
- cp_r t.source_directory, configuration_directory
47
-
48
- Dir.chdir(configuration_directory) do
49
- RubyTerraform.init(
50
- backend_config: t.backend_config,
51
- no_color: t.no_color)
52
- RubyTerraform.plan(
53
- no_color: t.no_color,
54
- destroy: t.destroy,
55
- state: t.state_file,
56
- plan: t.plan_file,
57
- vars: t.vars,
58
- var_file: t.var_file)
59
- end
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 RakeFactory::DynamicValue.new { |t|
12
+ default_prerequisites(RakeFactory::DynamicValue.new do |t|
11
13
  [t.ensure_task_name]
12
- }
13
- default_description RakeFactory::DynamicValue.new { |t|
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, :required => true
18
- parameter :source_directory, :required => true
19
- parameter :work_directory, :required => true
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, :default => false
28
- parameter :no_color, :default => false
29
- parameter :no_backup, :default => false
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, :default => :'terraform:ensure'
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
- File.join(t.work_directory, t.source_directory)
46
+ File.join(t.work_directory, t.source_directory)
40
47
 
41
- puts "Provisioning #{t.configuration_name}".cyan
42
- RubyTerraform.clean(
43
- directory: configuration_directory)
48
+ Kernel.puts("Provisioning #{t.configuration_name}".cyan)
44
49
 
45
- mkdir_p File.dirname(configuration_directory)
46
- cp_r t.source_directory, configuration_directory
50
+ FileUtils.rm_rf(configuration_directory)
51
+ FileUtils.mkdir_p(configuration_directory)
47
52
 
48
-
49
- Dir.chdir(configuration_directory) do
50
- RubyTerraform.init(
51
- backend_config: t.backend_config,
52
- no_color: t.no_color)
53
- RubyTerraform.apply(
54
- auto_approve: true,
55
- no_color: t.no_color,
56
- no_backup: t.no_backup,
57
- backup: t.backup_file,
58
- state: t.state_file,
59
- vars: t.vars,
60
- var_file: t.var_file)
61
- end
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 RakeFactory::DynamicValue.new { |t|
12
+ default_prerequisites(RakeFactory::DynamicValue.new do |t|
11
13
  [t.ensure_task_name]
12
- }
13
- default_description RakeFactory::DynamicValue.new { |t|
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, :required => true
18
- parameter :source_directory, :required => true
19
- parameter :work_directory, :required => true
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 :vars, default: {}
24
- parameter :var_file
25
- parameter :state_file
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, :default => :'terraform:ensure'
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
- File.join(t.work_directory, t.source_directory)
37
-
38
- puts "Validating #{t.configuration_name}".cyan
39
- RubyTerraform.clean(
40
- directory: configuration_directory)
41
-
42
- mkdir_p File.dirname(configuration_directory)
43
- cp_r t.source_directory, configuration_directory
44
-
45
- Dir.chdir(configuration_directory) do
46
- RubyTerraform.init(
47
- backend_config: t.backend_config,
48
- no_color: t.no_color)
49
- RubyTerraform.validate(
50
- no_color: t.no_color,
51
- state: t.state_file,
52
- vars: t.vars,
53
- var_file: t.var_file)
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