ansible模块:stat用法

ansible模块:stat用法

ansible命令格式:

  • ansible [-m module_name] [-a args]
  • ansible后接主机名称:localhost,all,bigdataservers
  • ansible localhost -m stat -a “path=/moudle/zeppelin-0.9.0.tar.gz”
  • 主机名称在/etc/ansible/hosts中设置
vim /etc/ansible/hosts
[bigdataservers]
192.168.216.128
192.168.216.129
192.168.216.130
192.168.216.131
192.168.216.132

执行命令ansible localhost -m stat -a “path=/moudle/zeppelin-0.9.0.tar.gz”,输出如下所示:

ansible localhost -m stat -a "path=/moudle/zeppelin-0.9.0.tar.gz"

localhost | SUCCESS => {
    "changed": false,
    "stat": {
        "atime": 1634804115.4646418,
        "attr_flags": "",
        "attributes": [],
        "birthtime": 1634803919.6507857,
        "block_size": 4096,
        "blocks": 3048488,
        "charset": "unknown",
        "checksum": "3bf08372baf3c6296d2be5d989e694769ee9b705",
        "ctime": 1634806789.7500503,
        "dev": 16777220,
        "device_type": 0,
        "executable": false,
        "exists": true,
        "flags": 0,
        "generation": 0,
        "gid": 656741719,
        "gr_name": "FAREAST\\Domain Users",
        "inode": 69915420,
        "isblk": false,
        "ischr": false,
        "isdir": false,
        "isfifo": false,
        "isgid": false,
        "islnk": false,
        "isreg": true,
        "issock": false,
        "isuid": false,
        "mimetype": "unknown",
        "mode": "0644",
        "mtime": 1634803976.8654132,
        "nlink": 1,
        "path": "/moudle/zeppelin-0.9.0.tar.gz",
        "pw_name": "zeppelin",
        "readable": true,
        "rgrp": true,
        "roth": true,
        "rusr": true,
        "size": 1545613526,
        "uid": 309351035,
        "version": null,
        "wgrp": false,
        "woth": false,
        "writeable": true,
        "wusr": true,
        "xgrp": false,
        "xoth": false,
        "xusr": false
    }
}
  • “exists”: true,
  • 通过stat.exists可以判断文件存不存在

你可能感兴趣的:(日常分享专栏,服务器,ansible模块,stat用法)