1

I've configured ansible.cfg to display the steps it has done during a playbook run and it looks like so:

===============================================================================
common : Upgrade all packages --------------------------------------- 407.33s
jenkins-slave : compile git --------------------------------------- 153.26s
jenkins-slave : clone tss repo --------------------------------------- 44.61s
jenkins-slave : remove current git installation --------------------------------------- 24.22s
jenkins-slave : install java 1.8.0 --------------------------------------- 16.61s
jenkins-slave : download git source --------------------------------------- 12.44s
jenkins-slave : Install required packages --------------------------------------- 10.83s
jenkins-slave : clone repo --------------------------------------- 9.02s
common : Install base packages --------------------------------------- 6.74s
jenkins-slave : install nvm --------------------------------------- 5.72s
common : install pip --------------------------------------- 5.21s
common : Install base packages centos 7 --------------------------------------- 3.53s
node-exporter : download node-exporter tarball --------------------------------------- 2.83s
jenkins-slave : create "/opt/devenv/company" --------------------------------------- 1.97s
common : download pip --------------------------------------- 1.80s
Gathering Facts --------------------------------------- 1.69s
common : install pip packages --------------------------------------- 1.66s
jenkins-slave : unarchive git source --------------------------------------- 1.46s
node-exporter : untar node-exporter tarball --------------------------------------- 1.32s

ansible.cfg is configured like so:

[defaults]
nocows = 1
nocolor = 0
retry_files_enabled   = False
display_skipped_hosts = True
host_key_checking = False
transport = paramiko
bin_ansible_callbacks = True
callback_whitelist = profile_tasks
forks = 25
[ssh_connection]
transfer_method = scp

If you see from the output, the order is all mixed up and is sorted by the length of each task's run in descending order.

How can I sort the output so it displays the tasks by the order they were run?

1

You can add an entry in your ini file to set the sort_order for the callback plugin to none.

[callback_profile_tasks]
sort_order = none

By default it is set to descending, which is why the tasks are displayed in decreasing order of time taken.

Refer: https://docs.ansible.com/ansible/latest/plugins/callback/profile_tasks.html#parameter-sort_order

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.