Ansible:期待->无效的命令名称 [英] Ansible: expect -> invalid command name

查看:63
本文介绍了Ansible:期待->无效的命令名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Expect函数与ansible一起使用,以安装带有预答案的.bin文件.但是我得到这个错误.

I want to use the expect function with ansible to install a .bin file with preanswers. But i get this error.

"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简单命令...

However also i cant execute other unix simple commands...

我的代码:

- 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

我无法使用pexpect模块.

And i have no possibility to use the pexpect module.

推荐答案

您缺少生成命令:

spawn /opt/{{ jiraExec }}

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

Also, for any string containing [...] use Tcl's single quoting mechanism: the square brackets are Tcl's command substitution syntax (think backticks in sh):

expect {OK [o, Enter], Cancel [c]}

我找到了一个类似的示例: https://docs.ansible.com/ansible/latest/modules/shell_module.html?highlight=shell#examples

I found a similar example: https://docs.ansible.com/ansible/latest/modules/shell_module.html?highlight=shell#examples

这篇关于Ansible:期待->无效的命令名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