英文:
Ansible: How to override default forks value with value larger than 5 from code or inventory?
问题
我需要在我的playbook中的每个任务同时在10个主机上运行,是否可以通过在playbook代码或清单中设置变量来覆盖默认的forks值(5),以使用大于5的值?不能使用ansible.cfg
文件或命令行。尝试在清单变量中设置forks
和ansible_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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论