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.13.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

Attributes

Attribute

Support

Description

check_mode

Support: full

This action does not modify state.

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: partial

This action does not modify state.

In diff mode, shows the differences of the current state compared to state.

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

idempotent

Support: full

This action does not modify state.

When run twice in a row outside check mode, with the same arguments, the second invocation indicates no change.

This assumes that the system controlled/queried by the module has not changed in a relevant way.

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 converted from links.

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)