Skip to content

Commit

Permalink
normalize docs in callback plugins (#9455)
Browse files Browse the repository at this point in the history
* normalize docs in callback plugins

Normalize doc blocks for plugins

* Apply suggestions from code review

Co-authored-by: Felix Fontein <[email protected]>

---------

Co-authored-by: Felix Fontein <[email protected]>
  • Loading branch information
russoz and felixfontein authored Dec 29, 2024
1 parent 29e3226 commit d887930
Show file tree
Hide file tree
Showing 26 changed files with 1,536 additions and 1,547 deletions.
69 changes: 35 additions & 34 deletions plugins/callback/cgroup_memory_recap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,41 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

DOCUMENTATION = '''
author: Unknown (!UNKNOWN)
name: cgroup_memory_recap
type: aggregate
requirements:
- whitelist in configuration
- cgroups
short_description: Profiles maximum memory usage of tasks and full execution using cgroups
description:
- This is an ansible callback plugin that profiles maximum memory usage of ansible and individual tasks, and displays a recap at the end using cgroups.
notes:
- Requires ansible to be run from within a cgroup, such as with C(cgexec -g memory:ansible_profile ansible-playbook ...).
- This cgroup should only be used by ansible to get accurate results.
- To create the cgroup, first use a command such as C(sudo cgcreate -a ec2-user:ec2-user -t ec2-user:ec2-user -g memory:ansible_profile).
options:
max_mem_file:
required: true
description: Path to cgroups C(memory.max_usage_in_bytes) file. Example V(/sys/fs/cgroup/memory/ansible_profile/memory.max_usage_in_bytes).
type: str
env:
- name: CGROUP_MAX_MEM_FILE
ini:
- section: callback_cgroupmemrecap
key: max_mem_file
cur_mem_file:
required: true
description: Path to C(memory.usage_in_bytes) file. Example V(/sys/fs/cgroup/memory/ansible_profile/memory.usage_in_bytes).
type: str
env:
- name: CGROUP_CUR_MEM_FILE
ini:
- section: callback_cgroupmemrecap
key: cur_mem_file
'''
DOCUMENTATION = r"""
author: Unknown (!UNKNOWN)
name: cgroup_memory_recap
type: aggregate
requirements:
- whitelist in configuration
- cgroups
short_description: Profiles maximum memory usage of tasks and full execution using cgroups
description:
- This is an Ansible callback plugin that profiles maximum memory usage of Ansible and individual tasks, and displays a
recap at the end using cgroups.
notes:
- Requires ansible to be run from within a C(cgroup), such as with C(cgexec -g memory:ansible_profile ansible-playbook ...).
- This C(cgroup) should only be used by Ansible to get accurate results.
- To create the C(cgroup), first use a command such as C(sudo cgcreate -a ec2-user:ec2-user -t ec2-user:ec2-user -g memory:ansible_profile).
options:
max_mem_file:
required: true
description: Path to cgroups C(memory.max_usage_in_bytes) file. Example V(/sys/fs/cgroup/memory/ansible_profile/memory.max_usage_in_bytes).
type: str
env:
- name: CGROUP_MAX_MEM_FILE
ini:
- section: callback_cgroupmemrecap
key: max_mem_file
cur_mem_file:
required: true
description: Path to C(memory.usage_in_bytes) file. Example V(/sys/fs/cgroup/memory/ansible_profile/memory.usage_in_bytes).
type: str
env:
- name: CGROUP_CUR_MEM_FILE
ini:
- section: callback_cgroupmemrecap
key: cur_mem_file
"""

import time
import threading
Expand Down
22 changes: 11 additions & 11 deletions plugins/callback/context_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

DOCUMENTATION = '''
author: Unknown (!UNKNOWN)
name: context_demo
type: aggregate
short_description: demo callback that adds play/task context
description:
- Displays some play and task context along with normal output.
- This is mostly for demo purposes.
requirements:
- whitelist in configuration
'''
DOCUMENTATION = r"""
author: Unknown (!UNKNOWN)
name: context_demo
type: aggregate
short_description: demo callback that adds play/task context
description:
- Displays some play and task context along with normal output.
- This is mostly for demo purposes.
requirements:
- whitelist in configuration
"""

from ansible.plugins.callback import CallbackBase

Expand Down
28 changes: 14 additions & 14 deletions plugins/callback/counter_enabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

DOCUMENTATION = '''
author: Unknown (!UNKNOWN)
name: counter_enabled
type: stdout
short_description: adds counters to the output items (tasks and hosts/task)
description:
- Use this callback when you need a kind of progress bar on a large environments.
- You will know how many tasks has the playbook to run, and which one is actually running.
- You will know how many hosts may run a task, and which of them is actually running.
extends_documentation_fragment:
- default_callback
requirements:
- set as stdout callback in C(ansible.cfg) (C(stdout_callback = counter_enabled))
'''
DOCUMENTATION = r"""
author: Unknown (!UNKNOWN)
name: counter_enabled
type: stdout
short_description: adds counters to the output items (tasks and hosts/task)
description:
- Use this callback when you need a kind of progress bar on a large environments.
- You will know how many tasks has the playbook to run, and which one is actually running.
- You will know how many hosts may run a task, and which of them is actually running.
extends_documentation_fragment:
- default_callback
requirements:
- set as stdout callback in C(ansible.cfg) (C(stdout_callback = counter_enabled))
"""

from ansible import constants as C
from ansible.plugins.callback import CallbackBase
Expand Down
35 changes: 17 additions & 18 deletions plugins/callback/default_without_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

DOCUMENTATION = r'''
name: default_without_diff
type: stdout
short_description: The default ansible callback without diff output
version_added: 8.4.0
description:
- This is basically the default ansible callback plugin (P(ansible.builtin.default#callback)) without
showing diff output. This can be useful when using another callback which sends more detailed information
to another service, like the L(ARA, https://ara.recordsansible.org/) callback, and you want diff output
sent to that plugin but not shown on the console output.
author: Felix Fontein (@felixfontein)
extends_documentation_fragment:
- ansible.builtin.default_callback
- ansible.builtin.result_format_callback
'''

EXAMPLES = r'''
DOCUMENTATION = r"""
name: default_without_diff
type: stdout
short_description: The default ansible callback without diff output
version_added: 8.4.0
description:
- This is basically the default ansible callback plugin (P(ansible.builtin.default#callback)) without showing diff output.
This can be useful when using another callback which sends more detailed information to another service, like the L(ARA,
https://ara.recordsansible.org/) callback, and you want diff output sent to that plugin but not shown on the console output.
author: Felix Fontein (@felixfontein)
extends_documentation_fragment:
- ansible.builtin.default_callback
- ansible.builtin.result_format_callback
"""

EXAMPLES = r"""
# Enable callback in ansible.cfg:
ansible_config: |
[defaults]
Expand All @@ -32,7 +31,7 @@
# Enable callback with environment variables:
environment_variable: |
ANSIBLE_STDOUT_CALLBACK=community.general.default_without_diff
'''
"""

from ansible.plugins.callback.default import CallbackModule as Default

Expand Down
12 changes: 6 additions & 6 deletions plugins/callback/dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

DOCUMENTATION = '''
DOCUMENTATION = r"""
name: dense
type: stdout
short_description: minimal stdout output
extends_documentation_fragment:
- default_callback
- default_callback
description:
- When in verbose mode it will act the same as the default callback.
- When in verbose mode it will act the same as the default callback.
author:
- Dag Wieers (@dagwieers)
- Dag Wieers (@dagwieers)
requirements:
- set as stdout in configuration
'''
- set as stdout in configuration
"""

HAS_OD = False
try:
Expand Down
Loading

0 comments on commit d887930

Please sign in to comment.