Commit graph

18 commits

Author SHA1 Message Date
Abhijeet Kasurde
f2d0b38b0e
Remove skippy callback
Fixes: #350

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2024-09-05 16:08:40 +09:00
Marty Winkler
51b94f536c
Feat/add summary only option to profile callbacks (#511)
* profile_tasks callback: add parameter to show only summary
2024-02-06 09:21:42 -06:00
softwarefactory-project-zuul[bot]
b9feff586f
Merge pull request #441 from jsquyres/pr/json-indent-level
json[l] callback: add parameter to set JSON prettyprint indent level

SUMMARY
Add ANSIBLE_JSON_INDENT parameter to both the json and jsonl callback plugins.  The default values are different between the two modules to maintain their existing behavior:

json: indent==4, causing a prettyprint output
jsonl: indent==0, causing a 1-line output

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix.json
ansible.posix.jsonl

ADDITIONAL INFORMATION
One specific use-case that is enabled by this feature: if a user chooses to use the jsonl plugin so that they still get output at the end of each task (vs. only at the end of the play), they may also want human-readable output so that they can monitor the status of their play.  For example, setting the jsonl indent level to 4 gives a) output at the end of each task, and b) making that output be both machine readable and human readable.
Using this trivial playbook shows the change:
- hosts: localhost
  gather_facts: false
  tasks:
    - name: hello, world
      debug:
        msg: hello, world
When using the jsonl callback, here's what one JSON emit looks like before the change:
{"_event":"v2_playbook_on_play_start","_timestamp":"2023-04-08T12:11:48.001806Z","play":{"duration":{"start":"2023-04-08T12:11:48.001383Z"},"id":"acde4800-1122-f32c-94c3-000000000001","name":"localhost"},"tasks":[]}
After the change, setting ANSIBLE_JSON_INDENT to 4, the same output looks like this:
{
    "_event":"v2_playbook_on_play_start",
    "_timestamp":"2023-04-08T12:12:47.787516Z",
    "play":{
        "duration":{
            "start":"2023-04-08T12:12:47.787164Z"
        },
        "id":"acde4800-1122-2946-e3e4-000000000001",
        "name":"localhost"
    },
    "tasks":[]
}
Both outputs are suitable for automated processes to parse the machine readable output.  The second output has the benefit of being human readable.

Reviewed-by: Adam Miller <admiller@redhat.com>
Reviewed-by: Jeff Squyres
2023-04-27 20:52:09 +00:00
Jeff Squyres
281f957ece json[l] callback: add parameter to set JSON prettyprint indent level
Add ANSIBLE_JSON_INDENT parameter to both the json and jsonl callback
plugins.  The default values are different between the two modules to
maintain their existing behavior:

* json: indent==4, causing a prettyprint output
* jsonl: indent==0, causing a 1-line output

One specific use-case that is enabled by this feature: if a user
chooses to use the jsonl plugin so that they still get output at the
end of each task (vs. only at the end of the play), they may also want
human-readable output so that they can monitor the status of their
play.  For example, setting the jsonl indent level to 4 gives a)
output at the end of each task, and b) making that output be both
machine readable and human readable.

Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
2023-04-18 08:00:04 -07:00
softwarefactory-project-zuul[bot]
da1713ed3e
Merge pull request #440 from jsquyres/pr/json-callback-path
json[l] callback: add play/task path info

Add the play and task path info (i.e., filename and line number) to the JSON that is emitted from the json and jsonl callback plugins, allowing more accurate post-mortem analysis.
SUMMARY
Add the play and task path info (i.e., filename and line number) to the JSON that is emitted from the json and jsonl callback plugins, allowing more accurate post-mortem analysis.
ISSUE TYPE

Feature Pull Request

COMPONENT NAME

ansible.posix.json
ansible.posix.jsonl

ADDITIONAL INFORMATION
By also including the file/line number in the JSON data emitted, post-mortem analysis can unambiguously tie play/task log data to the specific play / task that generated it.  Without this information, it could be difficult for automated processes to precisely map log output back to the task that generated it (especially with playbooks that either do not name tasks, or do not name tasks uniquely).
Using this trivial playbook shows the change:
- hosts: localhost
  gather_facts: false
  tasks:
    - name: hello, world
      debug:
        msg: hello, world
When using the json callback, here's what it looks like before the change (for brevity, just the plays section of the output):
        {
            "play": {
                "duration": {
                    "end": "2023-04-08T11:35:39.694000Z",
                    "start": "2023-04-08T11:35:39.657056Z"
                },
                "id": "acde4800-1122-6387-7abd-000000000001",
                "name": "localhost",
            },
            "tasks": [
                {
                    "hosts": {
                        "localhost": {
                            "_ansible_no_log": null,
                            "_ansible_verbose_always": true,
                            "action": "debug",
                            "changed": false,
                            "msg": "hello, world"
                        }
                    },
                    "task": {
                        "duration": {
                            "end": "2023-04-08T11:35:39.694000Z",
                            "start": "2023-04-08T11:35:39.672132Z"
                        },
                        "id": "acde4800-1122-6387-7abd-000000000003",
                        "name": "hello, world",
                    }
                }
            ]
        }
