Ansible showing incorrect info when i try to find free space in switch, please help

33 views
Skip to first unread message

Vikram S

unread,
Mar 6, 2021, 8:32:58 PM3/6/21
to Ansible Project

I have written a script to check for free space in switch before i proceed to copy image. I used ios_facts module and i used below return values however the free and total space displayed is incorrect than the actual free/total space i saw in switch. Why is this happening?

Incorrect value shown for 2960 and 3650 switch but correct value shown when i run the same script in GNS3 router. Even when i convert the bytes/kb shown to MB, it is inccorect.

How to fix this or is there an alternate way to gather freee space and proceed with copying image only if free space is above certain MB?

ansible_net_memfree_mb ansible_net_memtotal_mb ansible_net_filesystems_info

  • name: Gather IOS Facts

    ios_facts: subset: all
    • debug:

      msg:

      • "version is {{ ansible_net_memfree_mb }}"

      register: print_output

    • name: DISPLAY IF SUFFICIENT SPACE IS THERE OR NOT assert:

      that:

      - ansible_net_memfree_mb >= 14920

      fail_msg: "THERE IS not SUFFICIENT SPACE TO COPY IMAGE"

      success_msg: "THERE IS SUFFICIENT SPACE TO COPY IMAGE"

Dick Visser

unread,
Mar 7, 2021, 2:07:49 PM3/7/21
to ansible...@googlegroups.com
Nothing prevents you from running a script that returns whatever you want, and use that in the conditional logic in subsequent tasks



--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a7bbc4ad-d4fa-4f7f-bbbf-74c93c8b5cdcn%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.
Reply all
Reply to author
Forward
0 new messages