On 14/01/2022 18:23, Jibun no Kage . wrote:
Odd results from query of /proc/meminfo?

When I do the following from shell...
# cat /proc/meminfo | grep MemTotal
MemTotal:        8087276 kB

But when I do the same via Ansible...
ok: [192.168.1.212] => {
     "msg": "Pi Memory Total: MemTotal:         957160 kB"
}


Why messing with the shell when the information is already present in the facts?

 - name: Show memory
      debug:
        msg: "{{ ansible_memory_mb }}"

TASK [Show memory] *************************************************************
ok: [bullseye-test-box] =>
  msg:
    nocache:
      free: 828
      used: 1154
    real:
      free: 82
      total: 1982
      used: 1900
    swap:
      cached: 0
      free: 0
      total: 0
      used: 0

Regards
       Racke

Ansible Source...
     - name: Memory Total
       #shell: "cat /proc/meminfo | grep MemTotal | cut -d ':' -f2 | cut -d 'k' -f1 
| tr -d ' '"
       shell: "cat /proc/meminfo | grep MemTotal"
       register: m
       changed_when: False

     - name: Memory Total
       debug:
         msg: "Memory Total: {{ m.stdout }}"

Returned value is greater than physical memory size!



--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/39e4a9c2-480d-d2c6-c1c7-4e77a7415b52%40linuxia.de.

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to