qb 0.1.88 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/qb +3 -53
- data/lib/qb.rb +3 -1
- data/lib/qb/ansible.rb +5 -0
- data/lib/qb/ansible/config_file.rb +147 -0
- data/lib/qb/ansible/env.rb +49 -0
- data/lib/qb/ansible/playbook.rb +4 -0
- data/lib/qb/cli.rb +4 -0
- data/lib/qb/cli/play.rb +33 -0
- data/lib/qb/options.rb +48 -7
- data/lib/qb/role.rb +228 -74
- data/lib/qb/util.rb +2 -2
- data/lib/qb/util/bundler.rb +56 -0
- data/lib/qb/version.rb +1 -1
- data/node_modules/.bin/semver +1 -1
- data/plugins/filter_plugins/{path.py → path_plugins.py} +35 -0
- data/plugins/filter_plugins/{ruby_interop.py → ruby_interop_plugins.py} +0 -0
- data/plugins/filter_plugins/{string.py → string_plugins.py} +19 -0
- data/plugins/filter_plugins/{version.py → version_plugins.py} +0 -0
- data/qb.gemspec +1 -0
- data/roles/nrser.blockinfile/tests/expected/test-follow/link2.txt +1 -1
- data/roles/nrser.blockinfile/tests/fixtures/test-follow/link0.txt +1 -1
- data/roles/nrser.blockinfile/tests/fixtures/test-follow/link1.txt +1 -1
- data/roles/nrser.blockinfile/tests/fixtures/test-follow/link2.txt +1 -1
- data/roles/nrser.blockinfile/tests/roles/yaegashi.blockinfile +1 -1
- data/roles/qb.gitignore/files/gitignore/Clojure.gitignore +1 -1
- data/roles/qb.gitignore/files/gitignore/Fortran.gitignore +1 -1
- data/roles/qb.qb_role/templates/qb.yml.j2 +1 -1
- data/roles/qb/dev/ref/repo/git/defaults/main.yml +32 -0
- data/roles/qb/dev/ref/repo/git/meta/main.yml +8 -0
- data/roles/qb/dev/ref/repo/git/meta/qb.yml +67 -0
- data/roles/qb/dev/ref/repo/git/tasks/main.yml +16 -0
- data/roles/qb/facts/defaults/main.yml +3 -0
- data/roles/{qb.facts → qb/facts}/meta/main.yml +1 -1
- data/roles/{qb.facts → qb/facts}/meta/qb.yml +1 -1
- data/roles/{qb.facts → qb/facts}/tasks/main.yml +1 -1
- data/roles/qb/osx/git/change_case/README.md +16 -0
- data/roles/qb/osx/git/change_case/defaults/main.yml +2 -0
- data/roles/qb/osx/git/change_case/meta/main.yml +8 -0
- data/roles/qb/osx/git/change_case/meta/qb.yml +80 -0
- data/roles/qb/osx/git/change_case/tasks/main.yml +6 -0
- data/roles/qb/osx/git/change_case/tasks/upcase.yml +26 -0
- metadata +42 -11
- data/roles/qb.facts/defaults/main.yml +0 -3
data/lib/qb/version.rb
CHANGED
data/node_modules/.bin/semver
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
../semver/bin/semver
|
@@ -45,7 +45,41 @@ def resolve(*path_segments):
|
|
45
45
|
'''
|
46
46
|
|
47
47
|
return Path(*path_segments).resolve().__str__()
|
48
|
+
|
49
|
+
|
50
|
+
def path_upcase_filename(path):
|
51
|
+
'''
|
52
|
+
Implemented pretty much just for `qb/osx/git/change_case` role...
|
53
|
+
just upcase the file (or directory) name at `path`, leaving any "normal"
|
54
|
+
file extension as is (will prob fuck up in weird file extension cases).
|
55
|
+
|
56
|
+
>>> path_upcase_filename('./a.txt')
|
57
|
+
'./A.txt'
|
58
|
+
|
59
|
+
>>> path_upcase_filename('./a/b.txt')
|
60
|
+
'./a/B.txt'
|
61
|
+
|
62
|
+
>>> path_upcase_filename('./a')
|
63
|
+
'./A'
|
48
64
|
|
65
|
+
>>> path_upcase_filename('./a/b')
|
66
|
+
'./a/B'
|
67
|
+
|
68
|
+
>>> path_upcase_filename('./a.b.txt')
|
69
|
+
'./A.B.txt'
|
70
|
+
|
71
|
+
>>> path_upcase_filename('./products/sg-v1/')
|
72
|
+
'./products/SG-V1'
|
73
|
+
|
74
|
+
>>> path_upcase_filename('./products/sg-v1')
|
75
|
+
'./products/SG-V1'
|
76
|
+
'''
|
77
|
+
|
78
|
+
head, ext = os.path.splitext(path.strip('/'))
|
79
|
+
dirname = os.path.dirname(head)
|
80
|
+
filename = os.path.basename(head)
|
81
|
+
return os.path.join(dirname, filename.upper() + ext)
|
82
|
+
|
49
83
|
|
50
84
|
class FilterModule(object):
|
51
85
|
'''
|
@@ -56,6 +90,7 @@ class FilterModule(object):
|
|
56
90
|
return {
|
57
91
|
'path_join': os.path.join,
|
58
92
|
'path_resolve': resolve,
|
93
|
+
'path_upcase_filename': path_upcase_filename,
|
59
94
|
}
|
60
95
|
|
61
96
|
|
File without changes
|
@@ -1,3 +1,22 @@
|
|
1
|
+
# **WARNING**
|
2
|
+
#
|
3
|
+
# Naming this file `string.py` fucks something up:
|
4
|
+
#
|
5
|
+
# $ python2 plugins/filter_plugins/path.py
|
6
|
+
# Traceback (most recent call last):
|
7
|
+
# File "plugins/filter_plugins/path.py", line 17, in <module>
|
8
|
+
# from pathlib2 import Path
|
9
|
+
# File "/usr/local/lib/python2.7/site-packages/pathlib2.py", line 21, in <module>
|
10
|
+
# from urllib import quote as urlquote_from_bytes
|
11
|
+
# File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 30, in <module>
|
12
|
+
# import base64
|
13
|
+
# File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/base64.py", line 98, in <module>
|
14
|
+
# _urlsafe_encode_translation = string.maketrans(b'+/', b'-_')
|
15
|
+
# AttributeError: 'module' object has no attribute 'maketrans'
|
16
|
+
#
|
17
|
+
# https://stackoverflow.com/questions/35139025/can-not-handle-attributeerror-module-object-has-no-attribute-maketrans
|
18
|
+
#
|
19
|
+
|
1
20
|
from __future__ import (absolute_import, division, print_function)
|
2
21
|
__metaclass__ = type
|
3
22
|
|
File without changes
|
data/qb.gemspec
CHANGED
@@ -92,6 +92,7 @@ Gem::Specification.new do |spec|
|
|
92
92
|
spec.add_development_dependency "rake", "~> 10.0"
|
93
93
|
spec.add_development_dependency "rspec"
|
94
94
|
spec.add_development_dependency "yard"
|
95
|
+
spec.add_development_dependency "pry"
|
95
96
|
|
96
97
|
spec.add_dependency "cmds",'~> 0.0', ">= 0.2.1"
|
97
98
|
spec.add_dependency "nrser",'~> 0.0', ">= 0.0.20"
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
real2.txt
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
real0.txt
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
real1.txt
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
real2.txt
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
../..
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Leiningen.gitignore
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
C++.gitignore
|
@@ -0,0 +1,32 @@
|
|
1
|
+
---
|
2
|
+
# defaults file for qb/ref/repo/git
|
3
|
+
project_root: >-
|
4
|
+
{{ qb_dir }}
|
5
|
+
|
6
|
+
version: HEAD
|
7
|
+
|
8
|
+
host: github.com
|
9
|
+
|
10
|
+
ssh_user: git
|
11
|
+
|
12
|
+
protocol: ssh
|
13
|
+
|
14
|
+
depth: 1
|
15
|
+
|
16
|
+
update: false
|
17
|
+
|
18
|
+
owner: >-
|
19
|
+
{{ full_name.split('/')[0] }}
|
20
|
+
|
21
|
+
name: >-
|
22
|
+
{{ full_path.split('/')[1] }}
|
23
|
+
|
24
|
+
full_name: >-
|
25
|
+
{{ owner }}/{{ name }}
|
26
|
+
|
27
|
+
rel_dest: >-
|
28
|
+
{{ name }}@{{ version }}
|
29
|
+
|
30
|
+
dest: >-
|
31
|
+
{{ project_root }}/dev/ref/{{ rel_dest }}
|
32
|
+
|
@@ -0,0 +1,67 @@
|
|
1
|
+
---
|
2
|
+
# meta/qb.yml file for qb/ref/repo/git
|
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
|
+
# Gemspec-style requirements. Right now only `gems:qb` is used, but plan to
|
11
|
+
# generalize in the future.
|
12
|
+
requirements:
|
13
|
+
gems:
|
14
|
+
qb: ~> 0.3.0
|
15
|
+
|
16
|
+
# prefix for role variables
|
17
|
+
var_prefix: false
|
18
|
+
|
19
|
+
# how to get a default for `dir` if it's not provided as the only
|
20
|
+
# positional argument. if a positional argument is provided it will
|
21
|
+
# override the method defined here.
|
22
|
+
#
|
23
|
+
# options:
|
24
|
+
#
|
25
|
+
# - null
|
26
|
+
# - require the value on the command line.
|
27
|
+
# - false
|
28
|
+
# - don't provide qb_dir (means doesn't load or save options either).
|
29
|
+
# - git_root
|
30
|
+
# - use the git root fof the directory that the `qb` command is invoked
|
31
|
+
# from. useful for 'project-centric' commands so they can be invoked
|
32
|
+
# from anywhere in the repo.
|
33
|
+
# - cwd
|
34
|
+
# - use the directory the `qb` command is invoked form.
|
35
|
+
# - {exe: PATH}
|
36
|
+
# - invoke an execuable, passing a JSON serialization of the options
|
37
|
+
# mapping their CLI names to values. path can be relative to role
|
38
|
+
# directory.
|
39
|
+
# - {find_up: FILENAME}
|
40
|
+
# - starting at the current direcotry and climbing up to parent
|
41
|
+
# directories, use the first one that contains FILENAME. error
|
42
|
+
# if none is found.
|
43
|
+
default_dir: null
|
44
|
+
|
45
|
+
# If `true`, QB will ensure the default dir exists before starting the play.
|
46
|
+
#
|
47
|
+
# For legacy reasons, this defaults to `true` if not present, but we want to
|
48
|
+
# default declare it as `false` here so new roles can turn it on only if
|
49
|
+
# they need it.
|
50
|
+
#
|
51
|
+
mkdir: false
|
52
|
+
|
53
|
+
# default user to become for play
|
54
|
+
default_user: null
|
55
|
+
|
56
|
+
# set to false to not save options in .qb-options.yml files
|
57
|
+
save_options: true
|
58
|
+
|
59
|
+
# options to pass to ansible-playbook
|
60
|
+
ansible_options: {}
|
61
|
+
|
62
|
+
options: []
|
63
|
+
# - name: example
|
64
|
+
# description: an example of a variable.
|
65
|
+
# required: false
|
66
|
+
# type: boolean # boolean (default) | string
|
67
|
+
# short: e
|
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
# tasks file for qb/ref/repo/git
|
3
|
+
|
4
|
+
- name: >-
|
5
|
+
Clone {{ full_name }}@{{ version }} Git repo for reference.
|
6
|
+
git:
|
7
|
+
repo: >-
|
8
|
+
{{ ssh_user }}@{{ host }}:{{ full_name }}.git
|
9
|
+
dest: >-
|
10
|
+
{{ dest }}
|
11
|
+
version: >-
|
12
|
+
{{ version }}
|
13
|
+
depth: >-
|
14
|
+
{{ depth }}
|
15
|
+
update: >-
|
16
|
+
{{ update }}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
qb/osx/git/change_case Role
|
2
|
+
===========================
|
3
|
+
|
4
|
+
Changes casing of a file or directory under Git control on OSX.
|
5
|
+
|
6
|
+
Due to OSX's default file system being *case insensitive* (and changing it to case-sensitive causing all sorts of problems), it's my current understanding that this requires:
|
7
|
+
|
8
|
+
1. Changing the name in a way that is recognized by the case-insensitive file system.
|
9
|
+
|
10
|
+
2. Committing that change.
|
11
|
+
|
12
|
+
3. Changing the name to the desired name.
|
13
|
+
|
14
|
+
4. Committing that change.
|
15
|
+
|
16
|
+
So that's what this role does.
|
@@ -0,0 +1,80 @@
|
|
1
|
+
---
|
2
|
+
# meta/qb.yml file for change_case
|
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: >-
|
9
|
+
Change casing of a file or directory under Git control on OSX.
|
10
|
+
|
11
|
+
# Gemspec-style requirements. Right now only `gems:qb` is used, but plan to
|
12
|
+
# generalize in the future.
|
13
|
+
requirements:
|
14
|
+
gems:
|
15
|
+
qb: ~> 0.3.0
|
16
|
+
|
17
|
+
# prefix for role variables
|
18
|
+
var_prefix: null
|
19
|
+
|
20
|
+
# how to get a default for `dir` if it's not provided as the only
|
21
|
+
# positional argument. if a positional argument is provided it will
|
22
|
+
# override the method defined here.
|
23
|
+
#
|
24
|
+
# options:
|
25
|
+
#
|
26
|
+
# - null
|
27
|
+
# - require the value on the command line.
|
28
|
+
# - false
|
29
|
+
# - don't provide qb_dir (means doesn't load or save options either).
|
30
|
+
# - git_root
|
31
|
+
# - use the git root fof the directory that the `qb` command is invoked
|
32
|
+
# from. useful for 'project-centric' commands so they can be invoked
|
33
|
+
# from anywhere in the repo.
|
34
|
+
# - cwd
|
35
|
+
# - use the directory the `qb` command is invoked form.
|
36
|
+
# - {exe: PATH}
|
37
|
+
# - invoke an execuable, passing a JSON serialization of the options
|
38
|
+
# mapping their CLI names to values. path can be relative to role
|
39
|
+
# directory.
|
40
|
+
# - {find_up: FILENAME}
|
41
|
+
# - starting at the current direcotry and climbing up to parent
|
42
|
+
# directories, use the first one that contains FILENAME. error
|
43
|
+
# if none is found.
|
44
|
+
default_dir: false
|
45
|
+
|
46
|
+
# If `true`, QB will ensure the default dir exists before starting the play.
|
47
|
+
#
|
48
|
+
# For legacy reasons, this defaults to `true` if not present, but we want to
|
49
|
+
# default declare it as `false` here so new roles can turn it on only if
|
50
|
+
# they need it.
|
51
|
+
#
|
52
|
+
mkdir: false
|
53
|
+
|
54
|
+
# default user to become for play
|
55
|
+
default_user: null
|
56
|
+
|
57
|
+
# set to false to not save options in .qb-options.yml files
|
58
|
+
save_options: false
|
59
|
+
|
60
|
+
# options to pass to ansible-playbook
|
61
|
+
ansible_options: {}
|
62
|
+
|
63
|
+
options:
|
64
|
+
# - name: example
|
65
|
+
# description: an example of a variable.
|
66
|
+
# required: false
|
67
|
+
# type: boolean # boolean (default) | string
|
68
|
+
# short: e
|
69
|
+
|
70
|
+
- name: from
|
71
|
+
description: >-
|
72
|
+
Path or glob of the current files.
|
73
|
+
required: true
|
74
|
+
type: glob
|
75
|
+
|
76
|
+
- name: upcase
|
77
|
+
description: >-
|
78
|
+
Convert all file names to all upper-case.
|
79
|
+
require: false
|
80
|
+
type: boolean
|
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
|
3
|
+
- name: >-
|
4
|
+
Change file names to all upper case.
|
5
|
+
with_items: >-
|
6
|
+
{{ change_case_from }}
|
7
|
+
command: >-
|
8
|
+
git mv {{ item }} {{ (item.strip('/') + '.RENAME_TEMP') | quote }}
|
9
|
+
|
10
|
+
- name: >-
|
11
|
+
Commit temp file names in Git.
|
12
|
+
command: >-
|
13
|
+
git commit -m {{ "Temp file renames when upcasing on OSX" | quote }}
|
14
|
+
|
15
|
+
- name: >-
|
16
|
+
Change file name to desired upper case.
|
17
|
+
with_items: >-
|
18
|
+
{{ change_case_from }}
|
19
|
+
command: >-
|
20
|
+
git mv {{ (item.strip('/') + '.RENAME_TEMP') | quote }}
|
21
|
+
{{ item | path_upcase_filename }}
|
22
|
+
|
23
|
+
- name: >-
|
24
|
+
Commit final file names in Git.
|
25
|
+
command: >-
|
26
|
+
git commit -m {{ "Final file renames when upcasing on OSX" | quote }}
|