当命令问两次相同的问题时,可以预料

  • 本文关键字:问题 命令 两次 ansible
  • 更新时间 :
  • 英文 :


我正在尝试使用命令vglserver_config自动化VirtualGL配置。此脚本使用以下菜单:

1) Configure server for use with VirtualGL (GLX + EGL back ends)
2) Unconfigure server for use with VirtualGL (GLX + EGL back ends)
3) Configure server for use with VirtualGL (EGL back end only)
4) Unconfigure server for use with VirtualGL (EGL back end only)
X) Exit
Choose:

我需要给出两个不同的答案;选择:"问题:

  • '1'第一次,配置VirtualGL,然后是配置脚本的实际响应(见下文(
  • 退出命令时为"x">

这是我的任务:

- name: configure VirtualGL (vglserver_config)
ansible.builtin.expect:
command: "{{ vglserver_config_cmd }}"
responses:
(.*)Choose:(.*): 1
(.*)Continue?(.*): y
(.*)Restrict 3D X server access to vglusers group (recommended)?(.*): y
(.*)Restrict framebuffer device access to vglusers group (recommended)?(.*): y
(.*)Disable XTEST extension (recommended)?(.*): y
(.*)Choose:(.*): x  

这不起作用:由于条目(.*)Choose!(.*):是重复的(Ansible对此表示不满(,预期模块会对命令进行"X"响应,因此不会发生任何事情。

我尝试了另一种代码:

- name: configure VirtualGL (vglserver_config)
ansible.builtin.expect:
command: "{{ vglserver_config_cmd }}"
responses:
Question:
- 1
- y
- y
- y
- y
- x

但是这种语法是不正确的。Ansible抛出错误。

我该如何解决这个问题?

Thx!Jose

PS。编辑了第二个代码示例,以反映我也测试过的代码示例(与Ansible提出的错误相同(

好的。。。为什么我要将expect模块用于具有无人参与模式参数的命令。。。我太笨了。

我把";期望";任务到";命令";具有适当的参数。

最新更新