如何通过ansible在side shell脚本中执行'source'

时间:2017-11-02 10:34:40

标签: shell ansible ansible-2.x

我有一个shell脚本说test.sh,我可以使用commandshell模块调用它们。但是test.shsource ../properties/Main.sh方式在内部调用另一个shell脚本。

我正在尝试使用ansible执行test.sh但是,执行暂停"No such file or directory"错误,因为源是内部shell命令。

test.sh看起来像这样

#/bin/bash

free -m

#echo $PWD
source ../Properties/Main.sh
#
#Remaining Part of the Script 

任何帮助都将不胜感激。

为了进一步澄清,如果您认为Main.sh不在正确的路径中,那么 我收到file not found错误,然后你错过了这一点。以下注释中提到的Automation_v1目录包含许多用于组织脚本的目录。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案,

提供绝对路径而不是source Main.sh的相对路径是关键。