本文介绍了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.
推荐答案
文档不正确.这是一个在更高版本(ansible 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 不允许剧本级别的环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!