很抱歉,您的问题真的很笨拙,我正在尝试更好地学习Ansible,但我遇到了以下问题:我有3个CentOS主机,我尝试使第一个任务失败,获取变量,如果该变量无法运行下一个任务。
---
- hosts: slaves
become: yes
tasks:
- name: install httpd
apt: name=apache2 state=latest
register: result
ignore_errors: true
- name: install httpd again
yum: name=httpd state=latest
when: result|failed
但是我没有成功地工作:
fatal: [slave2]: FAILED! => {"msg": "The conditional check 'result|failed' failed. The error was: template error while templating string: no filter named 'failed'. String: {% if result|failed %} True {% else %} False {% endif %}\n\nThe error appears to be in '/private/etc/ansible/vars/Conditional': line 11, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: install httpd Again\n ^ here\n"}
好吧,我回答了我自己的问题。似乎不再起作用失败,而是:时间:结果失败