提高Ansible性能

我正在尝试提高 ansible playbook 的性能。我有一个测试剧本如下:

---
- name: Test
  hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - name: Creating an empty file
      file:
        path: /tmp/hello
        state: touch

    - name: Test
      command: "echo 'Hello, World!' >> /tmp/hello"
      with_sequence: start=1 end=500
      delegate_to: localhost

运行这需要惊人的 57 秒。与执行相同操作的 bash 脚本相比:

测试文件

#!/bin/bash
touch /tmp/hello
for i in {1..500}
do
  sh /home/admin/hello.sh
  echo "This is iteration $i"
done

你好.sh

#!/bin/bash
echo "Hello, World!" >> /tmp/hello

这需要大约 1.5 秒才能运行。

我已经对ansible.cfg文件进行了一些更改

[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=18000s -o PreferredAuthentications=publickey
control_path = %(directory)s/ansible-ssh-%%h-%%p-%%r
pipelining = True

我还能做些什么来改善这种糟糕的表现?

以上是提高Ansible性能的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>