community.internal_test_tools.files_diff (0.10.1) — module

Check whether there were changes since files_collect was called

| "added in version" 0.3.0 of community.internal_test_tools"

Authors: Felix Fontein (@felixfontein)

Install collection

Install with ansible-galaxy collection install community.internal_test_tools:==0.10.1


Add to requirements.yml

  collections:
    - name: community.internal_test_tools
      version: 0.10.1

Description

This module checks whether any changes (timestamps, attributes, content) were made to files and directories that M(community.internal_test_tools.files_collect) collected information on earlier.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Recursively collect information on all files in output_dir
  community.internal_test_tools.files_collect:
    directories:
      - path: "{{ output_dir }}"
  register: state
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# ... some tasks inbetween ...

- name: Verify whether any file changed in output_dir
  community.internal_test_tools.files_diff:
    state: "{{ state.state }}"

Inputs

    
state:
    description:
    - The state returned by M(community.internal_test_tools.files_collect).
    required: true
    type: dict

fail_on_diffs:
    default: false
    description:
    - Whether to fail when differences are found, instead of simply returning RV(changed=true).
    type: bool

Outputs

added_dirs:
  description:
  - A list of directories that have been added.
  elements: path
  returned: success
  sample:
  - dir_a
  - dir/dir_b
  type: list
added_files:
  description:
  - A list of files that were added.
  elements: path
  returned: success
  sample:
  - file_a.txt
  - dir/file_b
  type: list
changed:
  description:
  - Whether any file or directory changed.
  - These can be attribute changes, time changes, or content changes.
  returned: success
  sample: true
  type: bool
changed_content:
  description:
  - Whether any file content changed. This does not consider added or removed files,
    or files which were converted to links or vice versa.
  returned: success
  sample: true
  type: bool
changed_dirs:
  description:
  - A list of directories that have been changed.
  elements: path
  returned: success
  sample:
  - dir_a
  - dir/dir_b
  type: list
changed_files:
  description:
  - A list of files that were changed.
  - Attribute changes, times changes, inode changes, symlink changes, and content
    changes are considered.
  elements: path
  returned: success
  sample:
  - file_a.txt
  - dir/file_b
  type: list
changed_files_content:
  description:
  - A list of files whose content was changed.
  - B(Only) content changes are considered.
  elements: path
  returned: success
  sample:
  - file_a.txt
  - dir/file_b
  type: list
removed_dirs:
  description:
  - A list of directories that have been removed.
  elements: path
  returned: success
  sample:
  - dir_a
  - dir/dir_b
  type: list
removed_files:
  description:
  - A list of files that were removed.
  elements: path
  returned: success
  sample:
  - file_a.txt
  - dir/file_b
  type: list