cancel
Showing results for 
Search instead for 
Did you mean: 
JS_Learning
Moderator
Moderator
  • 2,905 Views

RH294: clarification needed on an ansible ram related fact

 

Hi,

In RH294, in the pdf called:RH294-RHEL8.0-en-1-20190531, page 189, it asks:

"Has at least the amount of RAM specified by the min_ram_mb variable. The min_ram_mb
variable is defined in the vars.yml file and has a value of 256."

 

1) In the answer, it says, arbitrarily:

when: >
ansible_memtotal_mb < min_ram_mb or
ansible_distribution != "RedHat"

Why using that fact and not using instead:

ansible_memory_mb.real.total

If it's valid or similar, then the answer should explain that also.

 

2) The explanation could provide an example on how to find that.

I did a few trials errors with the ad-hoc command and the setup module, not know exactly the fact name:

ansible all -m setup | grep -i mem -> that one would not show the .real.total

ansible all -m setup -a 'filter=*memory*' -> that one would not know ansible_memtotal...

ansible all -m setup -a 'filter=*mem*' -> that one would show both but one needed to know it would be "mem" and not "memory".

I think the course could explain how we reach that value, as opposed to telling what it should be.

 

Cheers!

 

 

 

 

 

 

0 Kudos
4 Replies
dennishart
Mission Specialist
Mission Specialist
  • 2,896 Views

So on the first part I believe they have you strive to do the first way because it is simpler. (either is techincally right because they are both ints.) Also I found this below to be useful when shifting through setup info. Which I agree it should show there's multiple solutions to that part.

ansible localhost -m setup | less

This makes it where you can search like with man pages rather than guessing on filter and grep.

with /mem 

then press n to go to the next and N to go back to the previous found match.

JS_Learning
Moderator
Moderator
  • 2,868 Views

Thanks! You are right, I forgot about using "pipe less", it is indeed a very good method to display see all the variables.

 

littlebigfab
Starfighter Starfighter
Starfighter
  • 2,885 Views

Hi,

Some facts can be retrieved with different names. It doesn't matter. That chapter's objective is to teach you how to use ansible facts in general.

Since you have already learnt how to execute the setup module with an ad hoc command, and since you were able to find ansible_memory_mb.real.total by yourself, then you're good to go. Good job! :)

To find a fact I don't know yet, I explore the output of the setup module or I review the example provided in the official documentation. Facts' names and structures are pretty self-explicit, so I always end up finding what I need :)

JS_Learning
Moderator
Moderator
  • 2,867 Views

Hi, thanks for responding and sharing the tips!

In fact I think, for the learner, it is very important to be told, at that stage, that there are several facts which can be similar, and explain one is preferred over another. 

In that very example, I was really wondering why they use that one and not the other one. So, for the learner who discovered two similars facts, it's better to explain. Maybe the explanation is as simple as you said, sometimes, there are other acceptable facts.

I still think it is missing, for the less experienced learners, how to reach that conclusion in the example (as for example the ad-hoc and the setup module with | less).

It's a good idea to explore the official doc also, I did not think of that in the context!

Cheers,

 

0 Kudos
Join the discussion
You must log in to join this conversation.