qb 0.3.13 → 0.3.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/doc/getting_started.md +2 -0
  3. data/doc/qb_roles.md +4 -109
  4. data/doc/qb_roles/metadata.md +221 -0
  5. data/exe/qb +23 -11
  6. data/lib/qb.rb +1 -3
  7. data/lib/qb/cli.rb +97 -85
  8. data/lib/qb/options.rb +6 -6
  9. data/lib/qb/role/default_dir.rb +28 -28
  10. data/lib/qb/util.rb +3 -2
  11. data/lib/qb/version.rb +1 -1
  12. data/qb.gemspec +22 -9
  13. data/roles/nrser.rbenv_gem/tasks/main.yml +3 -3
  14. data/roles/qb/gem/build/defaults/main.yml +12 -0
  15. data/roles/{qb.build_gem → qb/gem/build}/meta/main.yml +0 -0
  16. data/roles/qb/gem/build/meta/qb.yml +42 -0
  17. data/roles/qb/gem/build/tasks/main.yml +61 -0
  18. data/roles/{qb.install_gem → qb/gem/install}/defaults/main.yml +1 -1
  19. data/roles/qb/gem/install/meta/main.yml +17 -0
  20. data/roles/{qb.install_gem → qb/gem/install}/meta/qb.yml +5 -2
  21. data/roles/{qb.install_gem → qb/gem/install}/tasks/main.yml +0 -0
  22. data/roles/qb/git/ignore/files/gitignore/Eagle.gitignore +9 -1
  23. data/roles/qb/git/ignore/files/gitignore/Global/Eclipse.gitignore +3 -0
  24. data/roles/qb/git/ignore/files/gitignore/Go.gitignore +1 -0
  25. data/roles/qb/git/ignore/files/gitignore/Node.gitignore +2 -0
  26. data/roles/qb/git/ignore/files/gitignore/Python.gitignore +7 -19
  27. data/roles/qb/git/ignore/files/gitignore/Python/Packaging.gitignore +25 -0
  28. data/roles/qb/git/ignore/files/gitignore/Ruby.gitignore +15 -5
  29. data/roles/qb/git/ignore/files/gitignore/Umbraco.gitignore +2 -2
  30. data/roles/qb/git/ignore/files/gitignore/VisualStudio.gitignore +4 -0
  31. data/roles/qb/role/qb/templates/qb.yml.j2 +19 -39
  32. data/roles/qb/role/templates/README.md.j2 +1 -1
  33. data/roles/qb/role/templates/defaults/main.yml.j2 +6 -1
  34. data/roles/qb/role/templates/filter_plugins/filters.py.j2 +5 -5
  35. data/roles/qb/role/templates/handlers/main.yml.j2 +3 -1
  36. data/roles/qb/role/templates/meta/main.yml.j2 +4 -2
  37. data/roles/qb/role/templates/tasks/main.yml.j2 +3 -1
  38. data/roles/qb/role/templates/vars/main.yml.j2 +3 -1
  39. metadata +43 -34
  40. data/roles/qb.build_gem/defaults/main.yml +0 -2
  41. data/roles/qb.build_gem/tasks/main.yml +0 -27
  42. data/roles/qb.install_gem/meta/main.yml +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5303c21f22149b8a6ae1bccb85b6ab0c298eabe5
4
- data.tar.gz: 192ae9200cbcc58a3ac5accc4fbd46f13f08a2f5
3
+ metadata.gz: b5043907ea8b17d2fd4f2a4d5ad146e4a3c13a3a
4
+ data.tar.gz: ddec830eccaae82a55107bae595e81ad93948deb
5
5
  SHA512:
6
- metadata.gz: 51454accde596eab43cd5311cab5eb302b56dfe443694817486261cc56a1da02eff5db83a2ea53668eb2b0efaa344b02c5c81fbee41de7bffec280e348d09aa4
7
- data.tar.gz: 59244ecbf50690bee88196083a711716d4ed4aca587e465d61531977b801a37d213db82a0b763a7c47800a384074bb92eacd9eaaabf83a074d248d1a94ef4d4c
6
+ metadata.gz: a609942e5b5ef542c8a48d8911defea06a1b33b95d4d2bf1c84d89e8a8871b9416647f03bcef1363bc7d67aac0a22dc696acb2493de9abcbf7c2127c8ad985ae
7
+ data.tar.gz: 5636e6d6a03a0410c2b8233165b39f934fd63b8ff1e86c7aa897aead9220dcaadd437aba7b682bec83cae73a20754a95900288bb669cdb7f7c74d62b5619988d
@@ -82,3 +82,5 @@ Usage
82
82
  -----------------------------------------------------------------------------
