stat.checksum return ansible 2.2 中缺少值
stat.checksum return value missing in ansible 2.2
我正在尝试使用 stat 模块在 playbook 中查找文件的校验和。
---
- name: loading checksum to variable
stat:
path: /data/foo.256
checksum_algorithm: sha256
register: origin
- debug:
msg: "The checksum of the file is {{ origin.stat.checksum }}"
当我 运行 剧本是
时我得到的错误
fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'dict object' has no attribute 'checksum'\n\nThe error appears to have been in '/data/playbooks/roles/test/tasks/main.yml': line 8, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - debug:\n ^ here\n"}
我试图使用 -vvv
来让游戏更加冗长,但我注意到模块的 return 值中没有校验和。
ok: [localhost] => {
"changed": false,
"invocation": {
"module_args": {
"checksum_algorithm": "sha256",
"follow": false,
"get_checksum": true,
"get_md5": true,
"mime": false,
"path": "/data/foo.256"
},
"module_name": "stat"
},
"stat": {
"atime": 1505250191.0,
"ctime": 1505250179.0,
"dev": 2057,
"executable": true,
"exists": true,
"gid": 0,
"gr_name": "root",
"inode": 5945,
"isblk": false,
"ischr": false,
"isdir": true,
"isfifo": false,
"isgid": false,
"islnk": false,
"isreg": false,
"issock": false,
"isuid": false,
"mode": "0755",
"mtime": 1505250179.0,
"nlink": 2,
"path": "/data/foo.256",
"pw_name": "root",
"readable": true,
"rgrp": true,
"roth": true,
"rusr": true,
"size": 4096,
"uid": 0,
"wgrp": false,
"woth": false,
"writeable": true,
"wusr": true,
"xgrp": true,
"xoth": true,
"xusr": true
}
}
因此,我使用显示的 return 值之一重新 运行 播放,并且播放似乎成功运行。
我使用的ansible版本是2.2.0.0
ansible 2.2.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
我在这里错过了什么?
我明白了"isdir": true
。不显示目录的校验和。
我正在尝试使用 stat 模块在 playbook 中查找文件的校验和。
---
- name: loading checksum to variable
stat:
path: /data/foo.256
checksum_algorithm: sha256
register: origin
- debug:
msg: "The checksum of the file is {{ origin.stat.checksum }}"
当我 运行 剧本是
时我得到的错误fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'dict object' has no attribute 'checksum'\n\nThe error appears to have been in '/data/playbooks/roles/test/tasks/main.yml': line 8, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - debug:\n ^ here\n"}
我试图使用 -vvv
来让游戏更加冗长,但我注意到模块的 return 值中没有校验和。
ok: [localhost] => {
"changed": false,
"invocation": {
"module_args": {
"checksum_algorithm": "sha256",
"follow": false,
"get_checksum": true,
"get_md5": true,
"mime": false,
"path": "/data/foo.256"
},
"module_name": "stat"
},
"stat": {
"atime": 1505250191.0,
"ctime": 1505250179.0,
"dev": 2057,
"executable": true,
"exists": true,
"gid": 0,
"gr_name": "root",
"inode": 5945,
"isblk": false,
"ischr": false,
"isdir": true,
"isfifo": false,
"isgid": false,
"islnk": false,
"isreg": false,
"issock": false,
"isuid": false,
"mode": "0755",
"mtime": 1505250179.0,
"nlink": 2,
"path": "/data/foo.256",
"pw_name": "root",
"readable": true,
"rgrp": true,
"roth": true,
"rusr": true,
"size": 4096,
"uid": 0,
"wgrp": false,
"woth": false,
"writeable": true,
"wusr": true,
"xgrp": true,
"xoth": true,
"xusr": true
}
}
因此,我使用显示的 return 值之一重新 运行 播放,并且播放似乎成功运行。
我使用的ansible版本是2.2.0.0
ansible 2.2.0.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
我在这里错过了什么?
我明白了"isdir": true
。不显示目录的校验和。