use*_*814 11 ansible ansible-playbook
我们开始研究 Ansible 来替换旧的 cfengine2 安装。我有一个简单的剧本:
该剧本需要超过 4 分钟的挂钟时间才能在 97 台机器上运行(全部通过快速 1gig 或 10gig 网络连接,LAN 延迟低于 1 毫秒),并且在我使用 2 核 4G 内存 VM 时消耗了超过 50% 的 CPU运行它。
在单台机器上运行大约需要 11 秒,消耗了大约 4 秒的用户+系统 CPU 时间,对于所涉及的工作量来说,TBH 似乎仍然有点过分。
明显的位:
这种性能水平是正常的还是我的设置有问题?如果是这样,我该如何确定什么?
编辑:截至 2017 年 8 月,我们仍然看到这个问题。Ansible 版本是 2.2.1,现在剧本的大小已经增加。最新数字:
ansible -m ping all
实际需要 4.6 秒,用户需要 3.2 秒,系统时间需要 2.5 秒尽管剧本现在更大了,但我仍然认为没有任何东西可以证明剧本服务器上的 CPU 负载水平是合理的 - 也许是挂钟时间,但部署服务器在大部分运行中应该基本上处于空闲状态,据我所知,它主要是文件副本和一些模板扩展。
请注意,我们正在大量使用主机/组变量
有几个人询问了分析,分析运行的尾部:
Tuesday 01 August 2017 16:02:24 +0100 (0:00:00.539) 0:06:22.991 ********
===============================================================================
yumrepo : centos repos -------------------------------------------------- 9.77s
sshd : copy CentOS 6 sshd config ---------------------------------------- 7.41s
sshd : copy CentOS 7 sshd config ---------------------------------------- 6.94s
core : ensure core packages are present --------------------------------- 6.28s
core : remove packages on VM guests ------------------------------------- 5.39s
resolv : stop NetworkManager changing resolv.conf ----------------------- 5.25s
yumrepo : epel6 gpg key ------------------------------------------------- 3.94s
yumrepo : epel7 gpg key ------------------------------------------------- 3.71s
yumrepo : nsg gpg key --------------------------------------------------- 3.57s
resolv : build resolv.conf ---------------------------------------------- 3.30s
yumrepo : nsg repo ------------------------------------------------------ 2.66s
resolv : check NetworkManager running ----------------------------------- 2.63s
yumrepo : psp repo ------------------------------------------------------ 2.62s
yumrepo : ucs repo ------------------------------------------------------ 2.44s
yumrepo : epel repo ----------------------------------------------------- 2.27s
resolv : check for nmcli ------------------------------------------------ 2.08s
core : remove various unwanted files ------------------------------------ 1.42s
telegraf : write telegraf.conf file ------------------------------------- 1.13s
core : copy sudoers in place -------------------------------------------- 0.94s
core : ensure sshd is running ------------------------------------------- 0.90s
Run Code Online (Sandbox Code Playgroud)
在您的ansible.cfg
设置中包含以下内容:
[defaults]
# profile each task
callback_whitelist = profile_tasks
# [don't validate host keys](http://docs.ansible.com/ansible/intro_configuration.html#host-key-checking)
host_key_checking = False
[ssh_connection]
pipelining = True
Run Code Online (Sandbox Code Playgroud)
- hosts: all
strategy: free
tasks: [...]
Run Code Online (Sandbox Code Playgroud)
最后,禁用游戏中的事实收集:gather_facts: false
如果在分析之后,您看到很多这样的内容:
TASK [pip foo]
ok: [10.192.197.252] => (item=ansible)
ok: [10.192.197.252] => (item=boto)
ok: [10.192.197.252] => (item=boto3)
ok: [10.192.197.252] => (item=passlib)
ok: [10.192.197.252] => (item=cryptography)
Run Code Online (Sandbox Code Playgroud)
将这些操作压缩在ansible.cfg
[默认值]下:
例如squash_actions = yum,pip,bar
归档时间: |
|
查看次数: |
1384 次 |
最近记录: |