rake_terraform 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rake_terraform/tasks/all.rb +9 -0
- data/lib/rake_terraform/tasks/destroy.rb +22 -14
- data/lib/rake_terraform/tasks/provision.rb +22 -13
- data/lib/rake_terraform/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76c255ddec30794de2a3a25d1b4c2ff329bfc94f
|
4
|
+
data.tar.gz: 189430e50a791b3f0eec78a2f2d07604530244e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fbb79cc988c0a4108447859400e326f2154765721c7c06cd612e6a5e426777327496d961e2b4854e6b549023716e8ac8c94b66e7a3cd21fd5c94c9a06df8955
|
7
|
+
data.tar.gz: 0936551d175e815407edd77532a7097cd7a1d0969bf41b79b5e099410b6bca633a5a81c971b92d3011e2ac80adf197f50782b014070911c9c26f71e5d2ce2ca4
|
data/Gemfile.lock
CHANGED
@@ -15,13 +15,20 @@ module RakeTerraform
|
|
15
15
|
|
16
16
|
parameter :backup_file
|
17
17
|
|
18
|
+
parameter :argument_names
|
19
|
+
|
18
20
|
parameter :ensure_task, :default => :'terraform:ensure'
|
21
|
+
|
19
22
|
parameter :provision_task_name, :default => :provision
|
23
|
+
parameter :provision_argument_names
|
24
|
+
|
20
25
|
parameter :destroy_task_name, :default => :destroy
|
26
|
+
parameter :destroy_argument_names
|
21
27
|
|
22
28
|
def define
|
23
29
|
Provision.new do |t|
|
24
30
|
t.name = provision_task_name
|
31
|
+
t.argument_names = provision_argument_names || argument_names || []
|
25
32
|
|
26
33
|
t.configuration_name = configuration_name
|
27
34
|
t.configuration_directory = configuration_directory
|
@@ -41,6 +48,8 @@ module RakeTerraform
|
|
41
48
|
end
|
42
49
|
Destroy.new do |t|
|
43
50
|
t.name = destroy_task_name
|
51
|
+
t.argument_names = destroy_argument_names || argument_names || []
|
52
|
+
|
44
53
|
|
45
54
|
t.configuration_name = configuration_name
|
46
55
|
t.configuration_directory = configuration_directory
|
@@ -5,6 +5,7 @@ module RakeTerraform
|
|
5
5
|
module Tasks
|
6
6
|
class Destroy < TaskLib
|
7
7
|
parameter :name, :default => :destroy
|
8
|
+
parameter :argument_names, :default => []
|
8
9
|
|
9
10
|
parameter :configuration_name, :required => true
|
10
11
|
parameter :configuration_directory, :required => true
|
@@ -33,18 +34,25 @@ module RakeTerraform
|
|
33
34
|
end
|
34
35
|
|
35
36
|
desc "Destroy #{configuration_name} using terraform"
|
36
|
-
task name => [ensure_task] do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
task name, argument_names => [ensure_task] do |_, args|
|
38
|
+
params = OpenStruct.new({
|
39
|
+
configuration_name: configuration_name,
|
40
|
+
configuration_directory: configuration_directory,
|
41
|
+
backend: backend,
|
42
|
+
backend_config: backend_config,
|
43
|
+
state_file: state_file,
|
44
|
+
no_color: no_color,
|
45
|
+
no_backup: no_backup,
|
46
|
+
backup_file: backup_file
|
47
|
+
})
|
48
|
+
|
49
|
+
derived_vars = vars.respond_to?(:call) ?
|
50
|
+
vars.call(*[args, params].slice(0, vars.arity)) :
|
51
|
+
vars
|
52
|
+
derived_backend_config = backend_config.respond_to?(:call) ?
|
53
|
+
backend_config.call(
|
54
|
+
*[args, params].slice(0, backend_config.arity)) :
|
55
|
+
backend_config
|
48
56
|
|
49
57
|
puts "Destroying #{configuration_name}"
|
50
58
|
|
@@ -56,7 +64,7 @@ module RakeTerraform
|
|
56
64
|
RubyTerraform.remote_config(
|
57
65
|
no_color: no_color,
|
58
66
|
backend: backend,
|
59
|
-
backend_config:
|
67
|
+
backend_config: derived_backend_config)
|
60
68
|
end
|
61
69
|
RubyTerraform.destroy(
|
62
70
|
force: true,
|
@@ -65,7 +73,7 @@ module RakeTerraform
|
|
65
73
|
backup: backup_file,
|
66
74
|
directory: configuration_directory,
|
67
75
|
state: state_file,
|
68
|
-
vars:
|
76
|
+
vars: derived_vars)
|
69
77
|
end
|
70
78
|
end
|
71
79
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'ruby_terraform'
|
2
|
+
require 'ostruct'
|
2
3
|
require_relative '../tasklib'
|
3
4
|
|
4
5
|
module RakeTerraform
|
5
6
|
module Tasks
|
6
7
|
class Provision < TaskLib
|
7
8
|
parameter :name, :default => :provision
|
9
|
+
parameter :argument_names, :default => []
|
8
10
|
|
9
11
|
parameter :configuration_name, :required => true
|
10
12
|
parameter :configuration_directory, :required => true
|
@@ -33,18 +35,25 @@ module RakeTerraform
|
|
33
35
|
end
|
34
36
|
|
35
37
|
desc "Provision #{configuration_name} using terraform"
|
36
|
-
task name => [ensure_task] do
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
task name, argument_names => [ensure_task] do |_, args|
|
39
|
+
params = OpenStruct.new({
|
40
|
+
configuration_name: configuration_name,
|
41
|
+
configuration_directory: configuration_directory,
|
42
|
+
backend: backend,
|
43
|
+
backend_config: backend_config,
|
44
|
+
state_file: state_file,
|
45
|
+
no_color: no_color,
|
46
|
+
no_backup: no_backup,
|
47
|
+
backup_file: backup_file
|
48
|
+
})
|
49
|
+
|
50
|
+
derived_vars = vars.respond_to?(:call) ?
|
51
|
+
vars.call(*[args, params].slice(0, vars.arity)) :
|
47
52
|
vars
|
53
|
+
derived_backend_config = backend_config.respond_to?(:call) ?
|
54
|
+
backend_config.call(
|
55
|
+
*[args, params].slice(0, backend_config.arity)) :
|
56
|
+
backend_config
|
48
57
|
|
49
58
|
puts "Provisioning #{configuration_name}"
|
50
59
|
|
@@ -56,7 +65,7 @@ module RakeTerraform
|
|
56
65
|
RubyTerraform.remote_config(
|
57
66
|
no_color: no_color,
|
58
67
|
backend: backend,
|
59
|
-
backend_config:
|
68
|
+
backend_config: derived_backend_config)
|
60
69
|
end
|
61
70
|
RubyTerraform.apply(
|
62
71
|
no_color: no_color,
|
@@ -64,7 +73,7 @@ module RakeTerraform
|
|
64
73
|
backup: backup_file,
|
65
74
|
directory: configuration_directory,
|
66
75
|
state: state_file,
|
67
|
-
vars:
|
76
|
+
vars: derived_vars)
|
68
77
|
end
|
69
78
|
end
|
70
79
|
end
|