rake_terraform 0.17.0 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da4531cbfecb1e320ceb6869d355684cfe101acc
4
- data.tar.gz: ed0762087ae68f52a4ce71baffadecb5b85cb44f
3
+ metadata.gz: ff110da056976fa317618cc3d0ca54cada2d333b
4
+ data.tar.gz: 121f1363babcf40c02487f50ea2d9271893787d8
5
5
  SHA512:
6
- metadata.gz: 13a23f739bb1d148b44d96effeb364488d25a5e84d5856c3c91e14aa46fff4f85bd74012ce1a62384aaa8a90038c22542aadc7dd41e7a5e8c8163bb5cc796d16
7
- data.tar.gz: 003ef8eaa82ac25239eb9dce020fd3b387a824ed33b5b122800dfca207324768ed12ca47b685194a2053ead4de566d76a08147ab3ea8f8c9b758b424210f6053
6
+ metadata.gz: 7bfb48fce0f0c36252e0033a4a0a804e62aa25dd440c2758ddad7b7cef91b06912ef6432e06bdcd99c237668fd1ce171047ab9f2686d3c8c8a57116f8964e549
7
+ data.tar.gz: 26f45a033eaa9a8e4c80695c196e674b6eabb5a38733e790739f27fe647c5cbd80afdc34123dbe86c9a541b4a13b75aa455a2c0ef2f87bc4cfb0186ddc12af6a
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_terraform (0.17.0)
4
+ rake_terraform (0.18.0)
5
+ colorize
5
6
  rake_dependencies (~> 0.15)
6
7
  ruby-terraform (~> 0.11)
7
8
 
@@ -14,6 +15,7 @@ GEM
14
15
  minitest (~> 5.1)
15
16
  thread_safe (~> 0.3, >= 0.3.4)
16
17
  tzinfo (~> 1.1)
18
+ colorize (0.8.1)
17
19
  concurrent-ruby (1.0.5)
18
20
  diff-lcs (1.3)
19
21
  fakefs (0.10.2)
@@ -46,7 +48,7 @@ GEM
46
48
  diff-lcs (>= 1.2.0, < 2.0)
47
49
  rspec-support (~> 3.5.0)
48
50
  rspec-support (3.5.0)
49
- ruby-terraform (0.11.2)
51
+ ruby-terraform (0.13.0)
50
52
  lino (~> 1.1)
51
53
  rubyzip (1.2.1)
52
54
  thread_safe (0.3.5)
@@ -66,4 +68,4 @@ DEPENDENCIES
66
68
  rspec (~> 3.0)
67
69
 
68
70
  BUNDLED WITH
69
- 1.16.1
71
+ 1.16.3
@@ -2,4 +2,5 @@ require_relative 'tasks/validate'
2
2
  require_relative 'tasks/plan'
3
3
  require_relative 'tasks/provision'
4
4
  require_relative 'tasks/destroy'
5
+ require_relative 'tasks/output'
5
6
  require_relative 'tasks/all'
@@ -10,12 +10,18 @@ module RakeTerraform
10
10
  parameter :vars
11
11
  parameter :state_file
12
12
 
13
+ # Emit additional information for debugging purposes
14
+ # Useful to check this value in lambdas passed to backend_config, vars and state_file
15
+ parameter :debug, :default => false
16
+
13
17
  parameter :no_color, :default => false
14
18
  parameter :no_backup, :default => false
19
+ parameter :no_print_output, :default => false
15
20
 
16
21
  parameter :backup_file
17
22
  parameter :plan_file
18
23
 
24
+ # Allows specifying rake task arguments, for example bucket:provision[my_deployment_id]
19
25
  parameter :argument_names
20
26
 
21
27
  parameter :ensure_task, :default => :'terraform:ensure'
@@ -32,6 +38,9 @@ module RakeTerraform
32
38
  parameter :destroy_task_name, :default => :destroy
33
39
  parameter :destroy_argument_names
34
40
 
41
+ parameter :output_task_name, :default => :output
42
+ parameter :output_argument_names
43
+
35
44
  def define
36
45
  Validate.new do |t|
37
46
  t.name = validate_task_name
@@ -46,6 +55,7 @@ module RakeTerraform
46
55
  t.vars = vars
47
56
  t.state_file = state_file
48
57
 
58
+ t.debug = debug
49
59
  t.no_color = no_color
50
60
 
51
61
  t.ensure_task = ensure_task
@@ -63,6 +73,7 @@ module RakeTerraform
63
73
  t.vars = vars
64
74
  t.state_file = state_file
65
75
 
76
+ t.debug = debug
66
77
  t.no_color = no_color
67
78
 
68
79
  t.plan_file = plan_file
@@ -82,6 +93,7 @@ module RakeTerraform
82
93
  t.vars = vars
