community.internal_test_tools.files_diff module – Check whether there were changes since files_collect was called

Note

This module is part of the community.internal_test_tools collection (version 0.12.0).

It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.internal_test_tools.

To use it in a playbook, specify: community.internal_test_tools.files_diff.

New in community.internal_test_tools 0.3.0

Synopsis

Parameters

Parameter

Comments

fail_on_diffs

boolean

Whether to fail when differences are found, instead of simply returning changed=true.

Choices:

  • false ← (default)

  • true

state

dictionary / required

Notes

Note

  • Supports check_mode. The module never modifies anything, so check mode behavior is identical to regular behavior.

Examples

- name: Recursively collect information on all files in output_dir
  community.internal_test_tools.files_collect:
    directories:
      - path: "{{ output_dir }}"
  register: state

# ... some tasks in between ...

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

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

added_dirs

list / elements=path

A list of directories that have been added.

Returned: success

Sample: ["dir_a", "dir/dir_b"]

added_files

list / elements=path

A list of files that were added.

Returned: success

Sample: ["file_a.txt", "dir/file_b"]

changed

boolean

Whether any file or directory changed.

These can be attribute changes, time changes, or content changes.

Returned: success

Sample: true

changed_content

boolean

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

changed_dirs

list / elements=path

A list of directories that have been changed.

Returned: success

Sample: ["dir_a", "dir/dir_b"]

changed_files

list / elements=path

A list of files that were changed.

Attribute changes, times changes, inode changes, symlink changes, and content changes are considered.

Returned: success

Sample: ["file_a.txt", "dir/file_b"]

changed_files_content

list / elements=path

A list of files whose content was changed.

Only content changes are considered.

Returned: success

Sample: ["file_a.txt", "dir/file_b"]

removed_dirs

list / elements=path

A list of directories that have been removed.

Returned: success

Sample: ["dir_a", "dir/dir_b"]

removed_files

list / elements=path

A list of files that were removed.

Returned: success

Sample: ["file_a.txt", "dir/file_b"]

Authors

  • Felix Fontein (@felixfontein)