如何在代码或清单中使用大于5的值覆盖默认的forks值?

huangapple go评论95阅读模式
英文:

Ansible: How to override default forks value with value larger than 5 from code or inventory?

问题

我需要在我的playbook中的每个任务同时在10个主机上运行,是否可以通过在playbook代码或清单中设置变量来覆盖默认的forks值(5),以使用大于5的值?不能使用ansible.cfg文件或命令行。尝试在清单变量中设置forksansible_forks,在playbook中设置环境变量ANSIBLE_FORKS,但似乎都不起作用。

英文:

I need every task in my playbook to run on 10 hosts simultaneously, is it possible to override default forks value (5) with value larger than 5 by setting a variable in the playbook code or inventory? Cannot use ansible.cfg file or command line.
Tried to set forks and ansible_forks in inventory variables, environment variable ANSIBLE_FORKS in playbook -- nothing seemed to work.

答案1

得分: 1

不。在播放或清单中无法设置DEFAULT_FORKS

英文:

No. It's not possible to set DEFAULT_FORKS in a play or inventory.

答案2

得分: 1

如前面的答案中已经提到的,一旦Ansible开始运行,就无法配置执行任务的目标主机上Ansible将使用的最大分叉数。这是因为通过Ansible配置设置来配置执行环境是在启动时完成的,并保存在内存中。这在运行时无法更改。

因此,你将需要使用ansible.cfg文件或命令行以及环境变量ANSIBLE_FORKS

英文:

As already mentioned in the first given answer it is not possible to configure the

> Maximum number of forks Ansible will use to execute tasks on target hosts.

after Ansible has started to run. This is because with the Ansible Configuration Settings you configure how the execution environment was started and is hold in memory. This can't then be overwritten during runtime.

So

> Cannot use ansible.cfg file or command line ... environment variable ANSIBLE_FORKS ...

you will need to.

huangapple
  • 本文由 发表于 2023年3月7日 03:23:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/75654992.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定