jackal-cfn 0.1.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/jackal-cfn/event.rb +3 -4
- data/lib/jackal-cfn/formatter/chef_cleanup.rb +48 -0
- data/lib/jackal-cfn/resource/ami_manager.rb +3 -3
- data/lib/jackal-cfn/resource/hash_extractor.rb +4 -4
- data/lib/jackal-cfn/resource.rb +24 -12
- data/lib/jackal-cfn/utils.rb +1 -1
- data/lib/jackal-cfn/version.rb +1 -1
- data/lib/jackal-cfn.rb +1 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a04e966cfce6d4c347d5ff5d227a53fe7a71245
|
4
|
+
data.tar.gz: bf1d3a7f3b402780bd0d4fbe1ff0a86b7f2f35d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 820460a2f614387d2237923f7bbafa28854ef7e325f461a5ff167de3a70a048c91733d859571ecb9865f462d535570cefdb048798668db935d74f3aa2e47679d
|
7
|
+
data.tar.gz: 1ead2a327e6c07abf88038b234721ab5f4eaba20bd07531fd7891ec2c4443bf14bec4319616c925ec684ba01e87126029a853bb92cf9b1fcbdfc28693a6d95e9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# v0.2.0
|
2
|
+
* Move builtin resources under single namespace
|
3
|
+
* Add custom failure wrap to resource to provide auto failure notification
|
4
|
+
* Fix endpoint url response in extractor resource
|
5
|
+
|
1
6
|
# v0.1.6
|
2
7
|
* Isolate event and resource to simple handle format and forward
|
3
8
|
* Move builtin custom resources within new module `CfnTools`
|
data/lib/jackal-cfn/event.rb
CHANGED
@@ -109,12 +109,11 @@ module Jackal
|
|
109
109
|
:cfn_event => data_payload
|
110
110
|
)
|
111
111
|
if(config[:reprocess])
|
112
|
-
|
113
|
-
|
114
|
-
Carnivore::Supervisor.supervisor[my_input].transmit(payload)
|
112
|
+
debug "Reprocessing payload through current source (#{destination(:input)})"
|
113
|
+
Carnivore::Supervisor.supervisor[destination(:input)].transmit(payload)
|
115
114
|
message.confirm!
|
116
115
|
else
|
117
|
-
|
116
|
+
job_completed(:jackal_cfn, payload, message)
|
118
117
|
end
|
119
118
|
end
|
120
119
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'jackal'
|
2
|
+
|
3
|
+
module Jackal
|
4
|
+
module Cfn
|
5
|
+
module Formatter
|
6
|
+
|
7
|
+
# Add cleanup information for chef instances
|
8
|
+
class ChefCleanup < Jackal::Formatter
|
9
|
+
|
10
|
+
# Source service
|
11
|
+
SOURCE = :cfn
|
12
|
+
# Destination service
|
13
|
+
DESTINATION = :commander
|
14
|
+
|
15
|
+
# Format payload to enable knife scrubbing via
|
16
|
+
# commander
|
17
|
+
#
|
18
|
+
# @param payload [Smash]
|
19
|
+
def format(payload)
|
20
|
+
event = payload.get(:data, :cfn_event)
|
21
|
+
if(valid_event?(event))
|
22
|
+
stack_id = payload.get(:data, :cfn_event, :stack_id)
|
23
|
+
if(stack_id)
|
24
|
+
debug "Found stack ID information. Setting commander scrub commands. (Stack ID: #{stack_id})"
|
25
|
+
actions = payload.fetch(:data, :commander, :actions, [])
|
26
|
+
actions << Smash.new(
|
27
|
+
:name => app_config.fetch(:cfn, :formatter, :chef_cleanup_command, :chef_cleanup),
|
28
|
+
:arguments => stack_id
|
29
|
+
)
|
30
|
+
payload.set(:data, :commander, :actions, actions)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Determine validity of event
|
36
|
+
#
|
37
|
+
# @param event [Smash]
|
38
|
+
# @return [Truthy, Falsey]
|
39
|
+
def valid_event?(event)
|
40
|
+
event[:resource_status] == 'DELETE_COMPLETE' &&
|
41
|
+
event[:resource_type] == app_config.fetch(:cfn, :formatter, :stack_resource_type, 'AWS::CloudFormation::Stack')
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'jackal-cfn'
|
2
2
|
|
3
3
|
module Jackal
|
4
|
-
module
|
4
|
+
module Cfn
|
5
5
|
# Manage AMI Resources
|
6
6
|
#
|
7
7
|
# Expected resource:
|
@@ -37,7 +37,7 @@ module Jackal
|
|
37
37
|
#
|
38
38
|
# @param message [Carnivore::Message]
|
39
39
|
def execute(message)
|
40
|
-
failure_wrap do |payload|
|
40
|
+
failure_wrap(message) do |payload|
|
41
41
|
cfn_resource = rekey_hash(payload.get(:data, :cfn_resource))
|
42
42
|
properties = rekey_hash(cfn_resource[:resource_properties])
|
43
43
|
parameters = rekey_hash(properties[:parameters])
|
@@ -54,7 +54,7 @@ module Jackal
|
|
54
54
|
response['Reason'] = 'Unknown request type received'
|
55
55
|
end
|
56
56
|
respond_to_stack(cfn_response, cfn_resource[:response_url])
|
57
|
-
|
57
|
+
job_completed(:jackal_cfn, payload, message)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'jackal-cfn'
|
2
2
|
|
3
3
|
module Jackal
|
4
|
-
module
|
4
|
+
module Cfn
|
5
5
|
# Extract value from hash
|
6
6
|
#
|
7
7
|
# Expected resource:
|
@@ -20,7 +20,7 @@ module Jackal
|
|
20
20
|
#
|
21
21
|
# @param message [Carnivore::Message]
|
22
22
|
def execute(message)
|
23
|
-
failure_wrap do |payload|
|
23
|
+
failure_wrap(message) do |payload|
|
24
24
|
cfn_resource = rekey_hash(payload.get(:data, :cfn_resource))
|
25
25
|
properties = rekey_hash(cfn_resource[:resource_properties])
|
26
26
|
parameters = rekey_hash(properties[:parameters])
|
@@ -36,8 +36,8 @@ module Jackal
|
|
36
36
|
return_value = MultiJson.dump(return_value)
|
37
37
|
end
|
38
38
|
cfn_response['Data']['Payload'] = return_value
|
39
|
-
respond_to_stack(cfn_response,
|
40
|
-
|
39
|
+
respond_to_stack(cfn_response, cfn_resource[:response_url])
|
40
|
+
job_completed(:jackal_cfn, payload, message)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
data/lib/jackal-cfn/resource.rb
CHANGED
@@ -87,9 +87,7 @@ module Jackal
|
|
87
87
|
'StackId' => cfn_resource[:stack_id],
|
88
88
|
'RequestId' => cfn_resource[:request_id],
|
89
89
|
'Status' => 'SUCCESS',
|
90
|
-
'Data' => Smash.new
|
91
|
-
'Reason' => 'None'
|
92
|
-
)
|
90
|
+
'Data' => Smash.new
|
93
91
|
)
|
94
92
|
end
|
95
93
|
|
@@ -133,12 +131,8 @@ module Jackal
|
|
133
131
|
payload = super
|
134
132
|
if(self.class == Jackal::Cfn::Resource)
|
135
133
|
begin
|
136
|
-
if(payload['Body'])
|
137
|
-
payload =
|
138
|
-
MultiJson.load(
|
139
|
-
payload.fetch('Body', 'Message', payload)
|
140
|
-
)
|
141
|
-
)
|
134
|
+
if(payload['Body'] && payload['Body']['Message'])
|
135
|
+
payload = MultiJson.load(payload.get('Body', 'Message')).to_smash
|
142
136
|
payload = transform_parameters(payload)
|
143
137
|
payload[:origin_type] = message[:message].get('Body', 'Type')
|
144
138
|
payload[:origin_subject] = message[:message].get('Body', 'Subject')
|
@@ -160,18 +154,36 @@ module Jackal
|
|
160
154
|
def execute(message)
|
161
155
|
data_payload = unpack(message)
|
162
156
|
payload = new_payload(
|
163
|
-
config
|
157
|
+
config.fetch(:name, :jackal_cfn),
|
164
158
|
:cfn_resource => data_payload
|
165
159
|
)
|
166
160
|
if(config[:reprocess])
|
167
|
-
|
168
|
-
Carnivore::Supervisor.supervisor[my_input].transmit(payload)
|
161
|
+
Carnivore::Supervisor.supervisor[destination(:input)].transmit(payload)
|
169
162
|
message.confirm!
|
170
163
|
else
|
171
164
|
completed(payload, message)
|
172
165
|
end
|
173
166
|
end
|
174
167
|
|
168
|
+
# Custom wrap to send resource failure
|
169
|
+
#
|
170
|
+
# @param message [Carnivore::Message]
|
171
|
+
def failure_wrap(message)
|
172
|
+
begin
|
173
|
+
payload = unpack(message)
|
174
|
+
yield payload
|
175
|
+
rescue => e
|
176
|
+
error "Unexpected error encountered processing custom resource - #{e.class}: #{e}"
|
177
|
+
debug "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
|
178
|
+
cfn_resource = payload.get(:data, :cfn_resource)
|
179
|
+
cfn_response = build_response(cfn_resource)
|
180
|
+
cfn_response['Status'] = 'FAILED'
|
181
|
+
cfn_response['Reason'] = "Unexpected error encountered [#{e}]"
|
182
|
+
respond_to_stack(cfn_response, cfn_resource[:response_url])
|
183
|
+
message.confirm!
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
175
187
|
end
|
176
188
|
end
|
177
189
|
end
|
data/lib/jackal-cfn/utils.rb
CHANGED
data/lib/jackal-cfn/version.rb
CHANGED
data/lib/jackal-cfn.rb
CHANGED
@@ -7,10 +7,8 @@ module Jackal
|
|
7
7
|
autoload :Event, 'jackal-cfn/event'
|
8
8
|
autoload :Resource, 'jackal-cfn/resource'
|
9
9
|
autoload :Utils, 'jackal-cfn/utils'
|
10
|
-
end
|
11
10
|
|
12
|
-
|
13
|
-
module CfnTools
|
11
|
+
# Provided custom resources
|
14
12
|
autoload :HashExtractor, 'jackal-cfn/resource/hash_extractor'
|
15
13
|
autoload :AmiManager, 'jackal-cfn/resource/ami_manager'
|
16
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jackal-cfn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jackal
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- jackal-cfn.gemspec
|
52
52
|
- lib/jackal-cfn.rb
|
53
53
|
- lib/jackal-cfn/event.rb
|
54
|
+
- lib/jackal-cfn/formatter/chef_cleanup.rb
|
54
55
|
- lib/jackal-cfn/resource.rb
|
55
56
|
- lib/jackal-cfn/resource/ami_manager.rb
|
56
57
|
- lib/jackal-cfn/resource/hash_extractor.rb
|
@@ -83,4 +84,3 @@ signing_key:
|
|
83
84
|
specification_version: 4
|
84
85
|
summary: Message processing helper
|
85
86
|
test_files: []
|
86
|
-
has_rdoc:
|