2017-09-13 90 views
0

我想在使用stat模塊的劇本中找到文件的校驗和。stat.checksum返回值缺少的可行2.2

--- 
    - 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的發揮得到一些更冗長而且我注意到,存在的返回值沒有校驗和我得到的錯誤模塊。

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 
    } 
} 

因此,我使用顯示的返回值之一重新運行了遊戲,並且該遊戲似乎可以成功運行。

我使用ansible的版本是2.2.0.0

ansible 2.2.0.0 
    config file = /etc/ansible/ansible.cfg 
    configured module search path = Default w/o overrides 

我失去的是什麼?

回答

0

我看到"isdir": true。目錄不顯示校驗和。

+0

謝謝!就是這樣。我忘了在路徑中提到該文件 – blo0old