83
94
  t.state_file = state_file
84
95
 
96
+ t.debug = debug
85
97
  t.no_color = no_color
86
98
  t.no_backup = no_backup
87
99
 
@@ -93,7 +105,6 @@ module RakeTerraform
93
105
  t.name = destroy_task_name
94
106
  t.argument_names = destroy_argument_names || argument_names || []
95
107
 
96
-
97
108
  t.configuration_name = configuration_name
98
109
  t.source_directory = source_directory
99
110
  t.work_directory = work_directory
@@ -103,11 +114,30 @@ module RakeTerraform
103
114
  t.vars = vars
104
115
  t.state_file = state_file
105
116
 
117
+ t.debug = debug
106
118
  t.no_color = no_color
107
119
  t.no_backup = no_backup
108
120
 
109
121
  t.backup_file = backup_file
110
122
 
123
+ t.ensure_task = ensure_task
124
+ end
125
+ Output.new do |t|
126
+ t.name = output_task_name
127
+ t.argument_names = output_argument_names || argument_names || []
128
+
129
+ t.configuration_name = configuration_name
130
+ t.source_directory = source_directory
131
+ t.work_directory = work_directory
132
+
133
+ t.backend_config = backend_config
134
+
135
+ t.state_file = state_file
136
+
137
+ t.debug = debug
138
+ t.no_color = no_color
139
+ t.no_print_output = no_print_output
140
+
111
141
  t.ensure_task = ensure_task
112
142
  end
113
143
  end
@@ -1,4 +1,6 @@
1
1
  require 'ruby_terraform'
2
+ require 'ostruct'
3
+ require 'colorize'
2
4
  require_relative '../tasklib'
3
5
 
4
6
  module RakeTerraform
@@ -16,6 +18,7 @@ module RakeTerraform
16
18
  parameter :vars, default: {}
17
19
  parameter :state_file
18
20
 
21
+ parameter :debug, :default => false
19
22
  parameter :no_color, :default => false
20
23
  parameter :no_backup, :default => false
21
24
 
@@ -30,6 +33,10 @@ module RakeTerraform
30
33
  def define
31
34
  desc "Destroy #{configuration_name} using terraform"
32
35
  task name, argument_names => [ensure_task] do |_, args|
36
+ String.disable_colorization = no_color
37
+
38
+ puts "Destroying #{configuration_name}".colorize(:cyan)
39
+
33
40
  configuration_directory = File.join(work_directory, source_directory)
34
41
 
35
42
  params = OpenStruct.new({
@@ -39,25 +46,24 @@ module RakeTerraform
39
46
  configuration_directory: configuration_directory,
40
47
  backend_config: backend_config,
41
48
  state_file: state_file,
49
+ debug: debug,
42
50
  no_color: no_color,
43
51
  no_backup: no_backup,
44
- backup_file: backup_file
52
+ backup_file: backup_file,
45
53
  })
46
54
 
47
- derived_vars = vars.respond_to?(:call) ?
48
- vars.call(*[args, params].slice(0, vars.arity)) :
49
- vars
50
55
  derived_backend_config = backend_config.respond_to?(:call) ?
51
56
  backend_config.call(
52
57
  *[args, params].slice(0, backend_config.arity)) :
53
58
  backend_config
59
+ derived_vars = vars.respond_to?(:call) ?
60
+ vars.call(*[args, params].slice(0, vars.arity)) :
61
+ vars
54
62
  derived_state_file = state_file.respond_to?(:call) ?
55
63
  state_file.call(
56
64
  *[args, params].slice(0, state_file.arity)) :
57
65
  state_file
58
66
 
59
- puts "Destroying #{configuration_name}"
60
-
61
67
  RubyTerraform.clean(
62
68
  directory: configuration_directory)
63
69
 
