qb 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/qb +10 -91
- data/lib/qb/ansible.rb +2 -0
- data/lib/qb/ansible/cmds/playbook.rb +193 -0
- data/lib/qb/ansible/config_file.rb +10 -5
- data/lib/qb/ansible/env.rb +63 -3
- data/lib/qb/ansible/module.rb +194 -0
- data/lib/qb/ansible_module.rb +2 -182
- data/lib/qb/cli/play.rb +28 -2
- data/lib/qb/cli/run.rb +0 -0
- data/lib/qb/role.rb +1 -1
- data/lib/qb/util.rb +21 -5
- data/lib/qb/util/stdio.rb +52 -0
- data/lib/qb/version.rb +1 -1
- data/library/path_facts +1 -1
- data/library/stream +1 -1
- data/node_modules/.bin/semver +1 -1
- data/qb.gemspec +2 -2
- 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.bump/library/bump +2 -2
- data/roles/qb.git_submodule_update/library/git_submodule_update +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.role/meta/qb.yml +1 -1
- data/roles/qb.role/templates/library/module.rb.j2 +1 -1
- data/roles/qb/gem/release/tasks/main.yml +98 -39
- metadata +10 -8
- data/lib/qb/ansible/playbook.rb +0 -4
data/lib/qb/util/stdio.rb
CHANGED
@@ -1,15 +1,67 @@
|
|
1
|
+
# Requirements
|
2
|
+
# =====================================================================
|
3
|
+
|
4
|
+
# stdlib
|
1
5
|
require 'thread'
|
2
6
|
require 'socket'
|
3
7
|
require 'securerandom'
|
4
8
|
require 'fileutils'
|
5
9
|
require 'nrser'
|
6
10
|
|
11
|
+
# Refinements
|
12
|
+
# =====================================================================
|
13
|
+
|
14
|
+
require 'nrser/refinements'
|
7
15
|
using NRSER
|
8
16
|
|
17
|
+
|
18
|
+
# Declarations
|
19
|
+
# =====================================================================
|
20
|
+
|
9
21
|
module QB; end
|
10
22
|
module QB::Util; end
|
11
23
|
|
24
|
+
|
25
|
+
# Definitions
|
26
|
+
# =====================================================================
|
27
|
+
|
28
|
+
# Utilities for QB's standard-IO (`stdio`) handling feature.
|
29
|
+
#
|
30
|
+
# Normally, Ansible modules can't really do much with `stdio` - they return
|
31
|
+
# results by writing JSON to `stdout`, can't do anything useful with `stdin`,
|
32
|
+
# and I think things written to `stderr` don't go anywhere useful.
|
33
|
+
#
|
34
|
+
# This makes dealing with logging, error reporting and wrapping executables
|
35
|
+
# that report useful progress info to `stdout` or `stderr` pretty shitty.
|
36
|
+
#
|
37
|
+
# So, what we do is create streaming sockets for `stdout`, `stderr` and
|
38
|
+
# `stdin` in the QB process and write their paths to environment variables,
|
39
|
+
# which will be available to modules.
|
40
|
+
#
|
41
|
+
# {QB::Ansible::Module} automatically detects these variables and sets up
|
42
|
+
# `$stdout`, `$stderr` and `$stdin` to point to the sockets, which proxy
|
43
|
+
# back to the QB process' `stdio`.
|
44
|
+
#
|
45
|
+
# Of course other modules written in any language can also connect to these
|
46
|
+
# file sockets in the same manner.
|
47
|
+
#
|
48
|
+
# @note
|
49
|
+
# This feature only works for `localhost`. I have no idea what it will do
|
50
|
+
# in other cases. It doesn't seem like it should break anything, but remotely
|
51
|
+
# executing modules definitely won't be able to connect to the sockets on
|
52
|
+
# the host.
|
53
|
+
#
|
54
|
+
# @todo
|
55
|
+
# `stdin` support is pretty experimental / broken at this point. That would
|
56
|
+
# be nice to fix in the future so that programs that make use of user
|
57
|
+
# interaction work seamlessly through QB. This will probably require
|
58
|
+
# using pseudo-TTY streams or whatever.
|
59
|
+
#
|
12
60
|
module QB::Util::STDIO
|
61
|
+
|
62
|
+
# Constants
|
63
|
+
# =====================================================================
|
64
|
+
|
13
65
|
SOCKET_DIR = Pathname.new('/').join 'tmp', 'qb-stdio'
|
14
66
|
|
15
67
|
# STDIO as a service exposed on a UNIX socket so that modules can stream
|
data/lib/qb/version.rb
CHANGED
data/library/path_facts
CHANGED
@@ -30,7 +30,7 @@ GITHUB_SSH_URL_RE = /^git@github\.com\:(?<owner>.*)\/(?<name>.*)\.git$/
|
|
30
30
|
GITHUB_HTTPS_URL_RE = /^https:\/\/github\.com\/(?<owner>.*)\/(?<name>.*)\.git$/
|
31
31
|
|
32
32
|
|
33
|
-
class PathFacts < QB::
|
33
|
+
class PathFacts < QB::Ansible::Module
|
34
34
|
# Add a bunch of useful things to know about the path
|
35
35
|
def add_path_facts
|
36
36
|
@result.expanded = @path.expand_path
|
data/library/stream
CHANGED
data/node_modules/.bin/semver
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
node_modules/.bin/../semver/bin/semver
|
data/qb.gemspec
CHANGED
@@ -94,8 +94,8 @@ Gem::Specification.new do |spec|
|
|
94
94
|
spec.add_development_dependency "yard"
|
95
95
|
spec.add_development_dependency "pry"
|
96
96
|
|
97
|
-
spec.add_dependency "cmds",'~> 0.0', ">= 0.2.
|
98
|
-
spec.add_dependency "nrser",'~> 0.0', ">= 0.0.
|
97
|
+
spec.add_dependency "cmds",'~> 0.0', ">= 0.2.2"
|
98
|
+
spec.add_dependency "nrser",'~> 0.0', ">= 0.0.22"
|
99
99
|
spec.add_dependency "nrser-extras", '~> 0.0', ">= 0.0.3"
|
100
100
|
spec.add_dependency "state_mate", '~> 0.0', ">= 0.0.9"
|
101
101
|
spec.add_dependency 'parseconfig', '~> 1.0', '>= 1.0.8'
|
@@ -1 +1 @@
|
|
1
|
-
real2.txt
|
1
|
+
roles/nrser.blockinfile/tests/expected/test-follow/real2.txt
|
@@ -1 +1 @@
|
|
1
|
-
real0.txt
|
1
|
+
roles/nrser.blockinfile/tests/fixtures/test-follow/real0.txt
|
@@ -1 +1 @@
|
|
1
|
-
real1.txt
|
1
|
+
roles/nrser.blockinfile/tests/fixtures/test-follow/real1.txt
|
@@ -1 +1 @@
|
|
1
|
-
real2.txt
|
1
|
+
roles/nrser.blockinfile/tests/fixtures/test-follow/real2.txt
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
roles/nrser.blockinfile/tests/roles/../..
|
data/roles/qb.bump/library/bump
CHANGED
@@ -86,7 +86,7 @@ class Version
|
|
86
86
|
# ------------------------------------------------------------------------
|
87
87
|
|
88
88
|
def to_json options
|
89
|
-
QB::
|
89
|
+
QB::Ansible::Module.stringify_keys(to_hash).to_json options
|
90
90
|
end # #to_json
|
91
91
|
end # Version
|
92
92
|
|
@@ -179,7 +179,7 @@ class NodeBumper < Bumper
|
|
179
179
|
end # NodeBumper
|
180
180
|
|
181
181
|
|
182
|
-
class Bump < QB::
|
182
|
+
class Bump < QB::Ansible::Module
|
183
183
|
|
184
184
|
def check_repo_clean!
|
185
185
|
unless Cmds.chomp!('git status --porcelain 2>/dev/null') == ''
|
@@ -1 +1 @@
|
|
1
|
-
Leiningen.gitignore
|
1
|
+
roles/qb.gitignore/files/gitignore/Leiningen.gitignore
|
@@ -1 +1 @@
|
|
1
|
-
C++.gitignore
|
1
|
+
roles/qb.gitignore/files/gitignore/C++.gitignore
|
data/roles/qb.role/meta/qb.yml
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
require 'qb'
|
15
15
|
require 'nrser'
|
16
16
|
|
17
|
-
class {{ role_module_class }} < QB::
|
17
|
+
class {{ role_module_class }} < QB::Ansible::Module
|
18
18
|
# define arg names to NRSER::Types::Type instances here and they
|
19
19
|
# will be type checked and set as @<name>
|
20
20
|
#
|
@@ -18,6 +18,33 @@
|
|
18
18
|
{{ gem_root }}
|
19
19
|
|
20
20
|
|
21
|
+
- name: >-
|
22
|
+
See if a pre-release script exists at `//dev/hooks/pre-release`.
|
23
|
+
stat:
|
24
|
+
path: >-
|
25
|
+
{{ gem_root | path_join( 'dev', 'hooks', 'pre-release' ) }}
|
26
|
+
register: gem_pre_release_script_stat
|
27
|
+
|
28
|
+
- debug: var=gem_pre_release_script_stat
|
29
|
+
|
30
|
+
|
31
|
+
# NOTE Contrary to how it might seems in the [docs][1],
|
32
|
+
# the `stat` object seems to *only* have the `exists` property if the
|
33
|
+
# path does not exist (set to `false`), necessitating we
|
34
|
+
#
|
35
|
+
# [1]: http://docs.ansible.com/ansible/latest/stat_module.html
|
36
|
+
#
|
37
|
+
- when: >-
|
38
|
+
gem_pre_release_script_stat.stat.exists and
|
39
|
+
gem_pre_release_script_stat.stat.executable
|
40
|
+
name: >-
|
41
|
+
Execute `//dev/hooks/pre-release` script.
|
42
|
+
stream:
|
43
|
+
cmd: ./dev/hooks/pre-release
|
44
|
+
chdir: >-
|
45
|
+
{{ gem_root }}
|
46
|
+
|
47
|
+
|
21
48
|
- name: >-
|
22
49
|
Get gem and version info
|
23
50
|
vars.rb:
|
@@ -32,8 +59,6 @@
|
|
32
59
|
raise "No gemspec found for pattern #{ spec_pattern }"
|
33
60
|
end
|
34
61
|
|
35
|
-
spec = Gem::Specification.load spec_path
|
36
|
-
|
37
62
|
# The gem *may already be loaded*, which would break the standard gemspec
|
38
63
|
# approach because the `require` will be a no-op, resulting in the
|
39
64
|
# already loaded version number being used instead of the one in the
|
@@ -71,68 +96,102 @@
|
|
71
96
|
'version_path' => "#{ gem_root }/lib/#{ name }/version.rb",
|
72
97
|
'spec_path' => spec_path,
|
73
98
|
}
|
74
|
-
|
99
|
+
|
100
|
+
|
75
101
|
- debug:
|
76
102
|
msg:
|
77
|
-
# - spec_path: >-
|
78
|
-
# {{ gem_spec_path }}
|
79
|
-
# - version_path: >-
|
80
|
-
# {{ gem_version_path }}
|
81
103
|
- current: >-
|
82
104
|
{{ gem_current_version }}
|
83
105
|
- release: >-
|
84
106
|
{{ gem_release_version }}
|
85
107
|
- next: >-
|
86
108
|
{{ gem_next_version }}
|
109
|
+
# - spec_path: >-
|
110
|
+
# {{ gem_spec_path }}
|
111
|
+
# - version_path: >-
|
112
|
+
# {{ gem_version_path }}
|
87
113
|
|
88
|
-
- name: "change version to release version {{ gem_release_version }}"
|
89
|
-
replace:
|
90
|
-
dest: "{{ gem_version_path }}"
|
91
|
-
regexp: "VERSION\\s*=\\s*\"{{ gem_current_version }}\""
|
92
|
-
replace: "VERSION = \"{{ gem_release_version }}\""
|
93
|
-
when: gem_current_version != gem_release_version
|
94
114
|
|
115
|
+
- when: gem_current_version != gem_release_version
|
116
|
+
name: >-
|
117
|
+
Change version in `{{ gem_version_path }}` from current
|
118
|
+
`{{ gem_current_version }}` to `{{ gem_release_version }}`.
|
119
|
+
block:
|
120
|
+
- name: >-
|
121
|
+
Change version to release version `{{ gem_release_version }}`.
|
122
|
+
replace:
|
123
|
+
dest: >-
|
124
|
+
{{ gem_version_path }}
|
125
|
+
regexp: >-
|
126
|
+
VERSION\s*=\s*["']{{ gem_current_version }}["']
|
127
|
+
replace: >-
|
128
|
+
VERSION = "{{ gem_release_version }}"
|
129
|
+
|
130
|
+
|
131
|
+
- name: >-
|
132
|
+
Add version file `{{ gem_version_path }}` to Git.
|
133
|
+
command: >-
|
134
|
+
git add {{ gem_version_path }}
|
135
|
+
args:
|
136
|
+
chdir: >-
|
137
|
+
{{ gem_root }}
|
138
|
+
when: gem_current_version != gem_release_version
|
95
139
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
140
|
+
|
141
|
+
- name: >-
|
142
|
+
Commit version file `{{ gem_version_path }}` in Git.
|
143
|
+
command: git commit -m "bump to v{{ gem_release_version }}"
|
144
|
+
args:
|
145
|
+
chdir: >-
|
146
|
+
{{ gem_root }}
|
147
|
+
when: gem_current_version != gem_release_version
|
148
|
+
# /block
|
102
149
|
|
103
150
|
|
104
151
|
- name: >-
|
105
|
-
|
106
|
-
command: git commit -m "bump to v{{ gem_release_version }}"
|
107
|
-
args:
|
108
|
-
chdir: "{{ gem_root }}"
|
109
|
-
when: gem_current_version != gem_release_version
|
110
|
-
|
111
|
-
- name: release with bundler
|
152
|
+
Release with Bundler via `bundle exec rake release`.
|
112
153
|
shell: bundle exec rake release
|
113
154
|
args:
|
114
|
-
chdir:
|
155
|
+
chdir: >-
|
156
|
+
{{ gem_root }}
|
115
157
|
|
116
|
-
|
158
|
+
|
159
|
+
- name: >-
|
160
|
+
Change version to next version `{{ gem_next_version }}`.
|
117
161
|
replace:
|
118
|
-
dest:
|
119
|
-
|
120
|
-
|
162
|
+
dest: >-
|
163
|
+
{{ gem_version_path }}
|
164
|
+
regexp: >-
|
165
|
+
VERSION\s*=\s*["']{{ gem_release_version }}["']
|
166
|
+
replace: >-
|
167
|
+
VERSION = "{{ gem_next_version }}"
|
168
|
+
|
121
169
|
|
122
|
-
- name:
|
123
|
-
|
170
|
+
- name: >-
|
171
|
+
Add next dev version to git.
|
172
|
+
command: >-
|
173
|
+
git add {{ gem_version_path }}
|
124
174
|
args:
|
125
|
-
chdir:
|
175
|
+
chdir: >-
|
176
|
+
{{ gem_root }}
|
177
|
+
|
126
178
|
|
127
|
-
- name:
|
128
|
-
|
179
|
+
- name: >-
|
180
|
+
Commit next dev version.
|
181
|
+
command: >-
|
182
|
+
git commit -m "start {{ gem_next_version }}"
|
129
183
|
args:
|
130
|
-
chdir:
|
184
|
+
chdir: >-
|
185
|
+
{{ gem_root }}
|
131
186
|
|
132
|
-
|
187
|
+
|
188
|
+
- name: >-
|
189
|
+
Push next dev version.
|
133
190
|
command: git push
|
134
191
|
args:
|
135
|
-
chdir:
|
192
|
+
chdir: >-
|
193
|
+
{{ gem_root }}
|
194
|
+
|
136
195
|
|
137
196
|
- debug:
|
138
197
|
msg: >
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nrser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -89,7 +89,7 @@ dependencies:
|
|
89
89
|
version: '0.0'
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: 0.2.
|
92
|
+
version: 0.2.2
|
93
93
|
type: :runtime
|
94
94
|
prerelease: false
|
95
95
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
version: '0.0'
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 0.2.
|
102
|
+
version: 0.2.2
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: nrser
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0.0'
|
110
110
|
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.0.
|
112
|
+
version: 0.0.22
|
113
113
|
type: :runtime
|
114
114
|
prerelease: false
|
115
115
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -119,7 +119,7 @@ dependencies:
|
|
119
119
|
version: '0.0'
|
120
120
|
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version: 0.0.
|
122
|
+
version: 0.0.22
|
123
123
|
- !ruby/object:Gem::Dependency
|
124
124
|
name: nrser-extras
|
125
125
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,12 +195,14 @@ files:
|
|
195
195
|
- exe/qb
|
196
196
|
- lib/qb.rb
|
197
197
|
- lib/qb/ansible.rb
|
198
|
+
- lib/qb/ansible/cmds/playbook.rb
|
198
199
|
- lib/qb/ansible/config_file.rb
|
199
200
|
- lib/qb/ansible/env.rb
|
200
|
-
- lib/qb/ansible/
|
201
|
+
- lib/qb/ansible/module.rb
|
201
202
|
- lib/qb/ansible_module.rb
|
202
203
|
- lib/qb/cli.rb
|
203
204
|
- lib/qb/cli/play.rb
|
205
|
+
- lib/qb/cli/run.rb
|
204
206
|
- lib/qb/errors.rb
|
205
207
|
- lib/qb/options.rb
|
206
208
|
- lib/qb/options/option.rb
|
@@ -693,7 +695,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
693
695
|
version: '0'
|
694
696
|
requirements: []
|
695
697
|
rubyforge_project:
|
696
|
-
rubygems_version: 2.
|
698
|
+
rubygems_version: 2.6.11
|
697
699
|
signing_key:
|
698
700
|
specification_version: 4
|
699
701
|
summary: qb is all about projects. named after everyone's favorite projects.
|
data/lib/qb/ansible/playbook.rb
DELETED