Skip to content

Commit a58a75f

Browse files
committed
fixup add specs/docs for filter plugins
1 parent 61e0793 commit a58a75f

File tree

4 files changed

+81
-2
lines changed

4 files changed

+81
-2
lines changed

filter_plugins/core.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ def file_exists(stat_result):
4747

4848

4949
def parse_a2query(stdout):
50-
"""Parse out the first column from a2query STDOUT lines."""
50+
"""Parse the first column from a2query STDOUT lines."""
5151
if not stdout:
5252
return stdout
5353

5454
return [line.split(" ")[0] for line in stdout]
5555

5656

5757
def to_vhost_filename(vhost):
58-
"""Turn vhost into filename."""
58+
"""Turn apache_vhost item(dict) into a filename."""
5959
try:
6060
priority = int(vhost.get("priority", 25))
6161
if "ssl" in vhost and vhost["ssl"]:

filter_plugins/file_exists.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
DOCUMENTATION:
3+
name: file_exists
4+
version_added: "1.0"
5+
short_description: evaluate results of stat
6+
description:
7+
- Evaluate results of ansible.builtin.stat.
8+
- Returns True if file is either regular file or symlink.
9+
positional: _input
10+
options:
11+
_input:
12+
description: Value returned by ansible.builtin.stat.
13+
type: dict
14+
required: true
15+
16+
EXAMPLES: |
17+
- name: Check if SSL certificate exists
18+
ansible.builtin.stat:
19+
path: "/path/to/ssl.cert"
20+
register: _stat_ssl_cert
21+
22+
- name: Does SSL cert file exist?
23+
ansible.builtin.debug:
24+
msg: "No, it does not"
25+
when: >
26+
_stat_ssl_cert is not defined
27+
or _stat_ssl_cert | file_exists is false
28+
29+
RETURN:
30+
_value:
31+
description: True if file is either regular file or symlink.
32+
type: bool

filter_plugins/parse_a2query.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
DOCUMENTATION:
3+
name: parse_a2query
4+
version_added: "1.0"
5+
short_description: parse first column from a2query output
6+
description:
7+
- Parse the first column from a2query STDOUT lines.
8+
positional: _input
9+
options:
10+
_input:
11+
description: a2query's STDOUT.
12+
type: str
13+
required: true
14+
15+
EXAMPLES: |
16+
- name: Parse first column from a2query's stdout lines.
17+
ansible.builtin.set_fact:
18+
myvar: "{{ _apache_cmd_a2q.stdout_lines | parse_a2query }}"
19+
20+
RETURN:
21+
_value:
22+
description: Fist column of a2query as a list.
23+
type: list
24+
elements: str

filter_plugins/to_vhost_filename.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
DOCUMENTATION:
3+
name: to_vhost_filename
4+
version_added: "1.0"
5+
short_description: turn apache_vhost item into filename.
6+
description:
7+
- Assemble filename(used to store vhost config) from item in apache_vhosts.
8+
positional: _input
9+
options:
10+
_input:
11+
description: apache_vhost item.
12+
type: dict
13+
required: true
14+
15+
EXAMPLES: |
16+
- name: Get virtual host's filename.
17+
ansible.builtin.set_fact:
18+
apache_vhost_filename: "{{ apache_vhosts[0] | to_vhost_filename }}"
19+
20+
RETURN:
21+
_value:
22+
description: filename of given virtual host.
23+
type: str

0 commit comments

Comments
 (0)