@@ -0,0 +1,83 @@
1
+ require 'ruby_terraform'
2
+ require 'ostruct'
3
+ require 'colorize'
4
+ require_relative '../tasklib'
5
+
6
+ module RakeTerraform
7
+ module Tasks
8
+ class Output < TaskLib
9
+ parameter :name, :default => :output
10
+ parameter :argument_names, :default => []
11
+
12
+ parameter :configuration_name, :required => true
13
+ parameter :source_directory, :required => true
14
+ parameter :work_directory, :required => true
15
+
16
+ parameter :backend_config
17
+
18
+ parameter :state_file
19
+
20
+ parameter :debug, :default => false
21
+ parameter :no_color, :default => false
22
+ parameter :no_print_output, :default => false
23
+
24
+ parameter :ensure_task, :default => :'terraform:ensure'
25
+
26
+ def process_arguments(args)
27
+ self.name = args[0] if args[0]
28
+ end
29
+
30
+ def define
31
+ desc "Output #{configuration_name} using terraform"
32
+ task name, argument_names => [ensure_task] do |_, args|
33
+ String.disable_colorization = no_color
34
+
35
+ puts "Output of #{configuration_name}".colorize(:cyan)
36
+
37
+ configuration_directory = File.join(work_directory, source_directory)
38
+
39
+ params = OpenStruct.new({
40
+ configuration_name: configuration_name,
41
+ source_directory: source_directory,
42
+ work_directory: work_directory,
43
+ configuration_directory: configuration_directory,
44
+ backend_config: backend_config,
45
+ state_file: state_file,
46
+ debug: debug,
47
+ no_color: no_color,
48
+ no_print_output: no_print_output,
49
+ })
50
+
51
+ derived_backend_config = backend_config.respond_to?(:call) ?
52
+ backend_config.call(
53
+ *[args, params].slice(0, backend_config.arity)) :
54
+ backend_config
55
+ derived_state_file = state_file.respond_to?(:call) ?
56
+ state_file.call(
57
+ *[args, params].slice(0, state_file.arity)) :
58
+ state_file
59
+
60
+ RubyTerraform.clean(
61
+ directory: configuration_directory)
62
+
63
+ mkdir_p File.dirname(configuration_directory)
64
+ cp_r source_directory, configuration_directory
65
+
66
+ Dir.chdir(configuration_directory) do
67
+ RubyTerraform.init(
68
+ backend_config: derived_backend_config,
69
+ no_color: no_color)
70
+
71
+ output = RubyTerraform.output(
72
+ no_color: no_color,
73
+ state: derived_state_file)
74
+
75
+ puts output unless no_print_output
76
+
77
+ output
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
@@ -1,5 +1,6 @@
1
1
  require 'ruby_terraform'
2
2
  require 'ostruct'
3
+ require 'colorize'
3
4
  require_relative '../tasklib'
4
5
 
5
6
  module RakeTerraform
@@ -17,6 +18,7 @@ module RakeTerraform
17
18
  parameter :vars, default: {}
18
19
  parameter :state_file
19
20
 
21
+ parameter :debug, :default => false
20
22
  parameter :no_color, :default => false
21
23
 
22
24
  parameter :plan_file
@@ -31,6 +33,10 @@ module RakeTerraform
31
33
  def define
32
34
  desc "Plan #{configuration_name} using terraform"
33
35
  task name, argument_names => [ensure_task] do |_, args|
36
+ String.disable_colorization = no_color
37
+
38
+ puts "Planning #{configuration_name}".colorize(:cyan)
39
+
34
40
  configuration_directory = File.join(work_directory, source_directory)
35
41
 
36
42
  params = OpenStruct.new({
@@ -40,23 +46,22 @@ module RakeTerraform
40
46
  configuration_directory: configuration_directory,
41
47
  backend_config: backend_config,
42
48
  state_file: state_file,
49
+ debug: debug,
43
50
  no_color: no_color,
44
51
  })
45
52
 
46
- derived_vars = vars.respond_to?(:call) ?
47
- vars.call(*[args, params].slice(0, vars.arity)) :
48
- vars
49
53
  derived_backend_config = backend_config.respond_to?(:call) ?
50
54
  backend_config.call(
51
55
  *[args, params].slice(0, backend_config.arity)) :
52
56
  backend_config
57
+ derived_vars = vars.respond_to?(:call) ?
58
+ vars.call(*[args, params].slice(0, vars.arity)) :
59
+ vars
53
60
  derived_state_file = state_file.respond_to?(:call) ?
54
61
  state_file.call(
55
62
  *[args, params].slice(0, state_file.arity)) :
56
63
  state_file
57
64
 
58
- puts "Planning #{configuration_name}"
59
-
60
65
  RubyTerraform.clean(
61
66
  directory: configuration_directory)
62
67
 
@@ -1,5 +1,6 @@
1
1
  require 'ruby_terraform'
2
2
  require 'ostruct'
3
+ require 'colorize'
3
4
  require_relative '../tasklib'
4
5
 
5
6
  module RakeTerraform
@@ -17,6 +18,7 @@ module RakeTerraform
17
18
  parameter :vars, default: {}
18
19
  parameter :state_file
19
20
 
21
+ parameter :debug, :default => false
20
22
  parameter :no_color, :default => false
21
23
  parameter :no_backup, :default => false
22
24
 
@@ -31,6 +33,10 @@ module RakeTerraform
31
33
  def define
32
34
  desc "Provision #{configuration_name} using terraform"
33
35
  task name, argument_names => [ensure_task] do |_, args|
36
+ String.disable_colorization = no_color
37
+
38
+ puts "Provisioning #{configuration_name}".colorize(:cyan)
39
+
34
40
  configuration_directory = File.join(work_directory, source_directory)
35
41
 
