Dha*_*iya 6 time ansible ansible-role
我有一本剧本,在这本剧本中,有很多任务。我需要知道哪个任务花费了多少时间?
有什么解决办法吗?
小智 11
callback_whitelist
已弃用,并将在 Ansible 2.15 中删除),callbacks_enabled
(在 2.11 中引入)应在现代版本的 Ansible 中使用
[defaults]
...
callbacks_enabled = ansible.posix.profile_tasks
Run Code Online (Sandbox Code Playgroud)
参考:
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#callbacks-enabled
添加callback_whitelist = profile_tasks
在[default]
节中的ansible.cfg
这是我的 ansible.cfg
[defaults]
inventory = hosts
callback_whitelist = profile_tasks
deprecation_warnings = False
Run Code Online (Sandbox Code Playgroud)
这是我的剧本
- hosts: localhost
gather_facts: true
tasks:
- name: Sleep for 10 Sec
command: sleep 10
- name: Sleep for 5 Sec
command: sleep 5
- name: Sleep for 2 Sec
command: sleep 2
Run Code Online (Sandbox Code Playgroud)
这是我的播放输出。
PLAY [localhost] ***************************************
TASK [Gathering Facts] *********************************
Thursday 28 May 2020 09:36:04 +0000 (0:00:00.038) 0:00:00.038 **********
ok: [localhost]
TASK [Sleep for 10 Sec] ********************************
Thursday 28 May 2020 09:36:07 +0000 (0:00:03.695) 0:00:03.733 **********
changed: [localhost]
TASK [Sleep for 5 Sec] *********************************
Thursday 28 May 2020 09:36:18 +0000 (0:00:11.166) 0:00:14.899 **********
changed: [localhost]
TASK [Sleep for 2 Sec] *********************************
Thursday 28 May 2020 09:36:24 +0000 (0:00:05.965) 0:00:20.865 **********
changed: [localhost]
PLAY RECAP *********************************************
localhost : ok=4 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Thursday 28 May 2020 09:36:27 +0000 (0:00:02.878) 0:00:23.744 **********
===============================================================================
Sleep for 10 Sec------------------------------------------------ 11.17s
Sleep for 5 Sec------------------------------------------------- 5.97s
Gathering Facts------------------------------------------------- 3.70s
Sleep for 2 Sec ------------------------------------------------- 2.88s
Run Code Online (Sandbox Code Playgroud)
这里最后显示了每个任务需要多少时间来完成游戏。
关于参数的解释callback_whitelist = profile_tasks
可以在ansible官方文档中找到...
https://docs.ansible.com/ansible/latest/plugins/callback.html#enabling-callback-plugins
https://docs.ansible.com/ansible/latest/plugins/callback.html#plugin-list
https://docs.ansible.com/ansible/latest/plugins/callback/profile_tasks.html
归档时间: |
|
查看次数: |
2631 次 |
最近记录: |