本文介绍了Ansible不允许在剧本级别上使用环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在定义剧本级别的环境变量时遇到问题. 根据文档,这应该是可能的.
I'm having issues defining environment variables at playbook level. According to the docs it should be possible.
$ ansible --version
1.7.1
$ ansible-playbook -i staging deploy.yml
ERROR: environment is not a legal parameter at this level in an Ansible Playbook
这是简化的剧本:
---
- hosts: app
user: web
environment:
PATH: "{{ path_append }}:{{ ansible_env.PATH }}"
tasks:
- ...
- ...
只需确保,我尝试将其设置为不带变量,结果是相等的.
Just to make sure, I tried setting it without the variables, and the result was equal.
在任务内部移动环境定义是可行的.
Moving the environment-definition inside the tasks works.
推荐答案
文档不正确.这是一个错误,该错误已在更高版本(可使用1.8)中修复.您可以升级到1.9.x吗?
The doc was incorrect. It was a bug which was fixed in a later version (ansible 1.8). Can you upgrade to 1.9.x?
这篇关于Ansible不允许在剧本级别上使用环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!