- What do we do to create a readers based fact cache?
Well, let's start with a new project directory.
And ensure that we have an ansible.cfg
and an inventory in there.
The major changes in the ansible.cfg
because in ansible.fg we need to indicate
that a redis based fact cache needs to be used.
This is a property of the default section.
So let's say fact_caching to redis fact_caching timeout
to 7,200 or whatever value works for you.
And most important, the fact_caching connection
is localhost 6379:0.
Then we also need to make sure that we have a redis process.
So sudo dnf install -y redis
which shouldn't be necessary in this case
because of the previous demo.
So we can use sudo systemctl status
on redis to verify the operation.
It is running, and let's not forget sudo pip3
and install redis for the corresponding patent components.
Already installed, that makes sense.
And now we can start using it.
So how do we do that?
Oh, ansible all -m setup, right, together some cache.
No, we need sudo password.
So let's enter a sudo password, there we go.
All right, now we have gathered some cache
and let's do some playbook that is using the cache.
So cache check yaml.
Gather_facts will be set to no.
And let's just use the setup module.
And that should do, so, there we go,
ansible.playbook cachecheck -k
because of the configuration.
And there we go, it's gathering the facts.
We don't see anything.
If you want to see something,
use register to show the value of the registered variable.
But the fact, the digital complaining means
that it is totally happy fetching this information
from the fact cache, and that's all.