Episode 10: Installing Redis Using An Ansible Galaxy Role
A pre-built playbook from Ansible Galaxy lets us easily install Redis. (Even we don’t re-invent the wheel every time.) The Request Metrics application will use Redis as its main data store. We need to install Redis on our servers to find out if this is a good plan. Ansible provides a repeatable way of doing this configuration work.
Redis setup takes more steps than just
apt-get install redis. Because we really don’t want to learn all the necessary steps, we turn to pre-built role written by David Wittman.
Download Redis Roles With Galaxy
Redis roles are shared through Ansible Galaxy. The davidwittman.redis role is downloaded by running Galaxy from the CLI:
There is one problem with the above command: it downloads the role to a system wide, shared location. Each developer needs to run the above command before running the playbook. We like our repositories to be standalone when possible. A slightly modified command saves the role locally. This lets us commit it to git:
Now that the role is downloaded, it can be called from our playbook. The
include_role module works well because it packages everything up into a single, self contained task:
And we’re done! A bunch of time was saved by using an Ansible Galaxy role written by a stranger on the internet. Next, we’ll code up the Request Metrics application to connect to our fresh Redis instance.