qb 0.1.80 → 0.1.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf03e970df417441d4a76b74959bdcdcb3529083
4
- data.tar.gz: 178dc4067ed6526dae586a5768148009c713cd1a
3
+ metadata.gz: bba65080a724f81277adc9a2a56f8e6ba62c165c
4
+ data.tar.gz: be45317a1716f484e9040ef0830d02cd0439d3f2
5
5
  SHA512:
6
- metadata.gz: 49011243189114d15ce05087b5c8c168df517678240310ede118a9360765089e7a40260b7b283513f8df5568bf0ae3bccc782321e91daac80da74b4502a70051
7
- data.tar.gz: d63066f007fad95b6cdf6152b23888dbd8a60cb189bd0a800507ea59c43475923eb8a8720fcad616fd7a71ed4f47b2654f54ebabc00537cd285fc4b4bdcf918a
6
+ metadata.gz: da5cacdac63f70bd0aa391c97ab289e35f1596cf7fdc7a48ccee6c943a6cf91da896505c18d97339ca7b4e2357a61757e48cdef8c3c2f584c202b7a2e30d0314
7
+ data.tar.gz: e46d091cc8abb4800c1734a6d2f643852dbd7375d6dff4eb1509ae4331b6905f80e9b4bd2242431e6c229ff85566a10d9ceb6d69180020ef522aface45cf6d92
@@ -4,7 +4,7 @@ module QB
4
4
 
5
5
  GEM_NAME = 'qb'
6
6
 
7
- VERSION = "0.1.80"
7
+ VERSION = "0.1.81"
8
8
 
9
9
  MIN_ANSIBLE_VERSION = Gem::Version.new '2.1.2'
10
10
 
@@ -16,6 +16,9 @@ role_library: false
16
16
  # modules
17
17
  role_modules: []
18
18
 
19
+ # filter plugins
20
+ role_filter_plugins: []
21
+
19
22
  # galaxy
20
23
  role_galaxy: false
21
24
  role_author: "{{ git_user_name }}"
@@ -90,5 +90,17 @@ vars:
90
90
 
91
91
  --modules=some_module
92
92
 
93
+ - name: filter_plugins
94
+ description: >-
95
+ Generate `filter_plugins` directory and file boilerplate(s).
96
+ type: array
97
+ examples:
98
+ - |
99
+ Generates a `filter_plugins/filter_plugins.py`
100
+
101
+ qb qb.role roles/owner.new_role --filter-plugins
102
+
103
+
104
+
93
105
  - include: qb.project
94
106
 
@@ -148,4 +148,19 @@
148
148
  - include: module.yml
149
149
  with_items: "{{ role_modules }}"
150
150
  loop_control:
