Visualise Ansible execution time across playbooks, tasks, and hosts.

Overview

ansible-trace

Visualise where time is spent in your Ansible playbooks: what tasks, and what hosts, so you can find where to optimise and decrease playbook latency.

An Ansible Callback Function which traces the execution time of Ansible playooks, outputting Chrome's Trace Event Format for visualising in the Perfetto in-browser trace UI.

Here's a trace of me deploying to my home Raspberry Pi cluster, with the default strategy: linear. You can see that now all the tasks are synchronized across hosts, with each host waiting for the slowest host before proceeding to the next task:

Perfetto window showing tasks all happening synchronized

Here's the same playbook ran with strategy: free so fast hosts run to completion without waiting for slow hosts:

Perfetto window showing durations

You can click on tasks to see details about them:

Perfetto window showing details showing arguments and filename of task

Interactive Example

  1. Download (Right-click -> Save Link As) example-trace.json.
  2. Open https://ui.perfetto.dev/, and drag and drop in the downloaded example-trace.json.

Usage

  1. Copy trace.py into your Ansible's callback_plugins directory, or in other positions Ansible accepts, e.g.:

    ansible-root
    ├── ansible.cfg
    ├── site.yml
    └── callback_plugins
        └── trace.py
    
  2. Enable the trace callback plugin in your ansible.cfg:

    [defaults]
    callback_enabled = trace

    Or, enable it at the top of your playbook yml:

    ansible:
      env:
        CALLBACKS_ENABLED: trace
        TRACE_OUTPUT_DIR: .
        TRACE_HIDE_TASK_ARGUMENTS: True
  3. Run your Ansible Playbook:

    $ ansible-playbook site.yml

    This will output trace.json in the TRACE_OUTPUT_DIR, defaulting to your current working directory.

  4. Open https://ui.perfetto.dev/, and drag-and-drop in the trace.json.

    You don't have to wait for the trace to finish; you can open in-progress trace files.

Other Trace Viewers

Perfetto is the most mature trace viewer, but here are some other options:

  • chrome://tracing (aka Catapult Trace Viewer) is the older version of Perfetto. Supports generating a standalone HTML page.
  • Speedscope can open the traces, but only shows one host at a time.
  • Firefox Profiler can open the traces, showing trace spans in the "Marker Chart" tab: example.

Other Ansible Profiling Tools

profile_tasks

ansible.posix.profile_tasks displays task timing as console output, but can't visualise gaps in the timing (e.g. with strategy: linear when fast hosts wait for slow hosts).

ansible-playbook -vvvv

Adding extra vs adds more debug info, -vvvv enables connection debugging.

Mitogen for Ansible

Mitogen promises to speed up your Ansible playbooks with a persistent interpreter. They profile their runs for bandwidth an time by analysing network packet captures.

You need to install from HEAD to support latest Ansible versions, because there hasn't been a tagged release since 2019.

Owner
Mark Hansen
Mark Hansen
📊 Charts with pure python

A zero-dependency python package that prints basic charts to a Jupyter output Charts supported: Bar graphs Scatter plots Histograms 🍑 📊 👏 Examples

Max Humber 54 Oct 04, 2022
PyPassword is a simple follow up to PyPassphrase

PyPassword PyPassword is a simple follow up to PyPassphrase. After finishing that project it occured to me that while some may wish to use that option

Scotty 2 Jan 22, 2022
These data visualizations were created as homework for my CS40 class. I hope you enjoy!

Data Visualizations These data visualizations were created as homework for my CS40 class. I hope you enjoy! Nobel Laureates by their Country of Birth

9 Sep 02, 2022
Drug design and development team HackBio internship is a virtual bioinformatics program that introduces students and professional to advanced practical bioinformatics and its applications globally.

-Nyokong. Drug design and development team HackBio internship is a virtual bioinformatics program that introduces students and professional to advance

4 Aug 04, 2022
A comprehensive tutorial for plotting focal mechanism

Focal_Mechanisms_Demo A comprehensive tutorial for plotting focal mechanism "beach-balls" using the PyGMT package for Python. (Resulting map of this d

3 Dec 13, 2022
Statistical data visualization using matplotlib

seaborn: statistical data visualization Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing

Michael Waskom 10.2k Dec 30, 2022
Analysis and plotting for motor/prop/ESC characterization, thrust vs RPM and torque vs thrust

esc_test This is a Python package used to plot and analyze data collected for the purpose of characterizing a particular propeller, motor, and ESC con

Alex Spitzer 1 Dec 28, 2021
An open-source plotting library for statistical data.

Lets-Plot Lets-Plot is an open-source plotting library for statistical data. It is implemented using the Kotlin programming language. The design of Le

JetBrains 820 Jan 06, 2023
A small timeseries transformation API built on Flask and Pandas

#Mcflyin ###A timeseries transformation API built on Pandas and Flask This is a small demo of an API to do timeseries transformations built on Flask a

Rob Story 84 Mar 25, 2022
A flexible tool for creating, organizing, and sharing visualizations of live, rich data. Supports Torch and Numpy.

Visdom A flexible tool for creating, organizing, and sharing visualizations of live, rich data. Supports Python. Overview Concepts Setup Usage API To

FOSSASIA 9.4k Jan 07, 2023
Multi-class confusion matrix library in Python

Table of contents Overview Installation Usage Document Try PyCM in Your Browser Issues & Bug Reports Todo Outputs Dependencies Contribution References

Sepand Haghighi 1.3k Dec 31, 2022
This is my favourite function - the Rastrigin function.

This is my favourite function - the Rastrigin function. What sparked my curiosity and interest in the function was its complexity in terms of many local optimum points, which makes it particularly in

1 Dec 27, 2021
A Python-based non-fungible token (NFT) generator built using Samilla and Matplotlib

PyNFT A Pythonic NF (non-fungible token) generator built using Samilla and Matplotlib Use python pynft.py [amount] The intention behind this generato

Ayush Gundawar 6 Feb 07, 2022
Squidpy is a tool for the analysis and visualization of spatial molecular data.

Squidpy is a tool for the analysis and visualization of spatial molecular data. It builds on top of scanpy and anndata, from which it inherits modularity and scalability. It provides analysis tools t

Theis Lab 251 Dec 19, 2022
Curvipy - The Python package for visualizing curves and linear transformations in a super simple way

Curvipy - The Python package for visualizing curves and linear transformations in a super simple way

Dylan Tintenfich 55 Dec 28, 2022
Example Code Notebooks for Data Visualization in Python

This repository contains sample code scripts for creating awesome data visualizations from scratch using different python libraries (such as matplotli

Javed Ali 27 Jan 04, 2023
Extensible, parallel implementations of t-SNE

openTSNE openTSNE is a modular Python implementation of t-Distributed Stochasitc Neighbor Embedding (t-SNE) [1], a popular dimensionality-reduction al

Pavlin Poličar 1.1k Jan 03, 2023
Sparkling Pandas

SparklingPandas SparklingPandas aims to make it easy to use the distributed computing power of PySpark to scale your data analysis with Pandas. Sparkl

366 Oct 27, 2022
Collection of scripts for making high quality beautiful math-related posters.

Poster Collection of scripts for making high quality beautiful math-related posters. The poster can have as large printing size as 3x2 square feet wit

Nattawut Phetmak 3 Jun 09, 2022
High performance, editable, stylable datagrids in jupyter and jupyterlab

An ipywidgets wrapper of regular-table for Jupyter. Examples Two Billion Rows Notebook Click Events Notebook Edit Events Notebook Styling Notebook Pan

J.P. Morgan Chase 75 Dec 15, 2022