ansible pexpect 模块,提示出现在下一行和多个提示
ansible pexpect module with prompt coming on the next line and more than one prompt
我有一个脚本提示我输入密码两次,但提示出现在下一行,如下所示:-
Password:
(I enter the Password here)
Re-enter Password:
(I enter the same Password here)
我正在尝试使用 Ansible pexpect 模块自动执行此操作,但我遇到了一些无法正常工作的问题:-
- name: myscript --setup-users
become: yes
become_user: someadmin
expect:
command: 'myscript --setup-users'
responses:
"Password:": "somepassword"
"Re-enter Password:": "somepassword"
args:
chdir: /home/someadmin/
when: someuser_out.stdout.find("someuser") == -1
我正在检查 "someuser" 是否在播放之前出现。
此代码无效。
请帮忙
得到这个与“\r\n”一起工作。
代码更改如下:-
- name: myscript --setup-users
become: yes
become_user: someadmin
expect:
command: 'myscript --setup-users'
responses:
"password:": "somepassword" #password for first prompt
"\r\n:": "someotherpassword" #password for second prompt which comes in the next line
"\r\n:": "someotherpassword" #same as above
args:
chdir: /home/someadmin/
when: someuser_out.stdout.find("someuser") == -1
我有一个脚本提示我输入密码两次,但提示出现在下一行,如下所示:-
Password:
(I enter the Password here)
Re-enter Password:
(I enter the same Password here)
我正在尝试使用 Ansible pexpect 模块自动执行此操作,但我遇到了一些无法正常工作的问题:-
- name: myscript --setup-users
become: yes
become_user: someadmin
expect:
command: 'myscript --setup-users'
responses:
"Password:": "somepassword"
"Re-enter Password:": "somepassword"
args:
chdir: /home/someadmin/
when: someuser_out.stdout.find("someuser") == -1
我正在检查 "someuser" 是否在播放之前出现。
此代码无效。
请帮忙
得到这个与“\r\n”一起工作。 代码更改如下:-
- name: myscript --setup-users
become: yes
become_user: someadmin
expect:
command: 'myscript --setup-users'
responses:
"password:": "somepassword" #password for first prompt
"\r\n:": "someotherpassword" #password for second prompt which comes in the next line
"\r\n:": "someotherpassword" #same as above
args:
chdir: /home/someadmin/
when: someuser_out.stdout.find("someuser") == -1