151
- loop_var: role_module
151
+ loop_var: role_module
152
+
153
+
154
+ # Plugins
155
+ # =====================================================================
156
+
157
+ # Filter PLugins
158
+ # ---------------------------------------------------------------------
159
+
160
+ - when: role_filter_plugins|length > 0
161
+ name: >-
162
+ Generate filter plugin files.
163
+ include: >-
164
+ {{ role_path }}/tasks/plugins/filter_plugins.yml
165
+
166
+
@@ -0,0 +1,12 @@
1
+ ---
2
+ # Generate a filter plugin boilerplate file.
3
+
4
+ - name: >-
5
+ Generate `filter_plugins/{{ name }}_filters.py` filter plugin file.
6
+ template:
7
+ src: >-
8
+ {{ role_path }}/templates/filter_plugins/filter_plugin.py.j2
9
+ dest: >-
10
+ {{ role_dest }}/filter_plugins/{{ name }}_plugins.py
11
+ force: >-
12
+ {{ role_force }}
@@ -0,0 +1,38 @@
1
+ ---
2
+ # Generate filter plugins boilerplate(s).
3
+
4
+ - name: >-
5
+ Create `filter_plugins` directory.
6
+ file:
7
+ dest: >-
8
+ {{ role_dest }}/filter_plugins
9
+ state: directory
10
+
11
+ - name: >-
12
+ Figure out if we received a single truthy value that indicates we should
13
+ use the default filter plugin name.
14
+ set_fact:
15
+ role_filter_plugins_default: >-
16
+ {{
17
+ role_filter_plugins|length == 1 and
18
+ role_filter_plugins[0].lower() in ['1', 'true', 't', 'yes', 'y']
19
+ }}
20
+
21
+ - when: role_filter_plugins_default
22
+ name: >-
23
+ Create default `filter_plugins/{{ role_role_name }}_plugins.py`
24
+ include: >-
25
+ {{ role_path }}/tasks/plugins/_filter_plugin.yml
26
+ vars:
27
+ name: >-
28
+ {{ role_role_name }}
29
+
30
+ - when: not role_filter_plugins_default
31
+ name: >-
32
+ Create each of filter plugins sepcified in `role_filter_plugins`.
33
+ with_items: >-
34
+ {{ role_filter_plugins }}
35
+ loop_control:
36
+ loop_var: name
37
+ include: >-
38
+ {{ role_path }}/tasks/plugins/_filter_plugin.yml
@@ -0,0 +1,67 @@
1
+ # `{{ name }}` Ansible/Jinja2 Filters for `{{ role_role_name }}` Role.
2
+ #
3
+
4
+
5
+ # Imports
6
+ # ============================================================================
7
+
8
+ # Make Python 2 more Python 3-like
9
+ from __future__ import (absolute_import, division, print_function)
10
+ __metaclass__ = type
11
+
12
+ from ansible.errors import AnsibleError
13
+
14
+ # Some imports you may often want:
15
+ # import sys
16
+ # improt os
17
+ # import subprocess
18
+ # import yaml
19
+ # improt json
20
+
21
+
22
+ # Functions
23
+ # ============================================================================
24
+ #
25
+ # Suggested practice seems to be to define each filter as a top-level function
26
+ # then expose them via the `FilterModule#filters` method below.
27
+ #
28
+
29
+ def my_{{ name }}_filter(subject, *args, **kwds):
30
+ '''
31
+ TODO doc me!
32
+ '''
33
+
34
+ raise NotImplementedError("Implement me!")
35
+
36
+
37
+ # Module
38
+ # ============================================================================
39
+ #
40
+ # How Ansible finds the filters. It looks like it gets instantiated with
41
+ # no arguments, at least most of the time, so it pretty much just serves as
42
+ # a well-known name to obtain the function references from.
43
+ #
44
+ class FilterModule(object):
45
+ '''
46
+ `{{ name }}` Ansible/Jinja2 filters for `{{ role_role_name }}` role.
47
+ '''
48
+
49
+ def filters(self):
50
+ return {
51
+ 'my_{{ name }}_filter': my_{{ name }}_filter,
52
+ }
53
+ # filters()
54
+ # FilterModule
55
+
56
+
57
+ # Testing
58
+ # ============================================================================
59
+ #
60
+ # This is not standard Ansible-ness - they use `unittest.TestCase` in separate
61
+ # files - but `doctest` seemed like a really easy way to add and run tests
62
+ # for these typically simple functions.
63
+ #
64
+ if __name__ == '__main__':
65
+ import doctest
66
+ doctest.testmod()
67
+
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.80
4
+ version: 0.1.81
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser
@@ -621,9 +621,12 @@ files:
621
621
  - roles/qb.role/meta/qb.yml
622
622
  - roles/qb.role/tasks/main.yml
623
623
  - roles/qb.role/tasks/module.yml
624
+ - roles/qb.role/tasks/plugins/_filter_plugin.yml
625
+ - roles/qb.role/tasks/plugins/filter_plugins.yml
624
626
  - roles/qb.role/templates/.gitkeep
625
627
  - roles/qb.role/templates/README.md.j2
626
628
  - roles/qb.role/templates/defaults/main.yml.j2
629
+ - roles/qb.role/templates/filter_plugins/filter_plugin.py.j2
627
630
  - roles/qb.role/templates/handlers/main.yml.j2
628
631
  - roles/qb.role/templates/library/module.rb.j2
629
632
  - roles/qb.role/templates/meta/main.yml.j2