我正在尝试做这本剧本半天。我正在使用 stat 模块检查文件的 sha1sum,如果它不等于第二个文件,它应该替换正确的文件。但是在注册一些变量时,输出显示变量未定义我做错了什么?
---
- hosts: all
remote_user: root
tasks:
- name: get sum of file
stat:
path: /home/roundcube/config.php
checksum_algorithm: sha1
get_checksum: yes
register: sum
stat:
path: /home/archive/config.php
checksum_algorithm: sha1
get_checksum: yes
register: sum2
- name: result
ansible.builtin.copy:
src: /home/archive/config.php
dest: /home/roundcube/config.php
when: sum.stat.checksum != sum2.stat.checksum