Frequently we might need to make a change to a file and respond to removals as well as additions.
This playbook demonstrates how we can detect changes (using the Ansible host).
- Run the playbook in regular mode
ansible-playbook demo-compare.yaml
. Look for a file nameddemo-compare.txt
alongside the playbook. - Change a name in the
file_data
list. - Re-run the playbook in
--check
mode. - If any changes would be made (
--check
mode) or are made (regular mode) as a result, these are displayed by the final debug module.
TASK [debug] ******************************************************************
ok: [127.0.0.1] => {
"msg": "removed: []\nadded: ['rudolph']\n"
}