36
42
  params = OpenStruct.new({
@@ -40,25 +46,24 @@ module RakeTerraform
40
46
  configuration_directory: configuration_directory,
41
47
  backend_config: backend_config,
42
48
  state_file: state_file,
49
+ debug: debug,
43
50
  no_color: no_color,
44
51
  no_backup: no_backup,
45
- backup_file: backup_file
52
+ backup_file: backup_file,
46
53
  })
47
54
 
48
- derived_vars = vars.respond_to?(:call) ?
49
- vars.call(*[args, params].slice(0, vars.arity)) :
50
- vars
51
55
  derived_backend_config = backend_config.respond_to?(:call) ?
52
56
  backend_config.call(
53
57
  *[args, params].slice(0, backend_config.arity)) :
54
58
  backend_config
59
+ derived_vars = vars.respond_to?(:call) ?
60
+ vars.call(*[args, params].slice(0, vars.arity)) :
61
+ vars
55
62
  derived_state_file = state_file.respond_to?(:call) ?
56
63
  state_file.call(
57
64
  *[args, params].slice(0, state_file.arity)) :
58
65
  state_file
59
66
 
60
- puts "Provisioning #{configuration_name}"
61
-
62
67
  RubyTerraform.clean(
63
68
  directory: configuration_directory)
64
69
 
@@ -1,5 +1,6 @@
1
1
  require 'ruby_terraform'
2
2
  require 'ostruct'
3
+ require 'colorize'
3
4
  require_relative '../tasklib'
4
5
 
5
6
  module RakeTerraform
@@ -17,6 +18,7 @@ module RakeTerraform
17
18
  parameter :vars, default: {}
18
19
  parameter :state_file
19
20
 
21
+ parameter :debug, :default => false
20
22
  parameter :no_color, :default => false
21
23
 
22
24
  parameter :ensure_task, :default => :'terraform:ensure'
@@ -28,6 +30,10 @@ module RakeTerraform
28
30
  def define
29
31
  desc "Validate #{configuration_name} using terraform"
30
32
  task name, argument_names => [ensure_task] do |_, args|
33
+ String.disable_colorization = no_color
34
+
35
+ puts "Validating #{configuration_name}".colorize(:cyan)
36
+
31
37
  configuration_directory = File.join(work_directory, source_directory)
32
38
 
33
39
  params = OpenStruct.new({
@@ -37,9 +43,14 @@ module RakeTerraform
37
43
  configuration_directory: configuration_directory,
38
44
  backend_config: backend_config,
39
45
  state_file: state_file,
46
+ debug: debug,
40
47
  no_color: no_color,
41
48
  })
42
49
 
50
+ derived_backend_config = backend_config.respond_to?(:call) ?
51
+ backend_config.call(
52
+ *[args, params].slice(0, backend_config.arity)) :
53
+ backend_config
43
54
  derived_vars = vars.respond_to?(:call) ?
44
55
  vars.call(*[args, params].slice(0, vars.arity)) :
45
56
  vars
@@ -48,8 +59,6 @@ module RakeTerraform
48
59
  *[args, params].slice(0, state_file.arity)) :
49
60
  state_file
50
61
 
51
- puts "Validating #{configuration_name}"
52
-
53
62
  RubyTerraform.clean(
54
63
  directory: configuration_directory)
55
64
 
@@ -57,6 +66,9 @@ module RakeTerraform
57
66
  cp_r source_directory, configuration_directory
58
67
 
59
68
  Dir.chdir(configuration_directory) do
69
+ RubyTerraform.init(
70
+ backend_config: derived_backend_config,
71
+ no_color: no_color)
60
72
  RubyTerraform.validate(
61
73
  no_color: no_color,
62
74
  state: derived_state_file,
@@ -1,3 +1,3 @@
1
1
  module RakeTerraform
2
- VERSION = "0.17.0"
2
+ VERSION = "0.18.0"
3
3
  end
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency 'rake_dependencies', '~> 0.15'
25
25
  spec.add_dependency 'ruby-terraform', '~> 0.11'
26
+ spec.add_dependency 'colorize'
26
27
 
27
28
  spec.add_development_dependency 'bundler', '~> 1.14'
28
29
  spec.add_development_dependency 'rake', '~> 11.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-01 00:00:00.000000000 Z
11
+ date: 2018-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake_dependencies
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -148,6 +162,7 @@ files:
148
162
  - lib/rake_terraform/tasks.rb
149
163
  - lib/rake_terraform/tasks/all.rb
150
164
  - lib/rake_terraform/tasks/destroy.rb
165
+ - lib/rake_terraform/tasks/output.rb
151
166
  - lib/rake_terraform/tasks/plan.rb
152
167
  - lib/rake_terraform/tasks/provision.rb
153
168
  - lib/rake_terraform/tasks/validate.rb