qb 0.1.28 → 0.1.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dev/scratch/empty/defaults/main.yml +2 -0
- data/dev/scratch/empty/meta/main.yml +8 -0
- data/dev/scratch/empty/meta/qb.yml +44 -0
- data/dev/scratch/empty/tasks/main.yml +2 -0
- data/exe/qb +34 -18
- data/lib/qb/options.rb +18 -4
- data/lib/qb/role.rb +8 -0
- data/lib/qb/version.rb +1 -1
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aac656a40513fcf8c1f6acc71036dce971733b9a
|
4
|
+
data.tar.gz: 554f6fe57718822c2afadaf72476804fa997d8c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7417819a6a7f768dc16b10605c6ef931a3b74d1965fdec6beba320b74bc4cf23fb331317c3526c752800af65948fe6980a65791c7213314d126d7d51de536b8f
|
7
|
+
data.tar.gz: aa2201ebaef641282e34f523c574b92e90303151163c3f0915a3fea9ae963d2a0b17e1e9fa0af719a520424a6398330543a2d9234626dad20c4298375ffe6e53
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
# meta/qb.yml file for empty
|
3
|
+
#
|
4
|
+
# qb settings for this role. see README.md for more info.
|
5
|
+
#
|
6
|
+
|
7
|
+
# description of the role to show in it's help output.
|
8
|
+
description: null
|
9
|
+
|
10
|
+
# prefix for role variables
|
11
|
+
var_prefix: null
|
12
|
+
|
13
|
+
# how to get a default for `dir` if it's not provided as the only
|
14
|
+
# positional argument. if a positional argument is provided it will
|
15
|
+
# override the method defined here.
|
16
|
+
#
|
17
|
+
# options:
|
18
|
+
#
|
19
|
+
# - null
|
20
|
+
# - require the value on the command line.
|
21
|
+
# - git_root
|
22
|
+
# - use the git root fof the directory that the `qb` command is invoked
|
23
|
+
# from. useful for 'project-centric' commands so they can be invoked
|
24
|
+
# from anywhere in the repo.
|
25
|
+
# - cwd
|
26
|
+
# - use the directory the `qb` command is invoked form.
|
27
|
+
# - {exe: PATH}
|
28
|
+
# - invoke an execuable, passing a JSON serialization of the options
|
29
|
+
# mapping their CLI names to values. path can be relative to role
|
30
|
+
# directory.
|
31
|
+
default_dir: cwd
|
32
|
+
|
33
|
+
# default user to become for play
|
34
|
+
default_user: null
|
35
|
+
|
36
|
+
# set to false to not save options in .qb-options.yml files
|
37
|
+
save_options: true
|
38
|
+
|
39
|
+
options: []
|
40
|
+
# - name: example
|
41
|
+
# description: an example of a variable.
|
42
|
+
# required: false
|
43
|
+
# type: boolean # boolean (default) | string
|
44
|
+
# short: e
|
data/exe/qb
CHANGED
@@ -16,7 +16,7 @@ require 'qb'
|
|
16
16
|
ROOT = QB::ROOT
|
17
17
|
ROLES_DIR = QB::ROLES_DIR
|
18
18
|
ROLES = Pathname.glob(ROLES_DIR + 'qb.*').map {|path| path.basename.to_s}
|
19
|
-
DEBUG_ARGS = ['-D', '--
|
19
|
+
DEBUG_ARGS = ['-D', '--DEBUG']
|
20
20
|
TMP_DIR = ROOT + 'tmp'
|
21
21
|
|
22
22
|
# globals
|
@@ -236,7 +236,7 @@ def main args
|
|
236
236
|
|
237
237
|
debug "playbook", playbook
|
238
238
|
|
239
|
-
playbook_path =
|
239
|
+
playbook_path = Pathname.new(Dir.getwd) + '.qb-playbook.yml'
|
240
240
|
debug playbook_path: playbook_path.to_s
|
241
241
|
|
242
242
|
playbook_path.open('w') do |f|
|
@@ -268,34 +268,50 @@ def main args
|
|
268
268
|
tmp_roles_path = QB::ROOT + 'tmp' + 'roles'
|
269
269
|
|
270
270
|
ansible_roles_path = (
|
271
|
-
[
|
272
|
-
|
271
|
+
[
|
272
|
+
role.path.expand_path.dirname,
|
273
|
+
tmp_roles_path
|
274
|
+
] + QB::Role.search_path
|
273
275
|
).join(':')
|
274
276
|
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
#
|
281
|
-
# roles_path: tmp_roles_path.to_s
|
282
|
-
# end
|
283
|
-
# end
|
284
|
-
|
285
|
-
# the `gem` ansible module doesn't work right when the bunlder env vars
|
277
|
+
ansible_library_path = [
|
278
|
+
ROOT + 'library',
|
279
|
+
].join(':')
|
280
|
+
|
281
|
+
Dir.chdir QB::ROOT do
|
282
|
+
# the `gem` ansible module doesn't work right when the bundler env vars
|
286
283
|
# are set... so we need to clear them.
|
287
284
|
with_clean_env do
|
288
285
|
template = []
|
289
|
-
template << "ANSIBLE_ROLES_PATH=<%= roles_path %>
|
286
|
+
template << "ANSIBLE_ROLES_PATH=<%= roles_path %>"
|
287
|
+
template << "ANSIBLE_LIBRARY=<%= library_path %>"
|
288
|
+
template << "ansible-playbook"
|
289
|
+
|
290
290
|
if play['hosts'] != ['localhost']
|
291
291
|
template << "-i <%= hosts %>"
|
292
292
|
end
|
293
|
+
|
294
|
+
if qb_options['tags']
|
295
|
+
template << "--tags=<%= tags %>"
|
296
|
+
end
|
297
|
+
|
298
|
+
if qb_options['verbose']
|
299
|
+
template << "-#{ 'v' * qb_options['verbose'] }"
|
300
|
+
end
|
301
|
+
|
293
302
|
template << "<%= playbook_path %>"
|
294
303
|
|
295
|
-
|
304
|
+
cmd = Cmds.sub template.join(" "), [], {
|
296
305
|
roles_path: ansible_roles_path,
|
306
|
+
library_path: ansible_library_path,
|
297
307
|
playbook_path: playbook_path.to_s,
|
298
|
-
hosts: "#{ play['hosts'].join(',') },"
|
308
|
+
hosts: "#{ play['hosts'].join(',') },",
|
309
|
+
tags: (qb_options['tags'] ? qb_options['tags'].join(',') : nil),
|
310
|
+
}
|
311
|
+
|
312
|
+
puts "COMMAND: #{ cmd }"
|
313
|
+
|
314
|
+
status = Cmds.stream cmd
|
299
315
|
|
300
316
|
if status != 0
|
301
317
|
puts "ERROR ansible-playbook failed."
|
data/lib/qb/options.rb
CHANGED
@@ -196,11 +196,25 @@ module QB
|
|
196
196
|
qb_options['user'] = value
|
197
197
|
end
|
198
198
|
|
199
|
-
|
199
|
+
opts.on(
|
200
|
+
'-T',
|
201
|
+
'--TAGS=TAGS',
|
202
|
+
Array,
|
203
|
+
"playbook tags",
|
204
|
+
) do |value|
|
205
|
+
qb_options['tags'] = value
|
206
|
+
end
|
200
207
|
|
201
|
-
opts.
|
202
|
-
|
203
|
-
|
208
|
+
opts.on(
|
209
|
+
'-V',
|
210
|
+
'--VERBOSE[=LEVEL]',
|
211
|
+
"run playbook in verbose mode"
|
212
|
+
) do |value|
|
213
|
+
qb_options['verbose'] = if value.nil?
|
214
|
+
1
|
215
|
+
else
|
216
|
+
value.to_i
|
217
|
+
end
|
204
218
|
end
|
205
219
|
end
|
206
220
|
|
data/lib/qb/role.rb
CHANGED
@@ -97,6 +97,14 @@ module QB
|
|
97
97
|
|
98
98
|
# find exactly one matching role for the input string or raise.
|
99
99
|
def self.require input
|
100
|
+
|
101
|
+
as_pathname = Pathname.new(input)
|
102
|
+
|
103
|
+
# allow a path to a role dir
|
104
|
+
if role_dir? as_pathname
|
105
|
+
return Role.new as_pathname
|
106
|
+
end
|
107
|
+
|
100
108
|
matches = self.matches input
|
101
109
|
|
102
110
|
role = case matches.length
|
data/lib/qb/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.29
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nrser
|
@@ -138,6 +138,10 @@ files:
|
|
138
138
|
- dev/hosts
|
139
139
|
- dev/requirements.yml
|
140
140
|
- dev/scratch/case.rb
|
141
|
+
- dev/scratch/empty/defaults/main.yml
|
142
|
+
- dev/scratch/empty/meta/main.yml
|
143
|
+
- dev/scratch/empty/meta/qb.yml
|
144
|
+
- dev/scratch/empty/tasks/main.yml
|
141
145
|
- dev/setup.yml
|
142
146
|
- exe/qb
|
143
147
|
- lib/qb.rb
|