This role lets you detect changes in files between operations, so that you can indicate changes if, and only if, the file actually changed.
This is useful when you do ad-hoc commands (command
, shell
, etc.) that cannot indicate if changes have been made or not.
Name | Required | Example | Description |
---|---|---|---|
path |
yes | /etc/acme/foobar.com/foobar.com.cer |
File to check changes on. |
mode |
yes | before |
Indicate whether the check is before or after the command(s). Possible values are before and after . If before , it calculates the checksum, if after , it checks the current checksum with the one calculated during the before run, and indicates the change if they differ. |
verbose |
no | true |
If true , print more diagnostic messages. Defaults to false . |
- include_role:
name: noobient.file_changed
vars:
path: /etc/acme/foobar.com/foobar.com.cer
mode: before
- name: Do stuff on file
command:
cmd: /opt/acme.sh --install-cert -d foobar.com --cert-file /etc/acme/foobar.com/foobar.com.cer
changed_when: false
- include_role:
name: noobient.file_changed
vars:
path: /etc/foo.conf
mode: after
verbose: true
Key | Type | Example | Description |
---|---|---|---|
file_changed.changed |
boolean | true |
Indicates whether the file changed between the before and after runs. In before mode, it's always false . |
Platform | Support | Status |
---|---|---|
Linter | ✅ | |
AlmaLinux 8 | ✅ | |
AlmaLinux 9 | ✅ | |
Fedora 40 | ✅ | |
Fedora 41 | ✅ | |
Ubuntu 20.04 | ✅ | |
Ubuntu 22.04 | ✅ | |
Ubuntu 24.04 | ✅ |