Debian Codegraph @

lib/ansible/modules/set_stats.py

raw
1 # -*- coding: utf-8 -*-
2
3 # Copyright: (c) 2016, Ansible RedHat, Inc
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 from __future__ import annotations
7
8
9 DOCUMENTATION = r"""
10 ---
11 module: set_stats
12 short_description: Define and display stats for the current ansible run
13 description:
14 - This module allows setting/accumulating stats on the current ansible run, either per host or for all hosts in the run.
15 - This module is also supported for Windows targets.
16 author: Brian Coca (@bcoca)
17 options:
18 data:
19 description:
20 - A dictionary of which each key represents a stat (or variable) you want to keep track of.
21 type: dict
22 required: true
23 per_host:
24 description:
25 - Whether the stats are per host or for all hosts in the run.
26 type: bool
27 default: no
28 aggregate:
29 description:
30 - Whether the provided value is aggregated to the existing stat V(true) or will replace it V(false).
31 type: bool
32 default: yes
33 extends_documentation_fragment:
34 - action_common_attributes
35 - action_common_attributes.conn
36 - action_common_attributes.flow
37 - action_core
38 attributes:
39 action:
40 details: While the action plugin does do some of the work it relies on the core engine to actually create the variables, that part cannot be overridden
41 support: partial
42 bypass_host_loop:
43 support: none
44 bypass_task_loop:
45 support: none
46 core:
47 details: While parts of this action are implemented in core, other parts are still available as normal plugins and can be partially overridden
48 support: partial
49 check_mode:
50 support: full
51 delegation:
52 support: none
53 diff_mode:
54 support: none
55 notes:
56 - In order for custom stats to be displayed, you must set C(show_custom_stats) in section C([defaults]) in C(ansible.cfg)
57 or by defining environment variable C(ANSIBLE_SHOW_CUSTOM_STATS) to V(true). See the P(ansible.builtin.default#callback) callback plugin for details.
58 version_added: "2.3"
59 """
60
61 EXAMPLES = r"""
62 - name: Aggregating packages_installed stat per host
63 ansible.builtin.set_stats:
64 data:
65 packages_installed: 31
66 per_host: yes
67
68 - name: Aggregating random stats for all hosts using complex arguments
69 ansible.builtin.set_stats:
70 data:
71 one_stat: 11
72 other_stat: "{{ local_var * 2 }}"
73 another_stat: "{{ some_registered_var.results | map(attribute='ansible_facts.some_fact') | list }}"
74 per_host: no
75
76 - name: Setting stats (not aggregating)
77 ansible.builtin.set_stats:
78 data:
79 the_answer: 42
80 aggregate: no
81 """