ansible.posix.cgroup_perf_recap callback – Profiles system activity of tasks and full execution using cgroups

Note

This callback plugin is part of the ansible.posix collection (version 1.4.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install ansible.posix.

To use it in a playbook, specify: ansible.posix.cgroup_perf_recap.

Synopsis

  • This is an ansible callback plugin utilizes cgroups to profile system activity of ansible and individual tasks, and display a recap at the end of the playbook execution

Requirements

The below requirements are needed on the local controller node that executes this callback.

  • whitelist in configuration

  • cgroups

Parameters

Parameter

Comments

control_group

string / required

Name of cgroups control group

Configuration:

  • INI entry:

    [callback_cgroup_perf_recap]
    control_group = None
    
  • Environment variable: CGROUP_CONTROL_GROUP

cpu_poll_interval

float

Interval between CPU polling for determining CPU usage. A lower value may produce inaccurate results, a higher value may not be short enough to collect results for short tasks.

Default: 0.25

Configuration:

  • INI entry:

    [callback_cgroup_perf_recap]
    cpu_poll_interval = 0.25
    
  • Environment variable: CGROUP_CPU_POLL_INTERVAL

display_recap

boolean

Controls whether the recap is printed at the end, useful if you will automatically process the output files

Choices:

  • no

  • yes ← (default)

Configuration:

  • INI entry:

    [callback_cgroup_perf_recap]
    display_recap = yes
    
  • Environment variable: CGROUP_DISPLAY_RECAP

file_name_format

string

Format of filename. Accepts %(counters), %(task_uuids), %(features), %(exts). Defaults to %(features.%(ext)s) when file_per_task is False and %(counters-%(task_uuid)s-%(feature)s.%(ext)s) when True

Default: “%(feature)s.%(ext)s”

Configuration:

  • INI entry:

    [callback_cgroup_perf_recap]
    file_name_format = %(feature)s.%(ext)s
    
  • Environment variable: CGROUP_FILE_NAME_FORMAT

file_per_task

boolean

When set as True along with write_files, this callback will write 1 file per task instead of 1 file for the entire playbook run

Choices:

  • no ← (default)

  • yes

Configuration:

  • INI entry:

    [callback_cgroup_perf_recap]
    file_per_task = no
    
  • Environment variable: CGROUP_FILE_PER_TASK

memory_poll_interval

float

Interval between memory polling for determining memory usage. A lower value may produce inaccurate results, a higher value may not be short enough to collect results for short tasks.

Default: 0.25

Configuration:

  • INI entry:

    [callback_cgroup_perf_recap]
    memory_poll_interval = 0.25
    
  • Environment variable: CGROUP_MEMORY_POLL_INTERVAL

output_dir

path

Output directory for files containing recorded performance readings. If the value contains a single %s, the start time of the playbook run will be inserted in that space. Only the deepest level directory will be created if it does not exist, parent directories will not be created.

Default: “/tmp/ansible-perf-%s”

Configuration:

  • INI entry:

    [callback_cgroup_perf_recap]
    output_dir = /tmp/ansible-perf-%s
    
  • Environment variable: CGROUP_OUTPUT_DIR

output_format

string

Output format, either CSV or JSON-seq

Choices:

  • csv ← (default)

  • json

Configuration:

  • INI entry:

    [callback_cgroup_perf_recap]
    output_format = csv
    
  • Environment variable: CGROUP_OUTPUT_FORMAT

pid_poll_interval

float

Interval between PID polling for determining PID count. A lower value may produce inaccurate results, a higher value may not be short enough to collect results for short tasks.

Default: 0.25

Configuration:

  • INI entry:

    [callback_cgroup_perf_recap]
    pid_poll_interval = 0.25
    
  • Environment variable: CGROUP_PID_POLL_INTERVAL

write_files

boolean

Dictates whether files will be written containing performance readings

Choices:

  • no ← (default)

  • yes

Configuration:

  • INI entry:

    [callback_cgroup_perf_recap]
    write_files = no
    
  • Environment variable: CGROUP_WRITE_FILES

Notes

Note

  • Requires ansible to be run from within a cgroup, such as with cgexec -g cpuacct,memory,pids: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 sudo cgcreate -a ec2-user:ec2-user -t ec2-user:ec2-user -g cpuacct,memory,pids:ansible_profile

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.