qb 0.1.80 → 0.1.81
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/qb/version.rb +1 -1
- data/roles/qb.role/defaults/main.yml +3 -0
- data/roles/qb.role/meta/qb.yml +12 -0
- data/roles/qb.role/tasks/main.yml +16 -1
- data/roles/qb.role/tasks/plugins/_filter_plugin.yml +12 -0
- data/roles/qb.role/tasks/plugins/filter_plugins.yml +38 -0
- data/roles/qb.role/templates/filter_plugins/filter_plugin.py.j2 +67 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bba65080a724f81277adc9a2a56f8e6ba62c165c
|
4
|
+
data.tar.gz: be45317a1716f484e9040ef0830d02cd0439d3f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da5cacdac63f70bd0aa391c97ab289e35f1596cf7fdc7a48ccee6c943a6cf91da896505c18d97339ca7b4e2357a61757e48cdef8c3c2f584c202b7a2e30d0314
|
7
|
+
data.tar.gz: e46d091cc8abb4800c1734a6d2f643852dbd7375d6dff4eb1509ae4331b6905f80e9b4bd2242431e6c229ff85566a10d9ceb6d69180020ef522aface45cf6d92
|
data/lib/qb/version.rb
CHANGED
data/roles/qb.role/meta/qb.yml
CHANGED
@@ -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.
|
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
|