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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a41610bee660bf726351cbf23ad0b6c508d848b
4
- data.tar.gz: 78160fa1e066a2c4a4a66ccf88ba473810698f2e
3
+ metadata.gz: aac656a40513fcf8c1f6acc71036dce971733b9a
4
+ data.tar.gz: 554f6fe57718822c2afadaf72476804fa997d8c6
5
5
  SHA512:
6
- metadata.gz: ea76aa5ff561c6ee5aa6b338bf32d58356c49b342b666aad3575c2eb4abd6f71ae197e79d6cb646cc7f381f9716c7500e5ec2453a40070f5a7c7eb1c7b1b7683
7
- data.tar.gz: 320385cf69110aab19c9ca6ad94be24e6f055d0734bbeb52ea9d36b732721b7e473a4cf27384b7e8aa717c61c72dac96940d3e1570545568c1fa267b273ef139
6
+ metadata.gz: 7417819a6a7f768dc16b10605c6ef931a3b74d1965fdec6beba320b74bc4cf23fb331317c3526c752800af65948fe6980a65791c7213314d126d7d51de536b8f
7
+ data.tar.gz: aa2201ebaef641282e34f523c574b92e90303151163c3f0915a3fea9ae963d2a0b17e1e9fa0af719a520424a6398330543a2d9234626dad20c4298375ffe6e53
@@ -0,0 +1,2 @@
1
+ ---
2
+ # defaults file for empty
@@ -0,0 +1,8 @@
1
+ ---
2
+ # meta file for empty
3
+
4
+ allow_duplicates: yes
5
+
6
+ dependencies: []
7
+ # - role: role-name
8
+
@@ -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
@@ -0,0 +1,2 @@
1
+ ---
2
+ # tasks file for empty
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', '--debug']
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 = ROOT + '.qb-playbook.yml'
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
- [tmp_roles_path] +
272
- QB::Role.search_path
271
+ [
272
+ role.path.expand_path.dirname,
273
+ tmp_roles_path
274
+ ] + QB::Role.search_path
273
275
  ).join(':')
274
276
 
275
- Dir.chdir ROOT do
276
- # install requirements
277
- # unless (TMP_DIR + 'roles').directory?
278
- # with_clean_env do
279
- # Cmds.stream! "ANSIBLE_ROLES_PATH=<%= roles_path %> ansible-galaxy install --ignore-errors -r <%= req_path%>",
280
- # req_path: (ROOT + 'requirements.yml'),
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 %> ansible-playbook"
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
- status = Cmds.stream template.join(" "),
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."
@@ -196,11 +196,25 @@ module QB
196
196
  qb_options['user'] = value
197
197
  end
198
198
 
199
- add opts, role_options, role
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.on_tail("-h", "--help", "Show this message") do
202
- puts opts
203
- exit
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
 
@@ -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
@@ -1,7 +1,7 @@
1
1
  module QB
2
2
  GEM_NAME = 'qb'
3
3
 
4
- VERSION = "0.1.28"
4
+ VERSION = "0.1.29"
5
5
 
6
6
  def self.gemspec
7
7
  Gem.loaded_specs[GEM_NAME]
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.28
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