- hosts: remote_1
tasks:
- name: first file check
stat:
path: /root/abc.txt
#get_checksum: yes
checksum_algorithm: sha256
register: test_file_check_1
- debug:
var: test_file_check_1.stat.checksum
when: test_file_check_1.stat.exists
- hosts: remote_2
tasks:
- name: next check
stat:
path: /root/abc.txt
#get_checksum: yes
checksum_algorithm: sha256
register: test_file_check_2
- debug:
var: test_file_check_2.stat.checksum
when: test_file_check_2.stat.exists
- name: Block run only if file has no changes
command: /bin/true
when: test_file_check_1.stat.checksum != test_file_check_2.stat.checksum
上面的代码给出了最后一个块的错误。错误!'when' 不是 Play 的有效属性
该错误似乎出现在“/root/two_file_stat.yml”中:第 27 行,第 3 列,但可能在文件中的其他位置,具体取决于确切的语法问题。
违规行似乎是:
- 名称:仅当文件没有更改时才阻止运行 ^ 此处