Loops 使用循环时,播放回放不会显示所有故障
我试图从某些文件中获取信息,并在文件不存在的情况下显示错误 问题是计数器仅显示一个错误,即使有多个文件不存在Loops 使用循环时,播放回放不会显示所有故障,loops,ansible,task,counter,Loops,Ansible,Task,Counter,我试图从某些文件中获取信息,并在文件不存在的情况下显示错误 问题是计数器仅显示一个错误,即使有多个文件不存在 - name: Show file version win_file_version: path: "{{ item.path }}" loop: - { name: 'Forksdump', path: 'C:\Windows\SysWOW64\Forksdump.exe' } - { name: 'Runfocus', path
- name: Show file version
win_file_version:
path: "{{ item.path }}"
loop:
- { name: 'Forksdump', path: 'C:\Windows\SysWOW64\Forksdump.exe' }
- { name: 'Runfocus', path: 'C:\Windows\SysWOW64\Runfocus' }
register: var_service
# failed_when: var_service.win_file_version | length == 0
ignore_errors: yes
- name: Show failure if service cannot be queried.
fail:
msg: The file does not exist
when: item is failed
with_items: "{{ var_service.results }}"
输出为红色,失败,但播放回放计数器仅显示一个失败
TASK [win_inventory : Show file version] ***************
failed: [windows_host] (item={'name': 'Forksdump',
.
.
failed: [windows_host] (item={'name': 'Runfocus',
...ignoring
TASK [win_inventory : Show failure if service cannot be queried..] ***************
failed: [windows_host] (item={'changed': False, 'msg': 'Specified path...
.
.
.
failed: [windows_host] (item={'changed': False, 'msg': 'Specified path..
.
.
.
***PLAY RECAP***windows_host : ok=3 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=1****
重述中的数字与任务相关,而不是与不同任务中所有可能的迭代相关。您可能会根据任务的结果来计算这一点,并在失败的情况下使用a来处理注册的var。当使用阻塞/救援构造时,我只得到一个“failed=1”,而1 saved=1