Skip to content

Commit cca0fc8

Browse files
author
Bill Meek
committed
filters/modules: update git_log_info, add sample module
1 parent 6113fbf commit cca0fc8

File tree

4 files changed

+35
-26
lines changed

4 files changed

+35
-26
lines changed

filter_plugins/git_log_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
'''
77
git log filter. Use this to view documentation:
8-
ansible-doc -t filter mythtv.general.git_log_info
8+
ansible-doc -t filter git_log_info
99
'''
1010

1111

filter_plugins/git_log_info.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
DOCUMENTATION:
3-
name: mythtv.general.git_log_info
3+
name: git_log_info
44
author: Bill Meek
55
short_description: Get some git info about the playbook or a single file
66
description:
@@ -28,11 +28,11 @@ DOCUMENTATION:
2828
EXAMPLES: |
2929
- name: "get a file's short SHA1, author and timestamp"
3030
ansible.builtin.debug:
31-
var: "{{ some_file_name | mythtv.general.git_log_info('full') }}"
31+
var: "{{ some_file_name | git_log_info('full') }}"
3232
3333
- name: "get the long SHA1 for the MythTV playbook (HEAD)"
3434
ansible.builtin.debug:
35-
var: "{{ 'HEAD' | mythtv.general.git_log_info('playbook') }}"
35+
var: "{{ 'HEAD' | git_log_info('playbook') }}"
3636
3737
RETURN:
3838
_output:

library/sample.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,33 @@ def run_module():
2222
''' Update with real module information. '''
2323

2424
module_args = {
25-
"api_port": {"type": 'int', "required": False, "default": 6544},
26-
"host": {"type": 'str', "required": False, "default": 'localhost'},
25+
'api_port': {
26+
'type': 'int',
27+
'required': False,
28+
'default': 6544
29+
},
30+
'host': {
31+
'type': 'str',
32+
'required': False,
33+
'default': 'localhost'
34+
},
2735
}
2836

29-
result = {'changed': False}
30-
31-
module = AnsibleModule(
32-
argument_spec=module_args,
33-
supports_check_mode=True
34-
)
35-
3637
module = AnsibleModule(argument_spec=module_args, supports_check_mode=True)
3738

39+
result = {'changed': False}
40+
3841
# In the check mode, really a sanity test of this module.
3942
if module.check_mode:
40-
result['changed'] = True
43+
result['comment'] = 'check mode ran'
4144
module.exit_json(**result)
4245

4346
# Do something(s) here and resurn result information.
4447

48+
result['changed'] = True
4549
result['comment'] = 'library/sample.py ran'
4650
result['host'] = module.params['host']
47-
result['port'] = module.params['api_port']
51+
result['api_port'] = module.params['api_port']
4852

4953
module.exit_json(**result)
5054

library/sample.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
DOCUMENTATION:
3-
module: mythtv.general.sample
3+
module: sample
44
plugin_type: module
55
author: Bill Meek
66
short_description: Enter something short here
77
description:
88
- Enter the real long description here.
99
options:
10-
some_option:
11-
description: some need for an integer
10+
api_port:
11+
description: some integer
1212
default: 1234
1313
type: int
1414
required: true
@@ -20,28 +20,33 @@ DOCUMENTATION:
2020

2121
EXAMPLES: |
2222
- name: do something
23-
mythtv.general.sample:
23+
sample:
2424
2525
- name: do something with some parameters
26-
mythtv.general.sample:
26+
sample:
2727
host: some_hostname
28-
some_option: 5678
28+
api_port: 5678
2929
3030
RETURN:
3131
changed:
3232
description: if true, the attempt worked
3333
type: bool
3434
returned: always
3535
sample: true
36-
failed:
37-
description: common task message
38-
type: bool
39-
returned: always
40-
sample: false
4136
comment:
4237
description: explanatory of result text
4338
type: str
4439
returned: always
4540
sample: "Success, all done!"
41+
host:
42+
description: some hostname
43+
type: str
44+
returned: always, except in check mode
45+
sample: "hostname"
46+
api_port:
47+
description: port number
48+
type: int
49+
returned: always, except in check mode
50+
sample: "3456"
4651

4752
# vim: set expandtab tabstop=2 shiftwidth=2 smartindent noautoindent colorcolumn=80:

0 commit comments

Comments
 (0)