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可以判断文件存不存在
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

快乐骑行^_^

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值