【发布时间】:2017-02-15 09:33:04
【问题描述】:
我有一个使用 ansible 命令的 yml 文件。在文件中,我将服务位置附加到现有环境路径,如下所示:
-name: retreiving the path
raw: $ENV:PATH
register: path_out
- name: adding the services to the environment path
raw: SETX /M PATH "$ENV:PATH;{{item.service_path}}"
with_items:
"{{ services }}"
因此,每次执行脚本时,即使先前添加了相同的服务路径,它也会将服务路径附加到现有环境路径,这会一次又一次地创建相同服务路径的附加。因此,我想要检查一下是否已经添加了 service_path,它不会在最后再次附加它。我尝试了以下但没有帮助:
- name: adding the services to the environment path
raw: SETX /M PATH "$ENV:PATH;{{item.service_location}}"
with_items:
"{{ services }}"
when : ansible_env.PATH;{{item.service_location}}.exists is not defined
它根本不起作用请帮助如何检查?平台是我正在工作的窗口
【问题讨论】: