以下是剧本:
- name: Find "N-1" unpatching ID from the Yum History
become: yes
shell: yum history | head -n -3 | tail -n +5 | awk '{print $1}' | head -n +1
register: unpatch
- name: Use expect module to unpatch the server to N-1 level
expect:
command: yum history undo {{ unpatch.stdout_lines }}
responses:
'Is this ok \[y/d/N]\:"y"'
在第二个任务上运行此Playbook时出现的错误如下:
fatal: [linux-Server-x86-64]: FAILED! => {"changed": false, "msg": "argument responses is of type <type 'str'> and we were unable to convert to dict: dictionary requested, could not parse JSON or key=value"}
我试图对命令yum history undo ${ID}
做出各种响应,但它要么在游戏中的任务级别卡住了,要么yum进程一直挂在系统中。
- name: Use expect module to unpatch the server to N-1 level
expect:
command: yum history undo {{ unpatch.stdout_lines }}
responses: yes
1条答案
按热度按时间rks48beu1#
由于您已经在使用
command
模块,并且无论如何都希望使用yes
来回答yum
命令提出的问题,因此根据man yum
,您可以使用--assumeyes
并且该任务将不需要
expect
模块。类似问答
yum install
always answeringyes
in the y/n questions?yes
foryum install
automatically?更多阅读
yes
command?echo yes | <command>