How to find the memory of remote systems using the setup module in Ansible

0 votes

Hi Guys,

I have three managed nodes. I want to install webserver to these nodes using Ansible-playbook. But before installing the software I want to fetch the memory details of each node. How can I do that in Ansible?

Aug 10, 2020 in Ansible by akhtar
• 38,260 points
5,907 views

1 answer to this question.

0 votes

Hi@akhtar,

You need to use the setup module to do this task. This module has the capability to gather information on remote nodes. You can use the below-given command to find the memory of remote nodes.

$ ansible server -m setup -a 'filter=ansible_*_mb'

192.168.0.180 | SUCCESS => {
    "ansible_facts": {
        "ansible_memfree_mb": 5723,
        "ansible_memory_mb": {
            "nocache": {
                "free": 6711,
                "used": 1262
            },
            "real": {
                "free": 5723,
                "total": 7973,
                "used": 2250
            },
            "swap": {
                "cached": 0,
                "free": 8103,
                "total": 8103,
                "used": 0
            }
        },
        "ansible_memtotal_mb": 7973,
        "ansible_swapfree_mb": 8103,
        "ansible_swaptotal_mb": 8103,
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false
}
answered Aug 10, 2020 by MD
• 95,460 points

Related Questions In Ansible

0 votes
1 answer

How to install httpd web server in remote node using Ansible?

Hi@akhtar, You need to use the package module in Ansible. ...READ MORE

answered Jul 30, 2020 in Ansible by MD
• 95,460 points
2,607 views
0 votes
1 answer

How to copy files in remote system using Ansible?

Hi@akhtar, You need to use the copy module ...READ MORE

answered Jul 30, 2020 in Ansible by MD
• 95,460 points
2,407 views
0 votes
1 answer

How to start httpd service in a remote system using Ansible?

Hi@akhtar, Ansible has a module named service. This ...READ MORE

answered Jul 30, 2020 in Ansible by MD
• 95,460 points
3,411 views
0 votes
1 answer

How to capture the output of a task in Ansible Playbook?

Hi@akhtar, Ansible registers module used to capture/store the ...READ MORE

answered Aug 2, 2020 in Ansible by MD
• 95,460 points
15,086 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,053 views
+2 votes
1 answer
0 votes
1 answer

How to overwrite the content of a file in remote systems using Ansible playbook?

Hi@akhtar, You can find one argument in the ...READ MORE

answered Aug 2, 2020 in Ansible by MD
• 95,460 points
14,465 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP