Ansible:expect->;无效的命令名

Ansible:expect->;无效的命令名,ansible,expect,Ansible,Expect,我想使用expect函数和ansible来安装一个带有前置应答的.bin文件。但我得到了这个错误 "stderr": "invalid command name \"/opt/atlassian-jira-software-7.8.1-x64.bin\"\n while executing\n\"/opt/atlassian-jira-software-7.8.1-x64.bin\"", 但是,我也不能执行其他unix简单命令 我的代码: - name: Upgrade Jira

我想使用expect函数和ansible来安装一个带有前置应答的.bin文件。但我得到了这个错误

"stderr": "invalid command name \"/opt/atlassian-jira-software-7.8.1-x64.bin\"\n    while executing\n\"/opt/atlassian-jira-software-7.8.1-x64.bin\"",
但是,我也不能执行其他unix简单命令

我的代码:

- name: Upgrade Jira
   shell: |
     /opt/{{ jiraExec }}

     expect "OK [o, Enter], Cancel [c]"
     send "o\n"

     expect "Express Install (use default settings) [1], Custom Install (recommended for advanced users) [2], Upgrade an existing JIRA installation [3, Enter]"
     send "3\n"

     expect "[/opt/atlassian/jira]"
     send "\n"

     expect "Yes [y, Enter], No [n]"
     send "y\n"

     expect "Upgrade [u, Enter], Exit [e]"
     send "u\n"

     expect "Yes [y, Enter], No [n]"
     send "n\n"
  args:
     executable: /usr/bin/expect

我不可能使用p预料模块。

错误没有抱怨<代码>预期< /> >,请检查您的jra文件路径,您应该考虑使用

  • 其中jira software.X.X.X是您下载的jira版本

  • -q指示安装程序以无人值守模式(安静)运行

  • -varfile指定包含安装程序使用的选项的配置文件的位置和名称
您缺少spawn命令:

spawn /opt/{{ jiraExec }}
此外,对于任何包含
[…]
的字符串,请使用Tcl的单引号机制:方括号是Tcl的命令替换语法(请考虑sh中的backticks):


我发现了一个类似的例子:

我的问题是要找到一个解决方案,而不是找到替代方法..正如我在回答中提到的,检查您的路径及其非替代方法,这是正确的方法。路径是正确的,错误显示为“无效命令名”,与“未找到文件”不同。此外,不可能进行无人参与的升级,只有安装“执行时…命令名无效…”是Tcl/expect样式的错误消息,因此expect正在运行,但代码中存在问题。
spawn /opt/{{ jiraExec }}
expect {OK [o, Enter], Cancel [c]}