# Comparing two hosts with ansible (installed packages and configuration files)

**URL:** <https://forum.ansible.com/t/comparing-two-hosts-with-ansible-installed-packages-and-configuration-files/32193>\
**Category:** Ansible Project\
**Created:** [February 10, 2020, 7:45pm UTC](https://forum.ansible.com/t/comparing-two-hosts-with-ansible-installed-packages-and-configuration-files/32193 "2020-02-10T19:45:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elb\_Isna](https://avatars.discourse-cdn.com/v4/letter/e/0ea827/32.png) [@Elb\_Isna](https://forum.ansible.com/u/Elb_Isna)\
**Post date:** [February 10, 2020, 7:45pm UTC](https://forum.ansible.com/t/comparing-two-hosts-with-ansible-installed-packages-and-configuration-files/32193/1 "2020-02-10T19:45:39Z")

</div>

How can I use ansible to check out the software differences (installed packages and configuration files) between two debian hosts?

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [February 10, 2020, 8:15pm UTC](https://forum.ansible.com/t/comparing-two-hosts-with-ansible-installed-packages-and-configuration-files/32193/2 "2020-02-10T20:15:52Z")

</div>

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](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](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

&nbsp;&nbsp;- hosts: host1:host2  
&nbsp;&nbsp;&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- package\_facts:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- debug:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg: "{{ hostvars.host1.ansible\_facts.packages|  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;difference(hostvars.host2.ansible\_facts.packages) }}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run\_once: true

HTH,

&nbsp;&nbsp;-vlado

---

<div class="post-metadata">

**Author:** ![Elb\_Isna](https://avatars.discourse-cdn.com/v4/letter/e/0ea827/32.png) [@Elb\_Isna](https://forum.ansible.com/u/Elb_Isna)\
**Post date:** [February 13, 2020, 4:15pm UTC](https://forum.ansible.com/t/comparing-two-hosts-with-ansible-installed-packages-and-configuration-files/32193/3 "2020-02-13T16:15:41Z")

</div>

Thank you very much for your answer.
