rezept 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +17 -16
- data/lib/rezept/actions.rb +22 -11
- data/lib/rezept/cli.rb +2 -1
- data/lib/rezept/client.rb +17 -2
- data/lib/rezept/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1a63c85f4f727f5f7f62cf237216d194f59e084
|
4
|
+
data.tar.gz: 208608be750743f64f5e4e5b707d7bc1596751f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3439526ec9d6f927172b56590bc343d7e24a0c7ff8d2651834145a677fc94ab01f14a699a5413ea9b01021c246843184f85339296671785250a390b9071dd042
|
7
|
+
data.tar.gz: 726585c29de47da270c4129d780bd275a7ec3e0cfa9b101ba2cab6657a4b56a76430299a738fdc58767bdb9a71f6176711363f75a57c3ebd40d47676ee38e8ef
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.3.0
|
2
|
+
- Add `--wait-entries option` to `run_command` [#3][]
|
3
|
+
- Change `--wait` option to `--wait-results` option
|
4
|
+
- Add `--wait-entries` option
|
5
|
+
- Bugfix
|
6
|
+
|
1
7
|
## 0.2.0
|
2
8
|
- Add `put_inventory` command [#2][]
|
3
9
|
- Add the options to search target instances from inventory to `run_command` [#2][]
|
@@ -17,4 +23,5 @@
|
|
17
23
|
|
18
24
|
<!--- The following link definition list is generated by PimpMyChangelog --->
|
19
25
|
[#1]: https://github.com/serverworks/rezept/issues/1
|
20
|
-
[#2]: https://github.com/serverworks/rezept/issues/2
|
26
|
+
[#2]: https://github.com/serverworks/rezept/issues/2
|
27
|
+
[#3]: https://github.com/serverworks/rezept/issues/3
|
data/README.md
CHANGED
@@ -112,21 +112,22 @@ Usage:
|
|
112
112
|
rezept run_command -d, --document=DOCUMENT
|
113
113
|
|
114
114
|
Options:
|
115
|
-
-d, --document=DOCUMENT
|
116
|
-
-i, [--instance-ids=one two three]
|
117
|
-
-t, [--tags=key:value]
|
118
|
-
-I, [--inventory=INVENTORY]
|
119
|
-
-C, [--conditions=one two three]
|
120
|
-
-p, [--parameters=key:value]
|
121
|
-
[--dry-run], [--no-dry-run]
|
122
|
-
[--wait], [--no-wait]
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
[--
|
129
|
-
|
115
|
+
-d, --document=DOCUMENT # The name of the document
|
116
|
+
-i, [--instance-ids=one two three] # EC2 Instance IDs
|
117
|
+
-t, [--tags=key:value] # EC2 Instance tags
|
118
|
+
-I, [--inventory=INVENTORY] # The name of the inventory type
|
119
|
+
-C, [--conditions=one two three] # The conditions to search inventories (ex. "Foo = Bar", "Buz > 1.0")
|
120
|
+
-p, [--parameters=key:value] # Parameters for the document
|
121
|
+
[--dry-run], [--no-dry-run] # Dry run (Only output the targets)
|
122
|
+
[--wait-entries], [--no-wait-entries] # Wait for entries of managed instances
|
123
|
+
[--wait-results], [--no-wait-results] # Wait and check for all results
|
124
|
+
-f, [--file=FILE] # Configuration file
|
125
|
+
# Default: Docfile
|
126
|
+
[--color], [--no-color] # Disable colorize
|
127
|
+
# Default: true
|
128
|
+
[--amazon-docs], [--no-amazon-docs] # Include Amazon owned documents
|
129
|
+
[--dsl-content], [--no-dsl-content] # Convert JSON contents to DSL
|
130
|
+
# Default: true
|
130
131
|
```
|
131
132
|
|
132
133
|
- If you specify multiple values to `tags` and `parameters`, separate them with commas(`,`).
|
@@ -167,7 +168,7 @@ Command "My-RunShellScript" do
|
|
167
168
|
content do
|
168
169
|
__dsl do
|
169
170
|
schemaVersion "2.0"
|
170
|
-
description "
|
171
|
+
description "Run a shell script."
|
171
172
|
mainSteps do |*|
|
172
173
|
action "aws:runShellScript"
|
173
174
|
name "runShellScript"
|
data/lib/rezept/actions.rb
CHANGED
@@ -74,28 +74,40 @@ module Rezept
|
|
74
74
|
|
75
75
|
def run_command(options)
|
76
76
|
dry_run = options['dry_run'] ? '[Dry run] ' : ''
|
77
|
+
@client.set_options(options)
|
77
78
|
|
78
79
|
if options['instance_ids'].nil? and options['tags'].nil? and (options['inventory'].nil? or options['conditions'].nil?)
|
79
80
|
raise "Please specify the targets (--instance-ids/-i' or '--target-tags/-t' or '--inventroty/-I and --conditions/-C')"
|
80
81
|
end
|
81
82
|
|
82
|
-
instances = @client.
|
83
|
+
instances = @client.get_instances(
|
83
84
|
options['instance_ids'],
|
84
85
|
_tags_to_criteria(options['tags'], 'name')
|
85
86
|
)
|
86
87
|
|
88
|
+
instance_ids = []
|
89
|
+
instances.each {|i| instance_ids << i.instance_id }
|
90
|
+
managed_instances = @client.get_managed_instances(instance_ids)
|
91
|
+
|
92
|
+
if options['wait_entries']
|
93
|
+
info("#{dry_run}Wait for entries of managed instances...")
|
94
|
+
while instances.length > 0 and managed_instances.length == 0
|
95
|
+
managed_instances = @client.get_managed_instances(instance_ids)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
87
99
|
info("#{dry_run}Target instances...")
|
88
100
|
|
89
101
|
unless options['inventory'].nil?
|
90
|
-
|
91
|
-
raise "Can't find target instances from inventories" if
|
102
|
+
managed_instances = _filter_by_inventory(managed_instances, options['inventory'], options['conditions'])
|
103
|
+
raise "Can't find target instances from inventories" if managed_instances.empty?
|
92
104
|
end
|
93
|
-
_print_instances(
|
105
|
+
_print_instances(managed_instances)
|
94
106
|
|
95
107
|
instance_ids = options['instance_ids']
|
96
108
|
if instance_ids.nil? and not options['inventory'].nil?
|
97
109
|
instance_ids = []
|
98
|
-
|
110
|
+
managed_instances.each {|i| instance_ids << i.instance_id}
|
99
111
|
end
|
100
112
|
|
101
113
|
if dry_run.empty?
|
@@ -105,7 +117,7 @@ module Rezept
|
|
105
117
|
_tags_to_criteria(options['tags'], 'key'),
|
106
118
|
_convert_paraeters(options['parameters'])
|
107
119
|
)
|
108
|
-
_wait_all_results(command.command_id) if options['
|
120
|
+
_wait_all_results(command.command_id) if options['wait_results']
|
109
121
|
end
|
110
122
|
end
|
111
123
|
|
@@ -113,12 +125,12 @@ module Rezept
|
|
113
125
|
filters = _conditions_to_filters(conditions)
|
114
126
|
ret = []
|
115
127
|
instances.each do |i|
|
116
|
-
|
128
|
+
inventory_entries = @client.list_inventory_entries(
|
117
129
|
i.instance_id,
|
118
130
|
inventory,
|
119
131
|
filters,
|
120
132
|
)
|
121
|
-
ret << i unless
|
133
|
+
ret << i unless inventory_entries.entries.empty?
|
122
134
|
end
|
123
135
|
ret
|
124
136
|
end
|
@@ -134,11 +146,10 @@ module Rezept
|
|
134
146
|
|
135
147
|
def _print_instances(instances)
|
136
148
|
instances.each do |instance|
|
137
|
-
|
138
|
-
if name_tag.empty?
|
149
|
+
if instance.name.nil?
|
139
150
|
info("- #{instance.instance_id}")
|
140
151
|
else
|
141
|
-
info("- #{
|
152
|
+
info("- #{instance.name} (#{instance.instance_id})")
|
142
153
|
end
|
143
154
|
end
|
144
155
|
end
|
data/lib/rezept/cli.rb
CHANGED
@@ -45,7 +45,8 @@ module Rezept
|
|
45
45
|
option :conditions, aliases: '-C', desc: 'The conditions to search inventories (ex. "Foo = Bar", "Buz > 1.0")', type: :array
|
46
46
|
option :parameters, aliases: '-p', desc: 'Parameters for the document', type: :hash
|
47
47
|
option :dry_run, desc: 'Dry run (Only output the targets)', type: :boolean, default: false
|
48
|
-
option :
|
48
|
+
option :wait_entries, desc: 'Wait for entries of managed instances', type: :boolean, default: false
|
49
|
+
option :wait_results, desc: 'Wait and check for all results', type: :boolean, default: false
|
49
50
|
def run_command
|
50
51
|
@actions.run_command(options)
|
51
52
|
end
|
data/lib/rezept/client.rb
CHANGED
@@ -62,7 +62,7 @@ module Rezept
|
|
62
62
|
)
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
65
|
+
def get_instances(instance_ids=nil, filters=nil, next_token=nil)
|
66
66
|
instances = []
|
67
67
|
|
68
68
|
ret = @ec2.describe_instances(
|
@@ -74,7 +74,22 @@ module Rezept
|
|
74
74
|
instances.concat(reservation.instances)
|
75
75
|
end
|
76
76
|
|
77
|
-
instances.concat(
|
77
|
+
instances.concat(get_instances(instance_ids, filters, ret.next_token)) unless ret.next_token.nil?
|
78
|
+
instances
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_managed_instances(instance_ids, next_token=nil)
|
82
|
+
instances = []
|
83
|
+
|
84
|
+
ret = @ssm.describe_instance_information(
|
85
|
+
filters: [{
|
86
|
+
key: "InstanceIds",
|
87
|
+
values: instance_ids
|
88
|
+
}],
|
89
|
+
next_token: next_token
|
90
|
+
)
|
91
|
+
instances = ret.instance_information_list
|
92
|
+
instances.concat(get_target_instances(instance_ids, ret.next_token)) unless ret.next_token.nil?
|
78
93
|
instances
|
79
94
|
end
|
80
95
|
|
data/lib/rezept/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rezept
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serverworks Co.,Ltd.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|