maxgalbu.tidy

ansible-tidy

Tidy role for Ansible, inspired by Puppet's tidy module. Remove unwanted files based on specific criteria.
Multiple criteria are AND’d together

Installation

ansible-tidy is an Ansible role distributed globally using Ansible Galaxy. In order to install Ansistrano role you can use the following command.

$ ansible-galaxy install maxgalbu.tidy

New in version: 1.7

parameter required default choices comments
tidy_age no 0
    Tidy files whose age is equal to or greater than the specified time. You can choose seconds, minutes, hours, days, or weeks by specifying the first letter of any of those words (e.g., ‘1w’). Specifying 0 will remove all files.
    tidy_force no
    • yes
    • no
    Force removal of non empty directories
    tidy_matches no
      One or more (shell type) file glob patterns, which restrict the list of files to be tidied to those whose basenames match at least one of the patterns specified. Multiple patterns can be specified using a list.
      tidy_path yes
        Path to the file or directory to manage. Must be fully qualified.
        tidy_recurse no no
        • yes
        • no
        If target is a directory, recursively descend into the directory looking for files to tidy.
        tidy_rmdirs no no
        • yes
        • no
        Tidy directories in addition to files; that is, remove directories whose age is older than the specified criteria. This will only remove empty directories, so all contained files must also be tidied before a directory gets removed.
        tidy_silent no no
        • yes
        • no
        Silently ignore failed commands.
        tidy_size no 0
          Tidy files whose size is equal to or greater than the specified size. Unqualified values are in bytes, but b, k, m, g, and t can be appended to specify bytes, kilobytes, megabytes, gigabytes, and terabytes, respectively. Size is not evaluated for directories.
          tidy_timestamp no atime
          • atime
          • mtime
          • ctime
          Set the mechanism for determining age. Default is atime.
          tidy_keep no 0 Keep x files, delete all the others. Works with recurse, it will keep x files in each folder if recurse=yes. Files are ordered before tidying up, using the `tidy_timestamp` param, so you can delete older files. Specifying 0 will remove all files.
          • Playbook example:
          ---
          - hosts: all
          
            roles:
              - role: maxgalbu.tidy
          
            vars:
              tidy_path: tests/files
              tidy_local_action: true
              tidy_recurse: true
              tidy_keep: 2
          
          About

          ansible-tidy

          Install
          ansible-galaxy install maxgalbu.tidy
          GitHub repository
          License
          gpl-2.0
          Downloads
          94