Ansible Module stat: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 19: Line 19:


The module result variable has the following structure:
The module result variable has the following structure:
<syntaxhighlight lang=''json'>
<syntaxhighlight lang='json'>
{
{
        "changed": false,
  "changed": false,
        "failed": false,
  "failed": false,
        "stat": {
  "stat": {
            "atime": 1625423678.392114,
    "atime": 1625423678.392114,
            "attr_flags": "",
    "attr_flags": "",
            "attributes": [],
    "attributes": [],
            "birthtime": 1625352249.6358514,
    "birthtime": 1625352249.6358514,
            "block_size": 4096,
    "block_size": 4096,
            "blocks": 0,
    "blocks": 0,
            "charset": "binary",
    "charset": "binary",
            "ctime": 1625423644.281025,
    "ctime": 1625423644.281025,
            "dev": 16777220,
    "dev": 16777220,
            "device_type": 0,
    "device_type": 0,
            "executable": true,
    "executable": true,
            "exists": true,
    "exists": true,
            "flags": 0,
    "flags": 0,
            "generation": 0,
    "generation": 0,
            "gid": 20,
    "gid": 20,
            "gr_name": "staff",
    "gr_name": "staff",
            "inode": 30508999,
    "inode": 30508999,
            "isblk": false,
    "isblk": false,
             "ischr": false,
             "ischr": false,
             "isdir": true,
             "isdir": true,
Line 71: Line 71:
             "xusr": true
             "xusr": true
         }
         }
    }
}
</syntaxhighlight>
</syntaxhighlight>

Revision as of 06:11, 5 July 2021

External

Internal

Overview

Retrieves facts for a file similar to the Linux/Unix "stat" command.

- name: Gather stats on the given path
  stat:
    path: "{{ some_path }}"
  register: some_path_stat
- name: debug
  debug:
    var: some_path_stat

The module result variable has the following structure:

{
  "changed": false,
  "failed": false,
  "stat": {
    "atime": 1625423678.392114,
    "attr_flags": "",
    "attributes": [],
    "birthtime": 1625352249.6358514,
    "block_size": 4096,
    "blocks": 0,
    "charset": "binary",
    "ctime": 1625423644.281025,
    "dev": 16777220,
    "device_type": 0,
    "executable": true,
    "exists": true,
    "flags": 0,
    "generation": 0,
    "gid": 20,
    "gr_name": "staff",
    "inode": 30508999,
    "isblk": false,
            "ischr": false,
            "isdir": true,
            "isfifo": false,
            "isgid": false,
            "islnk": false,
            "isreg": false,
            "issock": false,
            "isuid": false,
            "mimetype": "inode/directory",
            "mode": "0755",
            "mtime": 1625423644.281025,
            "nlink": 24,
            "path": "/Users/ovidiu/Library/Application Support/JetBrains/IntelliJIdea2021.2",
            "pw_name": "ovidiu",
            "readable": true,
            "rgrp": true,
            "roth": true,
            "rusr": true,
            "size": 768,
            "uid": 502,
            "version": null,
            "wgrp": false,
            "woth": false,
            "writeable": true,
            "wusr": true,
            "xgrp": true,
            "xoth": true,
            "xusr": true
        }
}