How can I use ansible to check out the software differences (installed packages and configuration files) between two debian hosts?
Collect the list of installed packages with "package_facts"
https://docs.ansible.com/ansible/latest/modules/package_facts_module.html#package-facts-package-information-as-facts
and use "Set theory filters" to find the differences
https://docs.ansible.com/ansible/devel/user_guide/playbooks_filters.html#set-theory-filters
For example the playbook below shall list the packages installed in
host1 but missing in host2
- hosts: host1:host2
tasks:
- package_facts:
- debug:
msg: "{{ hostvars.host1.ansible_facts.packages|
difference(hostvars.host2.ansible_facts.packages) }}"
run_once: true
HTH,
-vlado
Thank you very much for your answer.