After the change, there is a new path key/value in both the play and the task:
        {
            "play": {
                "duration": {
                    "end": "2023-04-08T11:35:39.694000Z",
                    "start": "2023-04-08T11:35:39.657056Z"
                },
                "id": "acde4800-1122-6387-7abd-000000000001",
                "name": "localhost",
                "path": "/tmp/plays/hello.yaml:1"
            },
            "tasks": [
                {
                    "hosts": {
                        "localhost": {
                            "_ansible_no_log": null,
                            "_ansible_verbose_always": true,
                            "action": "debug",
                            "changed": false,
                            "msg": "hello, world"
                        }
                    },
                    "task": {
                        "duration": {
                            "end": "2023-04-08T11:35:39.694000Z",
                            "start": "2023-04-08T11:35:39.672132Z"
                        },
                        "id": "acde4800-1122-6387-7abd-000000000003",
                        "name": "hello, world",
                        "path": "/tmp/plays/hello.yaml:4"
                    }
                }
            ]
        }
The effect is the same in the jsonl plugin, but the output is squashed into a single line.

Reviewed-by: Adam Miller <admiller@redhat.com>
2023-04-18 03:24:12 +00:00
softwarefactory-project-zuul[bot]
7fb9cc95c3
Merge pull request #435 from ziegenberg/fix-412
docs: fix profile_tasks callback documentation

SUMMARY

This fixes the markup.
Fixes: #412
ISSUE TYPE


Docs Pull Request

COMPONENT NAME

profile_tasks
ADDITIONAL INFORMATION


None.

Reviewed-by: Hideki Saito <saito@fgrep.org>
Reviewed-by: Adam Miller <admiller@redhat.com>
2023-04-18 01:52:07 +00:00
Jeff Squyres
940d914904 json[l] callback: add play/task path info
Add the play and task path info (i.e., filename and line number) to
the JSON that is emitted from the json and jsonl callback plugins,
allowing more accurate post-mortem analysis.

Signed-off-by: Jeff Squyres <jsquyres@cisco.com>
2023-04-12 09:55:44 -04:00
Michael Dubner
a417ac80f0 Add jsonl callback plugin to ansible.posix collection 2023-03-30 03:46:17 +03:00
Daniel Ziegenberg
009ed3bed5
docs: fix profile_tasks callback documentation
Fixes: #412

Signed-off-by: Daniel Ziegenberg <daniel@ziegenberg.at>
2023-03-24 11:47:00 +01:00
Sean Cavanaugh
c4be75114b
Update profile_tasks.py
removing contentious terminology to match reference documentation https://docs.ansible.com/ansible/latest/reference_appendices/config.html
2022-07-15 14:04:06 -04:00
Hideki Saito
0e71c0e530 Fixed documentation and options to address new sanity tests
- https://docs.ansible.com/ansible/latest/dev_guide/testing_validate-modules.html

Signed-off-by: Hideki Saito <saito@fgrep.org>
2022-04-01 13:23:45 +09:00
Hideki Saito
3d57a17ed6 Correctly calculate task execution time with serial execution
- Fixes #83

Signed-off-by: Hideki Saito <saito@fgrep.org>
2021-09-10 13:21:37 +09:00
Adam Miller
c390183337 fix skippy callback deprecation warning
Fixes https://github.com/ansible-collections/ansible.posix/issues/62

Signed-off-by: Adam Miller <admiller@redhat.com>
2020-08-21 16:24:35 -05:00
ansible-zuul[bot]
0d0f8217cf
Merge pull request #8 from sivel/ansible/pull/65973
Fix json callback for non-lockstep strategy plugins such as free

Reviewed-by: https://github.com/apps/ansible-zuul
2020-06-19 06:48:42 +00:00
Abhijeet Kasurde
0062198f73
Typecast results before use in profile_tasks callback (#26)
If user specifies sort_order to none, results are not converted to list.
This fix force this typecasting before using the results.

Fixes: https://github.com/ansible/ansible/issues/69563

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
2020-05-21 11:55:11 -05:00
Alexandre Garnier
8a11a72e0c
Fix issue ansible/ansible#59059 (#15)
When no sorting was selected, `result` was a `odict_items` which is not
subscriptable, so the slicing was failing.
2020-04-29 15:17:03 -05:00
Matt Martz
23d3703a84 Fix json callback for non-lockstep strategy plugins such as free. Fixes #65931 2020-03-24 11:23:39 -05:00
Ansible Core Team
6f928621f0 Initial commit 2020-03-09 13:15:28 +00:00