简体   繁体   English

如何在剧本上设定ansible促分裂原策略?

[英]How to set ansible mitogen strategy on playbook?

I'm trying to make it work mitogen strategy on my ansible playbook. 我正在尝试在我的可折叠剧本上使用它的促分裂原策略。 I'm following tutorial on mitogen tutorial . 我正在关注有丝分裂原教程 My python version is 3.6 and ansible version is 2.7.10. 我的python版本是3.6,而ansible版本是2.7.10。

Mitogen is installed in /usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy Mitogen安装在/usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy

When I try to add keys on my playbook as: 当我尝试在剧本上添加键时:

  - hosts: "{{ host_group | default('host-list') }}"
    ...
    strategy: mitogen_linear
    strategy_plugins: /usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy

I have the following error: 我有以下错误:

ERROR! 'strategy_plugins' is not a valid attribute for a Play

Also, I'm trying to configure it as a environment variable in playbook execution: 另外,我正在尝试在执行剧本时将其配置为环境变量:

command = ['ANSIBLE_STRATEGY_PLUGINS=/usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy', 'ANSIBLE_STRATEGY=mitogen_linear', 'ansible-playbook', '-ihosts', 'ansible_scripts/inventory.yml']
process = subprocess.Popen(command, stdout=subprocess.PIPE)

Here is not finding directory: 这里找不到目录:

FileNotFoundError: [Errno 2] No such file or directory: 'ANSIBLE_STRATEGY_PLUGINS=/usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy': 'ANSIBLE_STRATEGY_PLUGINS=/usr/local/lib/python3.6/site-packages/ansible_mitogen/plugins/strategy'

How I can correctly configure mitogen strategy on my playbook? 如何在剧本上正确配置促分裂原策略? How I can make it work? 我该如何运作?

This might be some misconfiguration "No such file or directory" . 这可能是一些配置错误"No such file or directory" Try the configuration file. 尝试配置文件。 For example put into the [defaults] section: 例如,放入[defaults]部分:

$ grep strategy /etc/ansible/ansible.cfg
strategy_plugins = /usr/local/ansible/plugins/ansible_mitogen/plugins/strategy
strategy = mitogen_linear

Fit the configuration file and path to your needs. 使配置文件和路径适合您的需求。 (Works for me with ansible 2.7.9 and mitogen-0.2.6) (适用于我的ansible 2.7.9和mitogen-0.2.6)

FWIW, if you want to automate the installation and configuration see plugins.yml and example of vars . FWIW,如果要自动化安装和配置,请参阅plugins.ymlvars示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM