title: Ansible and hardware checks
body: <p>I have to check different hardware and configurations elements on Linux machines using ansible, and I am not sure at all about how to do it (RAM, disk space, DNS, CPU...), I've understood that I can find nearly all I want in the ansible facts, but I do not understand how I can use it.</p>
  
  <p>For example, I have to check if the RAM amount is at least of 4GB and have an alarm if not, so I tried many things, and... nothing works.</p>
  
  <p>Here is an example of what I tried.</p>
  
  <pre><code> - hosts: client
     remote_user: user
  
    tasks:
        - debug: var=ansible_memory_mb
        - debug: msg="total RAM is {{ ansible_memory_mb.real.total }}"
        - fail: msg="not enough RAM"t
        - when: {{ ansible_memory_mb.real.total }} &lt; 4096
  </code></pre>
  
  <p>Could you tell me how it works ? and maybe there is a better way to do what I want using Ansible ?</p>
  
  <p>Thank you for your answer.</p>