需要使用Ansible自动安装cisco anyconnect。在运行安装脚本时,它要求同意条款和条件。我怎么才能解析出“是”呢?下面的第一种方法显然是有效的(还没有尝试过),但是根据这个Ansible doco,我需要Python2.6;我需要Python3的解决方案。下面的第二种方法也不起作用。
攻略代码:
- name: Install CISCO annyconnect #>>>> needs pexpect module from python2 <<<<
become: yes
expect:
command: "/opt/CISCO/{{ vpn }}/vpn/vpn_install.sh"
responses:
Question:
- yes- name: Install CISCO annyconnect
become: yes
shell: yes | "/opt/CISCO/{{ vpn }}/vpn/vpn_install.sh"通过脚本安装Cisco VPN:
.
.
.
Description of Other Rights and Obligations
Please refer to the Cisco Systems, Inc. End User License Agreement.
http://www.cisco.com/en/US/docs/general/warranty/English/EU1KEN_.html
Do you accept the terms in the license agreement? [y/n] 发布于 2021-02-07 18:00:58
该解决方案不需要Python2.6,而是python >= 2.6。
“响应”映射背后的逻辑是,当在输出中找到左侧时,它将用右侧响应程序。其思想是查找输入提示,并在找到提示时进行响应。
所以,目前您的示例代码在程序输出中查找“问题”(可能不会匹配任何内容),但它应该查找一些其他字符串,告诉我们它需要输入。“你接受吗?”看起来是个不错的候选人。
- name: Install CISCO annyconnect #>>>> needs pexpect module from python2 <<<<
become: yes
expect:
command: "/opt/CISCO/{{ vpn }}/vpn/vpn_install.sh"
responses:
"Do you accept": yhttps://stackoverflow.com/questions/66084902
复制相似问题