83
83
 
84
84
  Yeah TODO someday maybe.
85
+
86
+ For now just go read about {file:doc/qb_roles.md QB Roles}, that's the important part.
@@ -27,11 +27,11 @@ This will generate a `DIRECTORY/meta/qb.yml` file with common keys and values fo
27
27
 
28
28
 
29
29
  > **Example**
30
- >
30
+ >
31
31
  > To create a new role named `me/my_new_role` at `./roles/me/my_new_role` run
32
- >
32
+ >
33
33
  > qb role/qb ./roles/me/my_new_role
34
- >
34
+ >
35
35
 
36
36
 
37
37
  As always, you can check out the `qb/role/qb` options via
@@ -47,109 +47,4 @@ QB metadata is a dictionary structure mapping string keys to mixed values that p
47
47
 
48
48
  **_A role is a QB role if (and only if) it has QB metadata._**
49
49
 
50
-
51
- ### Metadata File Location and Format ###
52
-
53
- Metadata is provided via one of two file paths (relative to the role's root directory `<role_path>`):
54
-
55
- 1. `<role_path>/meta/qb.yml`
56
-
57
- Metadata provided in static [YAML][] format. This is default method and should be used unless the metadata needs to be created dynamically on each role run (in ways not covered by the value options themselves).
58
-
59
- 2. `<role_path>/meta/qb` (*executable*)
60
-
61
- Metadata provided by running an executable. The file must be marked as executable for the current system user.
62
-
63
- The executable is fed a [JSON][] encoding of the options collected form the CLI `run` command on `STDIN`.
64
-
65
- The executable should write the computed metadata to `STDOUT` in [YAML][] or [JSON][] format and exit successfully.
66
-
67
- > QB uses the [Ruby YAML library][] to parse the result, which accepts `JSON` as well.
68
-
69
- If `meta/qb` can't compute metadata, it should exit with an error status and write any error feedback to `STDERR` (though feedback might not be nicely relayed to the CLI user yet).
70
-
71
- Right now, please don't provide both. At some point I'll handle this case, probably by raising an error, but for the moment I'm not sure how it's (not) handled.
72
-
73
- > Role metadata is loaded by the {QB::Role#load_meta} function, which is called on demand when accessing the {QB::Role#meta} attribute.
74
-
75
-
76
- <!-- References & Further Reading: -->
77
-
78
- [YAML]: http://yaml.org/
79
- [JSON]: https://www.json.org/
80
- [Ruby YAML library]: http://ruby-doc.org/stdlib/libdoc/yaml/rdoc/YAML.html
81
-
82
- ******************************************************************************
83
-
84
-
85
- ### Conventions ###
86
-
87
- #### `null` and Missing Metadata Values ####
88
-
89
- **_QB treats keys set to `null` and missing keys identically._**
90
-
91
- `null` is the same as not being there at all. I feel like this simplifies things. Departures from this behavior are considered bugs.
92
-
93
- Generally, to tell QB *not* to do something assign `false`.
94
-
95
- ******************************************************************************
96
-
97
-
98
- ### Recognized Metadata Keys ###
99
-
100
- This section lays out recognized keys and their acceptable values.
101
-
102
- All keys are optional unless otherwise stated, though if present their values must be acceptable or errors will be raised when you try to run the role.
103
-
104
-
105
- #### default_dir ####
106
-
107
- Define a *strategy* (or list of *strategies*) to find a suitable default for
108
- the `DIRECTORY` command line argument - which becomes the `qb_dir` variable in Ansible - when running a QB role.
109
-
110
- > The role's `default_dir` metadata value is converted into a directory path in {QB::Role#default_dir}.
111
-
112
- In brief, the *strategy* value can be:
113
-
114
- 1. `null` (or missing)
115
- - `DIRECTORY` arg must be provided on CLI.
116
- 2. `false`
117
- - No `DIRECTORY` arg is used and none will be accepted.
118
- 3. `cwd`
119
- - Use directory `run` command was run in.
120
- 4. `git_root`
121
- - Use the root of the Git repo working directory is a part of.
122
- 5. `{exe: <path:string>}`
123
- - Run the executable at `path` and use output.
124
- 6. `{find_up: <rel_path:string>}`
125
- - Walk up directories from current looking for `rel_path`.
126
- 7. `{from_role: <role:string>}`
127
- - Use the value from another role.
128
- 8. `Array`
129
- - Try each strategy until one works.
130
-
131
- See {file:doc/qb_roles/metadata/default_dir.md} for strategy details and examples.
132
-
133
-
134
- #### var_prefix ####
135
-
136
- Declare prefix to be prepended to role CLI option names to form their Ansible variable name.
137
-
138
- Because all variables are pretty much global in Ansible, you really want to prefix all your variables names to try and achieve uniqueness. the way i've been doing that is to prefix them with the 'namespaceless' part of the role name.
139
-
140
- For example, if you have a role named `qb.project`, the 'namespace' would be `qb` and the 'namespaceless' part would be `project`. it has been my convention to then name the role variables `project_*`, like `project_owner`, `project_name`, etc..
141
-
142
- `var_prefix` therefore defaults to the 'namespaceless' part of the role name, so that a call like
143
-
144
- qb qb.project --owner=nrser --name=blah
145
-
146
- will pass variables
147
-
148
- project_owner: "nrser"
149
- project_name: "blah"
150
-
151
- to the `qb.project` role.
152
-
153
- However, this setting allows you to specify an alternative prefix.
154
-
155
- If this is set to `null` (or missing) the default behavior will be used.
50
+ See {file:doc/qb_roles/metadata.md QB Role Metadata} for details.
@@ -0,0 +1,221 @@
1
+ QB Role Metadata
2
+ ==============================================================================
3
+
4
+ QB metadata is a dictionary structure mapping string keys to mixed values that provides QB-specific role configuration.
5
+
6
+ **_A role is a QB role if (and only if) it has QB metadata._**
7
+
8
+
9
+ File Location and Format
10
+ ------------------------------------------------------------------------------
11
+
12
+ Metadata is provided via one of two file paths (relative to the role's root directory `<role_path>`):
13
+
14
+ 1. `<role_path>/meta/qb.yml`
15
+
16
+ Metadata provided in static [YAML][] format. This is default method and should be used unless the metadata needs to be created dynamically on each role run (in ways not covered by the value options themselves).
17
+
18
+ 2. `<role_path>/meta/qb` (*executable*)
19
+
20
+ Metadata provided by running an executable. The file must be marked as executable for the current system user.
21
+
22
+ The executable is fed a [JSON][] encoding of the options collected form the CLI `run` command on `STDIN`.
23
+
24
+ The executable should write the computed metadata to `STDOUT` in [YAML][] or [JSON][] format and exit successfully.
25
+
26
+ > QB uses the [Ruby YAML library][] to parse the result, which accepts `JSON` as well.
27
+
28
+ If `meta/qb` can't compute metadata, it should exit with an error status and write any error feedback to `STDERR` (though feedback might not be nicely relayed to the CLI user yet).
29
+
30
+ Right now, please don't provide both. At some point I'll handle this case, probably by raising an error, but for the moment I'm not sure how it's (not) handled.
31
+
32
+ > Role metadata is loaded by the {QB::Role#load_meta} function, which is called on demand when accessing the {QB::Role#meta} attribute.
33
+
34
+
35
+ <!-- References & Further Reading: -->
36
+
37
+ [YAML]: http://yaml.org/
38
+ [JSON]: https://www.json.org/
39
+ [Ruby YAML library]: http://ruby-doc.org/stdlib/libdoc/yaml/rdoc/YAML.html
40
+
41
+
42
+ -----------------------------------------------------------------------------
43
+ Conventions
44
+ -----------------------------------------------------------------------------
45
+
46
+ ### `null` and Missing Metadata Values ###
47
+
48
+ **_QB treats keys set to `null` and missing keys identically._**
49
+
50
+ `null` is the same as not being there at all. I feel like this simplifies things. Departures from this behavior are considered bugs.
51
+
52
+ Generally, to tell QB *not* to do something assign `false`.
53
+
54
+
55
+ -----------------------------------------------------------------------------
56
+ Keys and Values
57
+ -----------------------------------------------------------------------------
58
+
59
+ This section lays out recognized keys and their acceptable values.
60
+
61
+ All keys are optional and default to `null`/`nil` unless otherwise stated, though if present their values must be acceptable or errors will be raised when you try to run the role.
62
+
63
+ ******************************************************************************
64
+
65
+
66
+ ### `ansible_options` ###
67
+
68
+ Type: `map`
69
+
70
+ Options to pass through to `ansible-playbook` command.
71
+
72
+ ******************************************************************************
73
+
74
+
75
+ ### `default_dir` ###
76
+
77
+ Type: `null | boolean | string | map | list`
78
+
79
+ Define a *strategy* (or list of *strategies*) to find a suitable default for
80
+ the `DIRECTORY` command line argument - which becomes the `qb_dir` variable in Ansible - when running a QB role.
81
+
82
+ > The role's `default_dir` metadata value is converted into a directory path in {QB::Role#default_dir}.
83
+
84
+ In brief, the *strategy* value can be:
85
+
86
+ 1. `null` (or missing)
87
+ - `DIRECTORY` arg must be provided on CLI.
88
+ 2. `false`
89
+ - No `DIRECTORY` arg is used and none will be accepted.
90
+ 3. `cwd`
91
+ - Use directory `run` command was run in.
92
+ 4. `git_root`
93
+ - Use the root of the Git repo working directory is a part of.
94
+ 5. `{exe: <path:string>}`
95
+ - Run the executable at `path` and use output.
96
+ 6. `{find_up: <rel_path:string>}`
97
+ - Walk up directories from current looking for `rel_path`.
98
+ 7. `{from_role: <role:string>}`
99
+ - Use the value from another role.
100
+ 8. `Array`
101
+ - Try each strategy until one works.
102
+
103
+ See {file:doc/qb_roles/metadata/default_dir.md} for strategy details and examples.
104
+
105
+ ******************************************************************************
106
+
107
+
108
+ ### `default_user` ###
109
+
110
+ Type: `string`
111
+
112
+ User to [become][Ansible become] for the playbook.
113
+
114
+ <!-- References & Further Reading: -->
115
+
116
+ [Ansible become]: http://docs.ansible.com/ansible/latest/become.html
117
+
118
+ ******************************************************************************
119
+
120
+
121
+ ### `description` ###
122
+
123
+ Type: `string`
124
+
125
+ Pretty self-descriptive. Shown in the role's `help` output and other relevant places.
126
+
127
+ Keep it short. Add a `README.md` file to the role's root if you need to write more. I promise we'll use that somehow someday.
128
+
129
+ **Example**
130
+
131
+ > description: Builds a gem using `gem build` command
132
+
133
+ ******************************************************************************
134
+
135
+
136
+ ### `mkdir` ###
137
+
138
+ Type: `boolean`
139
+ Default: `true`
140
+
141
+ When `true`, QB will create the `DIRECTORY` argument to `qb run ROLE DIRECTORY` *before* kicking off the Ansible playbook.
142
+
143
+ This is pretty much a legacy thing: it seemed like a really good idea at the start of everything and then turned out to not really be.
144
+
145
+ The default is `true` for said legacy reasons - there may still be roles hanging around that depend on it - but `qb/role/qb` creates `meta/qb.yml` files that set it to `false`, but I'd like to change the default to `false` when I get the time, so **please don't depend on the default value**.
146
+
147
+ ******************************************************************************
148
+
149
+
150
+ ### `options` ###
151
+
152
+ Type: `list`
153
+
154
+ Options to accept via the `qb run` CLI command and pass to the role as Ansible vars.
155
+
156
+ **Example**
157
+
158
+ > options:
159
+ > - name: example
160
+ > description: an example of a variable.
161
+ > required: false
162
+ > type: boolean
163
+ > short: e
164
+
165
+ ******************************************************************************
166
+
167
+
168
+ ### `requirements` ###
169
+
170
+ Type: `map`
171
+
172
+ Specify what the roles needs to work.
173
+
174
+ Work in progress... right now, only `requirements.gems.qb` does anything, and that checks that the version of QB running satisfies the version spec provided (RubyGems-style specs).
175
+
176
+ This can help you prevent annoying or confusing errors when a role fails because it's using newer features than the version trying to run it.
177
+
178
+ **Example** Make sure we're running QB `0.3.X`
179
+
180
+ > requirements:
181
+ > gems:
182
+ > qb: ~> 0.3.0
183
+
184
+ ******************************************************************************
185
+
186
+
187
+ ### `save_options` ###
188
+
189
+ Type: `boolean`
190
+
191
+ When `true` saves options to a `.qb-options.yml` file so they can be repeated in subsequent runs.
192
+
193
+ Good idea but kinda shit feature that I want to replace with state stuff.
194
+
195
+ ******************************************************************************
196
+
197
+
198
+ ### `var_prefix` ###
199
+
200
+ Type: `string`
201
+
202
+ Declare prefix to be prepended to role CLI option names to form their Ansible variable name.
203
+
204
+ Because all variables are pretty much global in Ansible, you really want to prefix all your variables names to try and achieve uniqueness. the way i've been doing that is to prefix them with the 'namespaceless' part of the role name.
205
+
206
+ For example, if you have a role named `qb.project`, the 'namespace' would be `qb` and the 'namespaceless' part would be `project`. it has been my convention to then name the role variables `project_*`, like `project_owner`, `project_name`, etc..
207
+
208
+ `var_prefix` therefore defaults to the 'namespaceless' part of the role name, so that a call like
209
+
210
+ qb qb.project --owner=nrser --name=blah
211
+
212
+ will pass variables
213
+
214
+ project_owner: "nrser"
215
+ project_name: "blah"
216
+
217
+ to the `qb.project` role.
218
+
219
+ However, this setting allows you to specify an alternative prefix.
220
+
221
+ If this is set to `null` (or missing) the default behavior will be used.
data/exe/qb CHANGED
@@ -1,5 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+
4
+ # Requirements
5
+ # =======================================================================
6
+
7
+ # Stdlib
8
+ # -----------------------------------------------------------------------
9
+
10
+ # Deps
11
+ # -----------------------------------------------------------------------
12
+
13
+ # Project / Package
14
+ # -----------------------------------------------------------------------
15
+
3
16
  require 'pathname'
4
17
  require 'pp'
5
18
  require 'yaml'
@@ -7,30 +20,26 @@ require 'json'
7
20
  require 'fileutils'
8
21
  require 'thread'
9
22
 
23
+ require 'nrser'
10
24
  require 'cmds'
11
25
 
12
26
  require 'qb'
13
27
 
14
- require 'nrser/refinements'
15
- using NRSER
16
28
 
29
+ # Refinements
30
+ # =======================================================================
17
31
 
18
- DEBUG_ARGS = ['-D', '--DEBUG']
32
+ using NRSER
19
33
 
20
34
 
21
- def set_debug! args
22
- if DEBUG_ARGS.any? {|arg| args.include? arg}
23
- QB::Util::Logging.setup level: :debug
24
- DEBUG_ARGS.each {|arg| args.delete arg}
25
- end
26
- end
27
-
35
+ # Definitions
36
+ # =======================================================================
28
37
 
29
38
  def main args
30
39
  Thread.current.name = 'main'
31
40
  logger = SemanticLogger['qb/exe/qb#main']
32
41
 
33
- set_debug! args
42
+ QB::CLI.set_debug! args
34
43
  logger.debug args: args
35
44
 
36
45
  QB.check_ansible_version
@@ -65,4 +74,7 @@ def main args
65
74
  end
66
75
 
67
76
 
77
+ # Execution
78
+ # ============================================================================
79
+
68
80
  main(ARGV) # if __FILE__ == $0 # doesn't work with gem stub or something?
data/lib/qb.rb CHANGED
@@ -6,6 +6,7 @@
6
6
 
7
7
  # Deps
8
8
  # -----------------------------------------------------------------------
9
+ require 'nrser'
9
10
  require 'nrser/extras'
10
11
 
11
12
  # Project / Package
@@ -19,10 +20,7 @@ require 'qb/path'
19
20
  # Refinements
20
21
  # =======================================================================
21
22
 
22
- require 'nrser/refinements'
23
23
  using NRSER
24
-
25
- require 'nrser/refinements/types'
26
24
  using NRSER::Types
27
25
 
28
26