stat - retrieve file or file system status

Author:Bruce Pennypacker

Synopsis

New in version 1.3.

Retrieves facts for a file similar to the linux/unix ‘stat’ command.

Options

parameter required default choices comments
follow no
    Whether to follow symlinks
    get_md5 no True
      Whether to return the md5 sum of the file
      path yes
        The full path of the file/object to get the facts of

        Examples


        # Obtain the stats of /etc/foo.conf, and check that the file still belongs
        # to 'root'. Fail otherwise.
        - stat: path=/etc/foo.conf
          register: st
        - fail: msg="Whoops! file ownership has changed"
          when: st.stat.pw_name != 'root'
        
        # Determine if a path exists and is a directory.  Note we need to test
        # both that p.stat.isdir actually exists, and also that it's set to true.
        - stat: path=/path/to/something
          register: p
        - debug: msg="Path exists and is a directory"
          when: p.stat.isdir is defined and p.stat.isdir == true
        
        # Don't do md5 checksum
        - stat: path=/path/to/myhugefile get_md5=no